Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Make unified headers' SIGRTMIN/SIGRTMAX usable before API 21.
Browse files Browse the repository at this point in the history
Bug: android/ndk#352
Test: built new NDK test
Change-Id: Iacebe574bbf693701949e038005a40ba6520d592
  • Loading branch information
enh-google committed Apr 26, 2017
1 parent 5deddda commit 7ba2bed
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libc/bionic/__libc_current_sigrtmax.cpp
Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions libc/bionic/__libc_current_sigrtmin.cpp
Expand Up @@ -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;
}
19 changes: 19 additions & 0 deletions libc/include/android/legacy_signal_inlines.h
Expand Up @@ -41,6 +41,25 @@ sighandler_t bsd_signal(int signum, sighandler_t handler) __REMOVED_IN(21);

#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;
Expand Down

0 comments on commit 7ba2bed

Please sign in to comment.