[geos-commits] r2860 - in trunk: . include/geos

svn_geos at osgeo.org svn_geos at osgeo.org
Sat Jan 16 19:46:47 EST 2010


Author: mloskot
Date: 2010-01-16 19:46:45 -0500 (Sat, 16 Jan 2010)
New Revision: 2860

Modified:
   trunk/CMakeLists.txt
   trunk/include/geos/platform.h.cmake
Log:
Refined detection of isnan and isfinite features (#317)

Modified: trunk/CMakeLists.txt
===================================================================
--- trunk/CMakeLists.txt	2010-01-16 22:20:03 UTC (rev 2859)
+++ trunk/CMakeLists.txt	2010-01-17 00:46:45 UTC (rev 2860)
@@ -57,6 +57,7 @@
 
 # check header files
 include(CheckIncludeFiles)
+
 check_include_files(stdint.h HAVE_STDINT_H)
 check_include_files(inttypes.h HAVE_INTTYPES_H)
 check_include_files(ieeefp.h HAVE_IEEEFP_H)
@@ -64,7 +65,6 @@
 # check types and sizes
 include(CheckTypeSize)
 
-
 if(MSVC)
   check_type_size("__int64" HAVE_INT64_T_64)
 else()
@@ -75,6 +75,33 @@
   endif()
 endif()
 
+# check functions and macros
+include(CheckSymbolExists)
+include(CheckFunctionExists)
+
+check_symbol_exists(std::isnan cmath HAVE_STD_ISNAN)
+if(NOT HAVE_STD_ISNAN)
+  if(MSVC)
+    check_symbol_exists(_isnan float.h HAVE_ISNAN)
+  elseif(APPLE)
+    check_symbol_exists(__isnand math.h HAVE_ISNAND_XCODE)
+    if(NOT HAVE_ISNAND_XCODE)
+      check_symbol_exists(__inline_isnand math.h HAVE_INLINE_ISNAND_XCODE)
+    endif()
+  else()
+    check_symbol_exists(isnan math.h HAVE_ISNAN)
+  endif()
+endif()
+
+check_symbol_exists(std::isfinite cmath HAVE_STD_ISFINITE)
+if(NOT HAVE_STD_ISFINITE)
+  if(MSVC)
+    check_symbol_exists(_finite float.h HAVE_FINITE)
+  else()
+    check_symbol_exists(isfinite math.h HAVE_ISFINITE)
+  endif()
+endif()
+
 ################################################################################
 # Setup include directories
 #################################################################################

Modified: trunk/include/geos/platform.h.cmake
===================================================================
--- trunk/include/geos/platform.h.cmake	2010-01-16 22:20:03 UTC (rev 2859)
+++ trunk/include/geos/platform.h.cmake	2010-01-17 00:46:45 UTC (rev 2860)
@@ -17,6 +17,18 @@
  *
  *********************************************************************/
 
+#ifndef GEOS_PLATFORM_H_INCLUDED
+#define GEOS_PLATFORM_H_INCLUDED
+
+/* Set to 1 if you have stdint.h */
+#cmakedefine HAVE_STDINT_H 1
+
+/* Set to 1 if you have inttypes.h */
+#cmakedefine HAVE_INTTYPES_H 1
+
+/* Set to 1 if you have ieeefp.h */
+#cmakedefine HAVE_IEEEFP_H 1
+
 /* Set to 1 if you have `int64_t' type */
 #cmakedefine HAVE_INT64_T_64 1
 
@@ -26,23 +38,26 @@
 /* Set to 1 if `long long int' is 64 bits */
 #cmakedefine HAVE_LONG_LONG_INT_64 1
 
-/* Set to 1 if you have stdint.h */
-#cmakedefine HAVE_STDINT_H 1
+/* Set to 1 if C++/C99 std::isnan is defined */
+#cmakedefine HAVE_STD_ISNAN 1
 
-/* Set to 1 if you have inttypes.h */
-#cmakedefine HAVE_INTTYPES_H 1
+/* Set to 1 if C99 isnan is defined */
+#cmakedefine HAVE_ISNAN 1
 
-/* Set to 1 if you have ieeefp.h */
-#cmakedefine HAVE_IEEEFP_H 1
+/* Set to 1 if XCode __isnand is defined */
+#cmakedefine HAVE_ISNAND_XCODE 1
 
-/* Has finite */
-#cmakedefine HAVE_FINITE 1
+/* Set to 1 if XCode __inline_isnand is defined */
+#cmakedefine HAVE_INLINE_ISNAND_XCODE 1
 
-/* Has isfinite */
+/* Set to 1 if C++/C99 std::isfinite is defined */
+#cmakedefine HAVE_STD_ISFINITE 1
+
+/* Set to 1 if C99 isfinite is defined */
 #cmakedefine HAVE_ISFINITE 1
 
-/* Has isnan */
-#cmakedefine HAVE_ISNAN 1
+/* Set to 1 if Visual C++ finite is defined */
+#cmakedefine HAVE_FINITE 1
 
 
 #ifdef HAVE_IEEEFP_H
@@ -84,14 +99,6 @@
 #include <float.h>
 #endif
 
-/* For Visual C++, required to find _isnan and _finite */
-#ifdef _MSC_VER
-#include <float.h>
-#endif
-
-#include <cmath> // trying C++0x finite, isfinite, isnan
-#include <limits>
-
 #ifdef HAVE_INT64_T_64
 # ifdef _MSC_VER
    typedef __int64 int64;
@@ -110,36 +117,42 @@
 # endif
 #endif
 
-#if defined(HAVE_FINITE) && !defined(HAVE_ISFINITE)
-# define FINITE(x) (finite(x))
-#else
+#if defined(HAVE_STD_ISNAN)
+# include <cmath>
+# define ISNAN(x) (std::isnan)(x)
+#elif defined(HAVE_INLINE_ISNAND_XCODE)
+# include <math.h>
+# define ISNAN(x) __inline_isnand(static_cast<double>(x))
+#elif defined(HAVE_ISNAND_XCODE)
+# include <math.h>
+# define ISNAN(x) __isnand(static_cast<double>(x))
+#elif defined(HAVE_ISNAN)
 # if defined(_MSC_VER)
-#  define FINITE(x) _finite(static_cast<double>(x))    
+#  include <float.h>
+#  define ISNAN(x) _isnan(static_cast<double>(x))
 # else
-#  define FINITE(x) (isfinite(x))
+#  include <math.h>
+#  define ISNAN(x) isnan(x)
 # endif
+#else
+# error "Could not find isnan function or macro!"
 #endif
 
-#if defined(HAVE_ISNAN)
-# define ISNAN(x) (isnan(x))
+#if defined(HAVE_STD_ISFINITE)
+# include <cmath>
+# define FINITE(x) (std::isfinite)(x)
+#elif defined(HAVE_ISFINITE)
+# include <math.h>
+# define FINITE(x) isfinite(x)
+#elif defined(HAVE_FINITE)
+# include <float.h>
+# define FINITE(x) _finite(static_cast<double>(x))
 #else
-# if defined(_MSC_VER)
-#  define ISNAN(x) _isnan(x)
-# elif defined(__OSX__)
-   // Hack for OS/X <cmath> incorrectly re-defining isnan() into oblivion.
-   // It does leave a version in std.
-#  define ISNAN(x) (std::isnan(x))
-# endif
+# error "Could not find finite or isfinite function or macro!"
 #endif
 
-#ifndef FINITE
-#error "Could not find finite or isfinite function or macro!"
-#endif
 
-#ifndef ISNAN
-#error "Could not find isnan function or macro!"
-#endif
-
+#include <limits>
 #define DoubleNegInfinity -std::numeric_limits<double>::infinity()
 #define DoubleMax std::numeric_limits<double>::max()
 // Defines NaN for Intel platforms
@@ -147,4 +160,4 @@
 // Don't forget to define infinities
 #define DoubleInfinity std::numeric_limits<double>::infinity()
 
-#endif
\ No newline at end of file
+#endif // GEOS_PLATFORM_H_INCLUDED



More information about the geos-commits mailing list