summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Liu <net147@gmail.com>2013-01-09 19:28:56 +1100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-09 12:19:11 +0100
commit2b77c30e246a7452a68999b47b9eaf10f6cafd2f (patch)
treed5146ca5ca8381b8e52f82341a8cf716fa266ede
parent4bffdf96b1418b011757bd1a7e8b6b109819a8fe (diff)
downloadqtscript-2b77c30e246a7452a68999b47b9eaf10f6cafd2f.tar.gz
Fix Math.pow implementation with MinGW-w64
Adapted from WebKit changes 137895, 138705, 138894 and 138903. Change-Id: I166f8837e898d17d71ce4e4cab8ab45ea49de39c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h
index a18949e..fc5676a 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h
@@ -27,6 +27,7 @@
#define WTF_MathExtras_h
#include <float.h>
+#include <limits>
#include <math.h>
#include <stdlib.h>
@@ -39,13 +40,6 @@
#include <machine/ieee.h>
#endif
-#if COMPILER(MSVC)
-#if OS(WINCE)
-#include <stdlib.h>
-#endif
-#include <limits>
-#endif
-
#ifndef M_PI
const double piDouble = 3.14159265358979323846;
const float piFloat = 3.14159265358979323846f;
@@ -186,4 +180,26 @@ inline float deg2turn(float d) { return d / 360.0f; }
inline float rad2grad(float r) { return r * 200.0f / piFloat; }
inline float grad2rad(float g) { return g * piFloat / 200.0f; }
+#if COMPILER(MINGW64) && (!defined(__MINGW64_VERSION_RC) || __MINGW64_VERSION_RC < 1)
+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)) {
+ double f;
+ if (modf(y, &f) != 0.0)
+ return ((x == 0.0) ^ (y > 0.0)) ? std::numeric_limits<double>::infinity() : 0.0;
+ }
+
+ if (x == 2.0) {
+ int yInt = static_cast<int>(y);
+ if (y == yInt)
+ return ldexp(1.0, yInt);
+ }
+
+ return pow(x, y);
+}
+#define pow(x, y) wtf_pow(x, y)
+#endif // COMPILER(MINGW64) && (!defined(__MINGW64_VERSION_RC) || __MINGW64_VERSION_RC < 1)
+
#endif // #ifndef WTF_MathExtras_h