]> granicus.if.org Git - json-c/commitdiff
Define INFINITY and NAN when missing
authorJames Myatt <james.myatt@tessella.com>
Thu, 5 Feb 2015 15:56:49 +0000 (15:56 +0000)
committerJames Myatt <james.myatt@tessella.com>
Wed, 4 Mar 2015 10:45:34 +0000 (10:45 +0000)
math_compat.h

index f40b8faf8fd4202e859cf43d1b3daaaccdba7c0d..baf3eb90efa0295172971d86b1d5d018393e3d93 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __math_compat_h
 #define __math_compat_h
 
-/* Define isnan and isinf on Windows/MSVC */
+/* Define isnan, isinf, infinity and nan on Windows/MSVC */
 
 #ifndef HAVE_DECL_ISNAN
 # ifdef HAVE_DECL__ISNAN
 # endif
 #endif
 
-#ifndef HAVE_DECL_NAN
-#error This platform does not have nan()
+#ifndef HAVE_DECL_INFINITY
+#include <float.h>
+#define INFINITY (DBL_MAX + DBL_MAX)
+#define HAVE_DECL_INFINITY
 #endif
 
-#ifndef HAVE_DECL_INFINITY
-#error This platform does not have INFINITY
+#ifndef HAVE_DECL_NAN
+#define NAN (INFINITY - INFINITY)
+#define HAVE_DECL_NAN
 #endif
 
 #endif