[geos-commits] r2854 - in trunk/include/geos: . util

svn_geos at osgeo.org svn_geos at osgeo.org
Sat Jan 16 15:12:23 EST 2010


Author: mloskot
Date: 2010-01-16 15:12:23 -0500 (Sat, 16 Jan 2010)
New Revision: 2854

Modified:
   trunk/include/geos/platform.h.in
   trunk/include/geos/util/math.h
Log:
Unified detection of math features to define FINITE and ISNAN macros

Modified: trunk/include/geos/platform.h.in
===================================================================
--- trunk/include/geos/platform.h.in	2010-01-16 18:14:41 UTC (rev 2853)
+++ trunk/include/geos/platform.h.in	2010-01-16 20:12:23 UTC (rev 2854)
@@ -45,7 +45,6 @@
 #include <float.h>
 #endif
 
-#include <cmath> // for finite()/isfinite() and isnan()
 #include <limits> // for std::numeric_limits
 
 
@@ -59,28 +58,6 @@
 
 #define DoubleMax std::numeric_limits<double>::max()
 
-inline bool
-isFinite(double d)
-{
-#if defined(HAVE_FINITE) && !defined(HAVE_ISFINITE) && !defined(__MINGW32__)
-    return (finite(d));
-#else
-    // Put using namespace std; here if you have to
-    // put it anywhere.
-    using namespace std;
-    return (isfinite(d));
-#endif
-}
-#define FINITE(x) ( isFinite(x) ) 
-
-#ifdef HAVE_ISNAN
-#define ISNAN(x) ( isnan(x) )
-#else
-// 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
-
 #ifdef HAVE_INT64_T_64
   typedef int64_t int64;
 #else
@@ -95,4 +72,35 @@
 # endif
 #endif
 
+
+#if defined(HAVE_FINITE) && !defined(HAVE_ISFINITE)
+# define FINITE(x) (finite(x))
+#else
+# if defined(_MSC_VER)
+#  define FINITE(x) _finite(static_cast<double>(x))    
+# else
+#  define FINITE(x) (isfinite(x))
+# endif
 #endif
+
+#if defined(HAVE_ISNAN)
+# define ISNAN(x) (isnan(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
+#endif
+
+#ifndef FINITE
+#error "Can not compile without finite or isfinite function or macro"
+#endif
+
+#ifndef ISNAN
+#error "Can not compile without isnan function or macro"
+#endif
+
+#endif

Modified: trunk/include/geos/util/math.h
===================================================================
--- trunk/include/geos/util/math.h	2010-01-16 18:14:41 UTC (rev 2853)
+++ trunk/include/geos/util/math.h	2010-01-16 20:12:23 UTC (rev 2854)
@@ -17,8 +17,7 @@
 #ifndef GEOS_UTIL_MATH_H
 #define GEOS_UTIL_MATH_H
 
-namespace geos {
-namespace util { // geos::util
+namespace geos { namespace util {
 
 /// Symmetric Rounding Algorithm
 double sym_round(double val);
@@ -30,18 +29,16 @@
 double rint_vc(double val);
 
 /// Default rounding method for GEOS
-//
-/// Always use this rounding method, to easy
-/// easy switching between different rounding
-/// method for the whole codebase
-inline double round(double val) {
+///
+/// @note Always use this rounding method, to easy easy switching
+/// between different rounding method for the whole codebase.
+inline double round(double val)
+{
 	return java_math_round(val);
 }
 
-} // namespace geos.util
-} // namespace geos
+}} // namespace geos::util
 
-
 #endif // GEOS_UTIL_MATH_H
 
 /**********************************************************************



More information about the geos-commits mailing list