Make unified headers' SIGRTMIN/SIGRTMAX usable before API 21.
Bug: https://github.com/android-ndk/ndk/issues/352
Test: built new NDK test
Change-Id: Iacebe574bbf693701949e038005a40ba6520d592
diff --git a/libc/bionic/__libc_current_sigrtmax.cpp b/libc/bionic/__libc_current_sigrtmax.cpp
index 27fcb35..32179bb 100644
--- a/libc/bionic/__libc_current_sigrtmax.cpp
+++ b/libc/bionic/__libc_current_sigrtmax.cpp
@@ -29,5 +29,7 @@
#include <signal.h>
int __libc_current_sigrtmax(void) {
+ // If you change this, also change __ndk_legacy___libc_current_sigrtmax
+ // in <android/legacy_signal_inlines.h> to match.
return __SIGRTMAX;
}
diff --git a/libc/bionic/__libc_current_sigrtmin.cpp b/libc/bionic/__libc_current_sigrtmin.cpp
index 7c93267..f3b2bf6 100644
--- a/libc/bionic/__libc_current_sigrtmin.cpp
+++ b/libc/bionic/__libc_current_sigrtmin.cpp
@@ -34,5 +34,7 @@
// __SIGRTMIN + 3 is reserved for triggering native stack dumps.
int __libc_current_sigrtmin(void) {
+ // If you change this, also change __ndk_legacy___libc_current_sigrtmin
+ // in <android/legacy_signal_inlines.h> to match.
return __SIGRTMIN + 4;
}
diff --git a/libc/include/android/legacy_signal_inlines.h b/libc/include/android/legacy_signal_inlines.h
index afdaca8..a5d3a6f 100644
--- a/libc/include/android/legacy_signal_inlines.h
+++ b/libc/include/android/legacy_signal_inlines.h
@@ -41,6 +41,25 @@
#if __ANDROID_API__ < __ANDROID_API_L__
+/* These weren't introduced until L. */
+int __libc_current_sigrtmax() __attribute__((__weak__)) __VERSIONER_NO_GUARD;
+int __libc_current_sigrtmin() __attribute__((__weak__)) __VERSIONER_NO_GUARD;
+
+static __inline int __ndk_legacy___libc_current_sigrtmax() {
+ if (__libc_current_sigrtmax) return __libc_current_sigrtmax();
+ return __SIGRTMAX; /* Should match __libc_current_sigrtmax. */
+}
+
+static __inline int __ndk_legacy___libc_current_sigrtmin() {
+ if (__libc_current_sigrtmin) return __libc_current_sigrtmin();
+ return __SIGRTMIN + 4; /* Should match __libc_current_sigrtmin. */
+}
+
+#undef SIGRTMAX
+#define SIGRTMAX __ndk_legacy___libc_current_sigrtmax()
+#undef SIGRTMIN
+#define SIGRTMIN __ndk_legacy___libc_current_sigrtmin()
+
static __inline int sigismember(const sigset_t *set, int signum) {
/* Signal numbers start at 1, but bit positions start at 0. */
int bit = signum - 1;