Condition usage of locale stdlib functions on Android API version

Some *_l functions were not available in some versions of Bionic. This CL
checks that the NDK version supports the functions, and if not, falls back
on the corresponding functions that don't take a locale.

Patch by Tom Anderson!

Differential Revision: https://reviews.llvm.org/D46558

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@332543 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Collingbourne
2018-05-16 22:40:12 +00:00
parent 6c03a7a2b3
commit 85a7702b4c

View File

@@ -27,14 +27,14 @@ extern "C" {
#if defined(__ANDROID__) #if defined(__ANDROID__)
#include <android/api-level.h> #include <android/api-level.h>
#include <android/ndk-version.h>
// Android gained most locale aware functions in L (API level 21)
#if __ANDROID_API__ < 21
#include <support/xlocale/__posix_l_fallback.h> #include <support/xlocale/__posix_l_fallback.h>
#endif // In NDK versions later than 16, locale-aware functions are provided by
// legacy_stdlib_inlines.h
// The strto* family was added in O (API Level 26) #if __NDK_MAJOR__ <= 16
#if __ANDROID_API__ < 26 #if __ANDROID_API__ < 21
#include <support/xlocale/__strtonum_fallback.h>
#elif __ANDROID_API__ < 26
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
@@ -61,6 +61,7 @@ inline _LIBCPP_ALWAYS_INLINE long strtol_l(const char* __nptr, char** __endptr,
#endif // __ANDROID_API__ < 26 #endif // __ANDROID_API__ < 26
#endif // __NDK_MAJOR__ <= 16
#endif // defined(__ANDROID__) #endif // defined(__ANDROID__)
#endif // defined(__BIONIC__) #endif // defined(__BIONIC__)