[libcxx-commits] [libcxx] 2d0475e - [libcxx] locale_bionic.h: skip ndk-version.h on Android platform

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 11 10:57:04 PDT 2022


Author: zijunzhao
Date: 2022-04-11T17:51:12Z
New Revision: 2d0475e37169bee3d969c4e4b445e86c08539769

URL: https://github.com/llvm/llvm-project/commit/2d0475e37169bee3d969c4e4b445e86c08539769
DIFF: https://github.com/llvm/llvm-project/commit/2d0475e37169bee3d969c4e4b445e86c08539769.diff

LOG: [libcxx] locale_bionic.h: skip ndk-version.h on Android platform

The Android platform does not have ndk-version.h, but it will always
have up-to-date libc headers, so it does not need any compatibility
code intended for past versions of NDK_MAJOR. If ndk-version.h is missing,
assume NDK_MAJOR is (conceptually) infinite

Bug: https://buganizer.corp.google.com/issues/222341313
Test: None

Added: 
    

Modified: 
    libcxx/include/__support/android/locale_bionic.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__support/android/locale_bionic.h b/libcxx/include/__support/android/locale_bionic.h
index 8c6d4bd0dc322..535bad7856480 100644
--- a/libcxx/include/__support/android/locale_bionic.h
+++ b/libcxx/include/__support/android/locale_bionic.h
@@ -26,10 +26,15 @@ extern "C" {
 #if defined(__ANDROID__)
 
 #include <android/api-level.h>
-#include <android/ndk-version.h>
 #if __ANDROID_API__ < 21
 #include <__support/xlocale/__posix_l_fallback.h>
 #endif
+
+// If we do not have this header, we are in a platform build rather than an NDK
+// build, which will always be at least as new as the ToT NDK, in which case we
+// don't need any of the inlines below since libc provides them.
+#if __has_include(<android/ndk-version.h>)
+#include <android/ndk-version.h>
 // In NDK versions later than 16, locale-aware functions are provided by
 // legacy_stdlib_inlines.h
 #if __NDK_MAJOR__ <= 16
@@ -63,6 +68,7 @@ inline _LIBCPP_INLINE_VISIBILITY long strtol_l(const char* __nptr, char** __endp
 #endif // __ANDROID_API__ < 26
 
 #endif // __NDK_MAJOR__ <= 16
+#endif // __has_include(<android/ndk-version.h>)
 #endif // defined(__ANDROID__)
 
 #endif // defined(__BIONIC__)


        


More information about the libcxx-commits mailing list