summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-10-20 19:18:29 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-10-20 19:18:29 +0200
commite8f213c2a89e069f5a1125a38094f399a4416e12 (patch)
treeaa05e72d81e7d9d45c8117963b013f57cf9b386a /compat
parentf505be196fd26f4a063360adf244c8928a3d0f0e (diff)
compat/nan: fix isnan in presence of -ffast-math
The trick prevents GCC isnan builtin from getting called.
Diffstat (limited to 'compat')
-rw-r--r--compat/nan.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/compat/nan.cpp b/compat/nan.cpp
index 899b907a..a7b37362 100644
--- a/compat/nan.cpp
+++ b/compat/nan.cpp
@@ -1,17 +1,16 @@
-#include <cmath>
#include "export.hpp"
-#if defined(__GNUC__)
-extern "C" OPENTRACK_COMPAT_EXPORT bool __attribute__ ((noinline)) nanp(double value)
-#elif defined(_WIN32)
-extern "C" OPENTRACK_COMPAT_EXPORT __declspec(noinline) bool nanp(double value)
+#if defined(_MSC_VER)
+# include <cmath>
+# define my_isnan std::isnan
+# define my_isinf std::isinf
+extern "C" OPENTRACK_COMPAT_EXPORT __declspec(noinline) bool nanp(double x)
#else
-extern "C" OPENTRACK_COMPAT_EXPORT bool nanp(double value)
+int my_isnan(double)__asm__("isnan");
+int my_isinf(double)__asm__("isinf");
+
+extern "C" OPENTRACK_COMPAT_EXPORT bool __attribute__ ((noinline)) nanp(double x)
#endif
{
- using std::isnan;
- using std::isinf;
-
- const volatile double x = value;
- return isnan(x) || isinf(x);
+ return my_isnan(x) || my_isinf(x);
}