summaryrefslogtreecommitdiffhomepage
path: root/opentrack-compat/nan.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'opentrack-compat/nan.cpp')
-rw-r--r--opentrack-compat/nan.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/opentrack-compat/nan.cpp b/opentrack-compat/nan.cpp
new file mode 100644
index 00000000..6c4b1f6d
--- /dev/null
+++ b/opentrack-compat/nan.cpp
@@ -0,0 +1,16 @@
+#include <cmath>
+
+#if defined(__GNUC__)
+extern "C" bool __attribute__ ((noinline)) nanp(double value)
+#elif defined(_WIN32)
+extern "C" __declspec(noinline) bool nanp(double value)
+#else
+extern "C" bool nanp(double value)
+#endif
+{
+ using std::isnan;
+ using std::isinf;
+
+ const volatile double x = value;
+ return isnan(x) || isinf(x);
+}