[libcxx] r332543 - Condition usage of locale stdlib functions on Android API version

Peter Collingbourne via cfe-commits cfe-commits at lists.llvm.org
Wed May 16 15:40:13 PDT 2018


Author: pcc
Date: Wed May 16 15:40:12 2018
New Revision: 332543

URL: http://llvm.org/viewvc/llvm-project?rev=332543&view=rev
Log:
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

Modified:
    libcxx/trunk/include/support/android/locale_bionic.h

Modified: libcxx/trunk/include/support/android/locale_bionic.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/android/locale_bionic.h?rev=332543&r1=332542&r2=332543&view=diff
==============================================================================
--- libcxx/trunk/include/support/android/locale_bionic.h (original)
+++ libcxx/trunk/include/support/android/locale_bionic.h Wed May 16 15:40:12 2018
@@ -27,14 +27,14 @@ extern "C" {
 #if defined(__ANDROID__)
 
 #include <android/api-level.h>
-
-// Android gained most locale aware functions in L (API level 21)
-#if __ANDROID_API__ < 21
+#include <android/ndk-version.h>
 #include <support/xlocale/__posix_l_fallback.h>
-#endif
-
-// The strto* family was added in O (API Level 26)
-#if __ANDROID_API__ < 26
+// In NDK versions later than 16, locale-aware functions are provided by
+// legacy_stdlib_inlines.h
+#if __NDK_MAJOR__ <= 16
+#if __ANDROID_API__ < 21
+#include <support/xlocale/__strtonum_fallback.h>
+#elif __ANDROID_API__ < 26
 
 #if defined(__cplusplus)
 extern "C" {
@@ -61,6 +61,7 @@ inline _LIBCPP_ALWAYS_INLINE long strtol
 
 #endif // __ANDROID_API__ < 26
 
+#endif // __NDK_MAJOR__ <= 16
 #endif // defined(__ANDROID__)
 
 #endif // defined(__BIONIC__)




More information about the cfe-commits mailing list