summaryrefslogtreecommitdiff
path: root/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h')
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h
index 81a1d8a..7185c1b 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h
@@ -28,7 +28,7 @@
#include <float.h>
#include <limits>
-#include <math.h>
+#include <cmath>
#include <stdlib.h>
#if OS(SOLARIS)
@@ -67,20 +67,26 @@ inline double wtf_ceil(double x) { return copysign(ceil(x), x); }
#if OS(SOLARIS)
+namespace std {
+
#ifndef isfinite
inline bool isfinite(double x) { return finite(x) && !isnand(x); }
#endif
+#ifndef signbit
+inline bool signbit(double x) { return copysign(1.0, x) < 0; }
+#endif
#ifndef isinf
inline bool isinf(double x) { return !finite(x) && !isnand(x); }
#endif
-#ifndef signbit
-inline bool signbit(double x) { return x < 0.0; } // FIXME: Wrong for negative 0.
-#endif
+
+} // namespace std
#endif
#if OS(OPENBSD)
+namespace std {
+
#ifndef isfinite
inline bool isfinite(double x) { return finite(x); }
#endif
@@ -88,6 +94,8 @@ inline bool isfinite(double x) { return finite(x); }
inline bool signbit(double x) { struct ieee_double *p = (struct ieee_double *)&x; return p->dbl_sign; }
#endif
+} // namespace std
+
#endif
#if (COMPILER(MSVC) && _MSC_VER < 1800) || COMPILER(RVCT)
@@ -115,17 +123,23 @@ inline double trunc(double num) { return num > 0 ? floor(num) : ceil(num); }
#endif
-#if COMPILER(MSVC) && _MSC_VER < 1800
+#if COMPILER(MSVC)
+
+namespace std {
inline bool isinf(double num) { return !_finite(num) && !_isnan(num); }
inline bool isnan(double num) { return !!_isnan(num); }
+inline bool isfinite(double x) { return _finite(x); }
+#if _MSC_VER < 1800
inline bool signbit(double num) { return _copysign(1.0, num) < 0; }
+#endif
+
+} // namespace std
inline double nextafter(double x, double y) { return _nextafter(x, y); }
inline float nextafterf(float x, float y) { return x > y ? x - FLT_EPSILON : x + FLT_EPSILON; }
inline double copysign(double x, double y) { return _copysign(x, y); }
-inline int isfinite(double x) { return _finite(x); }
// Work around a bug in Win, where atan2(+-infinity, +-infinity) yields NaN instead of specific values.
inline double wtf_atan2(double x, double y)
@@ -151,10 +165,10 @@ inline double wtf_atan2(double x, double y)
}
// Work around a bug in the Microsoft CRT, where fmod(x, +-infinity) yields NaN instead of x.
-inline double wtf_fmod(double x, double y) { return (!isinf(x) && isinf(y)) ? x : fmod(x, y); }
+extern "C" inline double wtf_fmod(double x, double y) { return (!std::isinf(x) && std::isinf(y)) ? x : fmod(x, y); }
// Work around a bug in the Microsoft CRT, where pow(NaN, 0) yields NaN instead of 1.
-inline double wtf_pow(double x, double y) { return y == 0 ? 1 : pow(x, y); }
+extern "C" inline double wtf_pow(double x, double y) { return y == 0 ? 1 : pow(x, y); }
#define atan2(x, y) wtf_atan2(x, y)
#define fmod(x, y) wtf_fmod(x, y)
@@ -185,7 +199,7 @@ inline double wtf_pow(double x, double y)
{
// MinGW-w64 has a custom implementation for pow.
// This handles certain special cases that are different.
- if ((x == 0.0 || isinf(x)) && isfinite(y)) {
+ if ((x == 0.0 || std::isinf(x)) && std::isfinite(y)) {
double f;
if (modf(y, &f) != 0.0)
return ((x == 0.0) ^ (y > 0.0)) ? std::numeric_limits<double>::infinity() : 0.0;