Skip to content
This repository has been archived by the owner on Oct 26, 2018. It is now read-only.

Commit

Permalink
More NDK fixes.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sandwichmaker committed Apr 26, 2014
1 parent e55596f commit 2569076
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
21 changes: 9 additions & 12 deletions include/ceres/fpclassify.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand All @@ -54,35 +55,31 @@ 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<double>::infinity() ||
x == -std::numeric_limits<double>::infinity();
}
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
Expand Down
4 changes: 2 additions & 2 deletions include/ceres/internal/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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;
Expand Down

0 comments on commit 2569076

Please sign in to comment.