From 2569076ff0bf8ffb3938da8b5df7edc4883aa053 Mon Sep 17 00:00:00 2001 From: Sameer Agarwal Date: Fri, 25 Apr 2014 23:54:48 -0700 Subject: [PATCH] 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 --- include/ceres/fpclassify.h | 21 +++++++++------------ include/ceres/internal/port.h | 4 ++-- 2 files changed, 11 insertions(+), 14 deletions(-) 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 @@ inline bool IsNormal (double x) { 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::infinity() || x == -std::numeric_limits::infinity(); @@ -72,17 +71,15 @@ inline bool IsInfinite(double x) { 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 -#if defined(CERES_TR1_SHARED_PTR) +#if defined(CERES_SHARED_PTR_IN_TR1_NAMESPACE) #include #else #include @@ -51,7 +51,7 @@ using namespace std; // "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;