]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Common header file change: lib/include/vm_basic_math.h
authorOliver Kurth <okurth@vmware.com>
Fri, 23 Mar 2018 22:05:36 +0000 (15:05 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 23 Mar 2018 22:05:36 +0000 (15:05 -0700)
Define portability macros for Inf and Nan tests.

open-vm-tools/lib/include/vm_basic_math.h

index 065ba368fadd254096fbb696fc1f0af75e57c82c..5dfa85b318fcef3a72af90e21a60b0e45f4e0dcd 100644 (file)
@@ -108,6 +108,38 @@ GetPowerOfTwo(uint32 x)
 }
 
 
+/*
+ *----------------------------------------------------------------------
+ *
+ * IsFinite --
+ * IsInf --
+ * IsNan --
+ *
+ *    Portability macros that test floats against -/+Inf and NaN.
+ *
+ *----------------------------------------------------------------------
+ */
+
+#ifdef _WIN32
+#include <float.h>
+
+#define IsFinite(x) _finite(x)
+#define IsNan(x)    _isnan(x)
+
+static INLINE Bool
+IsInf(double x)
+{
+   return !_finite(x) && !_isnan(x);
+}
+#else
+#include <math.h>
+
+#define IsFinite(x) isfinite(x)
+#define IsInf(x)    isinf(x)
+#define IsNan(x)    isnan(x)
+#endif
+
+
 #if !defined(_WIN32) && !defined(_WIN64)
 /*
  *-----------------------------------------------------------------------------