aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2012-10-17 13:24:46 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-10-17 13:29:00 +0200
commite6cb8faa9160a5da4db8c443e10e4c3e34671336 (patch)
tree2c8b8f7337f8aaa07dd450d08906247f0aaa1f6e
parentf5b98f63862d4f36774d6baea5d3789350844e04 (diff)
Change usages of math.h into cmath. Fixes MacOS build.
At least on MacOS, but possibly elsewhere too, including cmath before or after math.h will undefine e.g. the isinf macro (and others). The math.h include headers will make sure that math.h cannot get included twice, so this will end with a situation where isinf is undefined, but std::isinf is there. Change-Id: Ie59aeadf2adde511ea8db5eb2fafd3272a7e9d51 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--masm/assembler/MacroAssembler.h2
-rw-r--r--masm/config.h4
-rw-r--r--qmljs_math.h2
-rw-r--r--qmljs_runtime.cpp12
-rw-r--r--qmljs_runtime.h12
-rw-r--r--qv4codegen.cpp2
-rw-r--r--qv4ecmaobjects.cpp2
-rw-r--r--qv4ir.cpp2
8 files changed, 20 insertions, 18 deletions
diff --git a/masm/assembler/MacroAssembler.h b/masm/assembler/MacroAssembler.h
index 43c9b470f7..b17e19bb9d 100644
--- a/masm/assembler/MacroAssembler.h
+++ b/masm/assembler/MacroAssembler.h
@@ -534,7 +534,7 @@ public:
bool shouldBlindDouble(double value)
{
// Don't trust NaN or +/-Infinity
- if (!isfinite(value))
+ if (!std::isfinite(value))
return true;
// Try to force normalisation, and check that there's no change
diff --git a/masm/config.h b/masm/config.h
index 2f4d9f4925..1ced4e454c 100644
--- a/masm/config.h
+++ b/masm/config.h
@@ -45,8 +45,10 @@
#include <wtf/Platform.h>
#ifdef __cplusplus
#include <wtf/Vector.h>
+#include <cmath>
+#else
+#include <math.h>
#endif
#include <limits.h>
-#include <math.h>
#endif // MASM_CONFIG_H
diff --git a/qmljs_math.h b/qmljs_math.h
index 8e4ff2c03b..89d6e28ee3 100644
--- a/qmljs_math.h
+++ b/qmljs_math.h
@@ -42,7 +42,7 @@
#define QMLJS_MATH_H
#include <QtCore/qnumeric.h>
-#include <math.h>
+#include <cmath>
#if 1 //CPU(X86_64)
diff --git a/qmljs_runtime.cpp b/qmljs_runtime.cpp
index 73391159f2..fd8d61a6ad 100644
--- a/qmljs_runtime.cpp
+++ b/qmljs_runtime.cpp
@@ -109,26 +109,26 @@ Value Value::fromString(Context *ctx, const QString &s)
int Value::toInt32(double number)
{
- if (! number || isnan(number) || isinf(number))
+ if (! number || std::isnan(number) || std::isinf(number))
return +0;
return (int) trunc(number); // ###
}
unsigned int Value::toUInt32(double number)
{
- if (! number || isnan(number) || isinf(number))
+ if (! number || std::isnan(number) || std::isinf(number))
return +0;
return (uint) trunc(number); // ###
}
int Value::toInteger(double number)
{
- if (isnan(number))
+ if (std::isnan(number))
return +0;
- else if (! number || isinf(number))
+ else if (! number || std::isinf(number))
return number;
const double v = floor(fabs(number));
- return signbit(number) ? -v : v;
+ return std::signbit(number) ? -v : v;
}
int Value::toUInt16(Context *ctx)
@@ -1007,7 +1007,7 @@ Value __qmljs_compare(Context *ctx, const Value x, const Value y, bool leftFirst
} else {
double nx = __qmljs_to_number(px, ctx);
double ny = __qmljs_to_number(py, ctx);
- if (isnan(nx) || isnan(ny)) {
+ if (std::isnan(nx) || std::isnan(ny)) {
return Value::undefinedValue();
} else {
return Value::fromBoolean(nx < ny);
diff --git a/qmljs_runtime.h b/qmljs_runtime.h
index 82becb1467..a8ea72ca9f 100644
--- a/qmljs_runtime.h
+++ b/qmljs_runtime.h
@@ -47,7 +47,7 @@
# include <QtCore/QDebug>
#endif
-#include <math.h>
+#include <cmath>
#include <cassert>
namespace QQmlJS {
@@ -733,10 +733,10 @@ inline double __qmljs_to_integer(const Value value, Context *ctx)
const double number = __qmljs_to_number(value, ctx);
if (qIsNaN(number))
return +0;
- else if (! number || isinf(number))
+ else if (! number || std::isinf(number))
return number;
const double v = floor(fabs(number));
- return signbit(number) ? -v : v;
+ return std::signbit(number) ? -v : v;
}
inline int __qmljs_to_int32(const Value value, Context *ctx)
@@ -749,7 +749,7 @@ inline int __qmljs_to_int32(const Value value, Context *ctx)
return static_cast<int>(number);
}
- if (! number || qIsNaN(number) || isinf(number))
+ if (! number || qIsNaN(number) || std::isinf(number))
return 0;
double D32 = 4294967296.0;
@@ -774,7 +774,7 @@ inline unsigned __qmljs_to_uint32(const Value value, Context *ctx)
return (unsigned) value.int_32;
double number = __qmljs_to_number(value, ctx);
- if (! number || qIsNaN(number) || isinf(number))
+ if (! number || qIsNaN(number) || std::isinf(number))
return +0;
double sign = (number < 0) ? -1.0 : 1.0;
@@ -792,7 +792,7 @@ inline unsigned __qmljs_to_uint32(const Value value, Context *ctx)
inline unsigned short __qmljs_to_uint16(const Value value, Context *ctx)
{
double number = __qmljs_to_number(value, ctx);
- if (! number || qIsNaN(number) || isinf(number))
+ if (! number || qIsNaN(number) || std::isinf(number))
return +0;
double sign = (number < 0) ? -1.0 : 1.0;
diff --git a/qv4codegen.cpp b/qv4codegen.cpp
index 892638fe88..69529cd695 100644
--- a/qv4codegen.cpp
+++ b/qv4codegen.cpp
@@ -47,7 +47,7 @@
#include <QtCore/QBitArray>
#include <QtCore/QStack>
#include <private/qqmljsast_p.h>
-#include <math.h>
+#include <cmath>
#include <iostream>
#include <cassert>
diff --git a/qv4ecmaobjects.cpp b/qv4ecmaobjects.cpp
index 54985facf7..f303f8f123 100644
--- a/qv4ecmaobjects.cpp
+++ b/qv4ecmaobjects.cpp
@@ -47,7 +47,7 @@
#include <QtCore/QDateTime>
#include <QtCore/QStringList>
#include <QtCore/QDebug>
-#include <math.h>
+#include <cmath>
#include <qmath.h>
#include <qnumeric.h>
#include <cassert>
diff --git a/qv4ir.cpp b/qv4ir.cpp
index 4805f62ee9..8248cbb647 100644
--- a/qv4ir.cpp
+++ b/qv4ir.cpp
@@ -44,7 +44,7 @@
#include <QtCore/qtextstream.h>
#include <QtCore/qdebug.h>
-#include <math.h>
+#include <cmath>
#include <cassert>
QT_BEGIN_NAMESPACE