summaryrefslogtreecommitdiffhomepage
path: root/opentrack/nan.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-06-14 11:43:06 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-06-14 18:14:46 +0200
commitdcef445e694c6e2b65d7f1fd0462f4ceacdaff3c (patch)
treec5dfd614298c66718c8f54fc47c315025b8e1cb8 /opentrack/nan.cpp
parentf9e4a82ac414bf60e817b48ac8443a00c83b2f1e (diff)
api: add nan checking function
Diffstat (limited to 'opentrack/nan.cpp')
-rw-r--r--opentrack/nan.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/opentrack/nan.cpp b/opentrack/nan.cpp
new file mode 100644
index 00000000..2522ba38
--- /dev/null
+++ b/opentrack/nan.cpp
@@ -0,0 +1,16 @@
+#include <cmath>
+
+#if defined(__GNUC__)
+bool __attribute__ ((noinline)) nanp(double value)
+#elif defined(_WIN32)
+__declspec(noinline) bool nanp(double value)
+#else
+bool nanp(double value)
+#endif
+{
+ using std::isnan;
+ using std::isinf;
+
+ const volatile double x = value;
+ return isnan(x) || isinf(x);
+} \ No newline at end of file