Fix for fpclassify.h NDK porting work.

Change-Id: I69df1b4caf2941ed96a53e35e43ec54073f84f59
This commit is contained in:
Keir Mierle
2012-08-16 16:27:10 -07:00
parent 8ceb02cb75
commit f21bee2472
+16 -21
View File
@@ -53,34 +53,29 @@ inline bool IsNormal (double x) {
classification == _FPCLASS_PN;
}
#elif defined(ANDROID)
# if defined(_STLP_CMATH)
// On Android when using STLPort, the isinf and isfinite functions are not
// available, so reimplement them.
// 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.
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);
}
inline bool IsInfinite(double x) {
return x == std::numeric_limits<T>::infinity() ||
x == -std::numeric_limits<T>::infinity();
}
# else
inline bool IsFinite (double x) { return isfinite(x); }
inline bool IsInfinite(double x) { return isinf(x); }
# endif // defined(_STLP_CMATH)
inline bool IsNaN (double x) { return isnan(x); }
inline bool IsNormal (double x) { return isnormal(x); }
#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.
inline bool IsFinite (double x) { return isfinite(x); }
inline bool IsInfinite(double x) { return isinf(x); }
inline bool IsNaN (double x) { return isnan(x); }
inline bool IsNormal (double x) { return isnormal(x); }
# endif // defined(_STLPORT_VERSION)
#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); }