summaryrefslogtreecommitdiffhomepage
path: root/opentrack-compat/nan.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-07-19 07:08:03 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-07-19 07:38:37 +0200
commit0773f40c072bdf117fff9e7179849b65737e7491 (patch)
tree534d764580eb312ada0dea038a1632fac97c5e2a /opentrack-compat/nan.cpp
parent9296ed95961b846a13477581e2947b8be611b154 (diff)
move nan check to compat
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);
+}