Fix __VERSIONER_NO_GUARD cases for availability.
libc++ still depends on these being declared even if they are
unavailable. This results in a worse error message (a link error
rather than a compiler diagnostic) if these functions end up being
used, but without the decl headers like libc++'s math.h can't be
included because it refers to an undeclared function.
For the cases where weak symbols aren't being used, don't annotate
these functions with their availability information.
Also need to avoid using __builtin_available for this case because the
NDK doesn't have __isOSVersionAtLeast yet.
__ANDROID_UNGUARDED_AVAILABILITY__ is being used as a proxy for
"building for the NDK" here because we don't have a good signal for
that which works for both the NDK proper and the NDK-in-the-platform
case.
Test: imported into the NDK, built and tested NDK
Bug: None
Change-Id: I9ef3e19a8fa083bca0be47b80dfef7ba52a94866
diff --git a/libc/include/android/legacy_signal_inlines.h b/libc/include/android/legacy_signal_inlines.h
index a673446..e968c45 100644
--- a/libc/include/android/legacy_signal_inlines.h
+++ b/libc/include/android/legacy_signal_inlines.h
@@ -45,14 +45,32 @@
int __libc_current_sigrtmin() __attribute__((__weak__)) __VERSIONER_NO_GUARD;
static __inline int __ndk_legacy___libc_current_sigrtmax() {
+ /*
+ * The NDK doesn't use libclang_rt.builtins yet (https://github.com/android/ndk/issues/1231) so it
+ * can't use __builtin_available, but the platform builds with -Werror=unguarded-availability so
+ * it requires __builtin_available.
+ */
+#if defined(__ANDROID_UNGUARDED_AVAILABILITY__)
if (__builtin_available(android 21, *)) {
+#else
+ if (__libc_current_sigrtmax) {
+#endif
return __libc_current_sigrtmax();
}
return __SIGRTMAX; /* Should match __libc_current_sigrtmax. */
}
static __inline int __ndk_legacy___libc_current_sigrtmin() {
+ /*
+ * The NDK doesn't use libclang_rt.builtins yet (https://github.com/android/ndk/issues/1231) so it
+ * can't use __builtin_available, but the platform builds with -Werror=unguarded-availability so
+ * it requires __builtin_available.
+ */
+#if defined(__ANDROID_UNGUARDED_AVAILABILITY__)
if (__builtin_available(android 21, *)) {
+#else
+ if (__libc_current_sigrtmin) {
+#endif
return __libc_current_sigrtmin();
}
return __SIGRTMIN + 7; /* Should match __libc_current_sigrtmin. */