summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Prichard <rprichard@google.com>2021-03-22 13:27:17 -0700
committerDan Albert <danalbert@google.com>2021-03-29 20:24:56 -0700
commit913ecbd45a64d0887402cdfae5d7c4d8a0e2e70b (patch)
tree73f8e56241678e3b0d598adfa0366d8413936e4a
parent3f51a8af5408569e74dc2c1a181bd723126a8611 (diff)
downloadndk-913ecbd45a64d0887402cdfae5d7c4d8a0e2e70b.tar.gz
Reapply: Hack libc++ support header to work in the platform.
Previously applied to r21: https://android-review.googlesource.com/c/platform/prebuilts/ndk/+/1363327/ The upstream LLVM file changed a bit in the meantime: https://reviews.llvm.org/D69983 Test: treehugger Bug: none Change-Id: I3e1fac6653da925b41e60d4af015a19f2c52c2de
-rw-r--r--r23/sources/cxx-stl/llvm-libc++/include/support/android/locale_bionic.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/r23/sources/cxx-stl/llvm-libc++/include/support/android/locale_bionic.h b/r23/sources/cxx-stl/llvm-libc++/include/support/android/locale_bionic.h
index f05a6a052..dd1c088f4 100644
--- a/r23/sources/cxx-stl/llvm-libc++/include/support/android/locale_bionic.h
+++ b/r23/sources/cxx-stl/llvm-libc++/include/support/android/locale_bionic.h
@@ -25,11 +25,22 @@ 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
+
+// HACK: Not in upstream NDK or libc++.
+// Upstream now supports using ToT libc++ with old NDKs, but as such it is now
+// *only* compatible with the NDK. That will need to be fixed both for the
+// platorm and for the NDK-in-platform use case since neither has
+// android/ndk-version.h.
+
+// 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/api-level.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 +74,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__)