More NDK fixes.
Fix variable names in port.h and fix fpclassify when
using gnustl. This was tested by switching to gnustl
in the JNI build.
Thanks to Carlos Hernandez for suggesting the gnustl fixes.
Change-Id: I690b73caf495ccc79061f45288e416da1604cc72
diff --git a/include/ceres/fpclassify.h b/include/ceres/fpclassify.h
index b730832..e7f0d7c 100644
--- a/include/ceres/fpclassify.h
+++ b/include/ceres/fpclassify.h
@@ -46,6 +46,7 @@
namespace ceres {
#if defined(_MSC_VER)
+
inline bool IsFinite (double x) { return _finite(x); }
inline bool IsInfinite(double x) { return !_finite(x) && !_isnan(x); }
inline bool IsNaN (double x) { return _isnan(x); }
@@ -54,17 +55,15 @@
return classification == _FPCLASS_NN ||
classification == _FPCLASS_PN;
}
-#elif defined(ANDROID)
-// On Android when using the GNU STL, the C++ fpclassify functions are not
-// available. Strictly speaking, the std functions are are not standard until
-// C++11. Instead use the C99 macros on Android.
+#elif defined(ANDROID) && defined(_STLPORT_VERSION)
+
+// On Android, when using the STLPort, the C++ isnan and isnormal functions
+// are defined as macros.
inline bool IsNaN (double x) { return isnan(x); }
inline bool IsNormal (double x) { return isnormal(x); }
-
// On Android NDK r6, when using STLPort, the isinf and isfinite functions are
// not available, so reimplement them.
-# if defined(_STLPORT_VERSION)
inline bool IsInfinite(double x) {
return x == std::numeric_limits<double>::infinity() ||
x == -std::numeric_limits<double>::infinity();
@@ -72,17 +71,15 @@
inline bool IsFinite(double x) {
return !isnan(x) && !IsInfinite(x);
}
-# else
-inline bool IsFinite (double x) { return isfinite(x); }
-inline bool IsInfinite(double x) { return isinf(x); }
-# endif // defined(_STLPORT_VERSION)
-#else
+
+# else
+
// These definitions are for the normal Unix suspects.
-// TODO(keir): Test the "else" with more platforms.
inline bool IsFinite (double x) { return std::isfinite(x); }
inline bool IsInfinite(double x) { return std::isinf(x); }
inline bool IsNaN (double x) { return std::isnan(x); }
inline bool IsNormal (double x) { return std::isnormal(x); }
+
#endif
} // namespace ceres
diff --git a/include/ceres/internal/port.h b/include/ceres/internal/port.h
index 4d0bbc0..13db149 100644
--- a/include/ceres/internal/port.h
+++ b/include/ceres/internal/port.h
@@ -33,7 +33,7 @@
#include <string>
-#if defined(CERES_TR1_SHARED_PTR)
+#if defined(CERES_SHARED_PTR_IN_TR1_NAMESPACE)
#include <tr1/memory>
#else
#include <memory>
@@ -51,7 +51,7 @@
// "string" implementation in the global namespace.
using std::string;
-#if defined(CERES_STD_SHARED_PTR_IN_TR1_NAMESPACE) || defined(SHARED_PTR_IN_TR1_NAMESPACE)
+#if defined(CERES_STD_SHARED_PTR_IN_TR1_NAMESPACE) || defined(CERES_SHARED_PTR_IN_TR1_NAMESPACE)
using std::tr1::shared_ptr;
#else
using std::shared_ptr;