am 01dc4152: am 4a41581a: am 9fb53dd4: Merge "Make SIGRTMIN hide the real-time signals we use internally."
* commit '01dc4152b736c822a11cbbff3240eec7143659e3': Make SIGRTMIN hide the real-time signals we use internally.
This commit is contained in:
commit
fc4d9263a3
@ -129,6 +129,8 @@ libc_bionic_src_files := \
|
|||||||
bionic/inotify_init.cpp \
|
bionic/inotify_init.cpp \
|
||||||
bionic/lchown.cpp \
|
bionic/lchown.cpp \
|
||||||
bionic/lfs64_support.cpp \
|
bionic/lfs64_support.cpp \
|
||||||
|
bionic/__libc_current_sigrtmax.cpp \
|
||||||
|
bionic/__libc_current_sigrtmin.cpp \
|
||||||
bionic/libc_init_common.cpp \
|
bionic/libc_init_common.cpp \
|
||||||
bionic/libc_logging.cpp \
|
bionic/libc_logging.cpp \
|
||||||
bionic/libgen.cpp \
|
bionic/libgen.cpp \
|
||||||
|
33
libc/bionic/__libc_current_sigrtmax.cpp
Normal file
33
libc/bionic/__libc_current_sigrtmax.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 The Android Open Source Project
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
int __libc_current_sigrtmax(void) {
|
||||||
|
return __SIGRTMAX;
|
||||||
|
}
|
37
libc/bionic/__libc_current_sigrtmin.cpp
Normal file
37
libc/bionic/__libc_current_sigrtmin.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 The Android Open Source Project
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
// POSIX timers use __SIGRTMIN + 0.
|
||||||
|
// libbacktrace uses __SIGRTMIN + 1.
|
||||||
|
// libcore uses __SIGRTMIN + 2.
|
||||||
|
|
||||||
|
int __libc_current_sigrtmin(void) {
|
||||||
|
return __SIGRTMIN + 3;
|
||||||
|
}
|
@ -52,7 +52,7 @@ extern "C" int __timer_settime(__kernel_timer_t, int, const itimerspec*, itimers
|
|||||||
// end up with one of our POSIX timer threads handling it (meaning that the intended recipient
|
// end up with one of our POSIX timer threads handling it (meaning that the intended recipient
|
||||||
// doesn't). glibc uses SIGRTMIN for its POSIX timer implementation, so in the absence of any
|
// doesn't). glibc uses SIGRTMIN for its POSIX timer implementation, so in the absence of any
|
||||||
// reason to use anything else, we use that too.
|
// reason to use anything else, we use that too.
|
||||||
static const int TIMER_SIGNAL = SIGRTMIN;
|
static const int TIMER_SIGNAL = (__SIGRTMIN + 0);
|
||||||
|
|
||||||
struct PosixTimer {
|
struct PosixTimer {
|
||||||
__kernel_timer_t kernel_timer_id;
|
__kernel_timer_t kernel_timer_id;
|
||||||
|
@ -60,6 +60,12 @@ typedef int sig_atomic_t;
|
|||||||
#define _NSIG (_KERNEL__NSIG + 1)
|
#define _NSIG (_KERNEL__NSIG + 1)
|
||||||
#define NSIG _NSIG
|
#define NSIG _NSIG
|
||||||
|
|
||||||
|
/* We take a few real-time signals for ourselves. May as well use the same names as glibc. */
|
||||||
|
#define SIGRTMIN (__libc_current_sigrtmin())
|
||||||
|
#define SIGRTMAX (__libc_current_sigrtmax())
|
||||||
|
extern int __libc_current_sigrtmin(void);
|
||||||
|
extern int __libc_current_sigrtmax(void);
|
||||||
|
|
||||||
extern const char* const sys_siglist[];
|
extern const char* const sys_siglist[];
|
||||||
extern const char* const sys_signame[]; /* BSD compatibility. */
|
extern const char* const sys_signame[]; /* BSD compatibility. */
|
||||||
|
|
||||||
|
@ -63,6 +63,9 @@ kernel_token_replacements = {
|
|||||||
# The kernel's _NSIG/NSIG are one less than the userspace value, so we need to move them aside.
|
# The kernel's _NSIG/NSIG are one less than the userspace value, so we need to move them aside.
|
||||||
"_NSIG": "_KERNEL__NSIG",
|
"_NSIG": "_KERNEL__NSIG",
|
||||||
"NSIG": "_KERNEL_NSIG",
|
"NSIG": "_KERNEL_NSIG",
|
||||||
|
# The kernel's SIGRTMIN/SIGRTMAX are absolute limits; userspace steals a few.
|
||||||
|
"SIGRTMIN": "__SIGRTMIN",
|
||||||
|
"SIGRTMAX": "__SIGRTMAX",
|
||||||
}
|
}
|
||||||
|
|
||||||
# this is the set of known static inline functions that we want to keep
|
# this is the set of known static inline functions that we want to keep
|
||||||
|
@ -66,8 +66,8 @@ typedef unsigned long sigset_t;
|
|||||||
#define SIGSYS 31
|
#define SIGSYS 31
|
||||||
#define SIGUNUSED 31
|
#define SIGUNUSED 31
|
||||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
#define SIGRTMIN 32
|
#define __SIGRTMIN 32
|
||||||
#define SIGRTMAX _KERNEL__NSIG
|
#define __SIGRTMAX _KERNEL__NSIG
|
||||||
#define SIGSWI 32
|
#define SIGSWI 32
|
||||||
#define SA_NOCLDSTOP 0x00000001
|
#define SA_NOCLDSTOP 0x00000001
|
||||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
@ -66,9 +66,9 @@
|
|||||||
#define SIGSYS 31
|
#define SIGSYS 31
|
||||||
#define SIGUNUSED 31
|
#define SIGUNUSED 31
|
||||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
#define SIGRTMIN 32
|
#define __SIGRTMIN 32
|
||||||
#ifndef SIGRTMAX
|
#ifndef SIGRTMAX
|
||||||
#define SIGRTMAX _KERNEL__NSIG
|
#define __SIGRTMAX _KERNEL__NSIG
|
||||||
#endif
|
#endif
|
||||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
#define SA_NOCLDSTOP 0x00000001
|
#define SA_NOCLDSTOP 0x00000001
|
||||||
|
@ -71,8 +71,8 @@ typedef unsigned long old_sigset_t;
|
|||||||
#define SIGXCPU 30
|
#define SIGXCPU 30
|
||||||
#define SIGXFSZ 31
|
#define SIGXFSZ 31
|
||||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
#define SIGRTMIN 32
|
#define __SIGRTMIN 32
|
||||||
#define SIGRTMAX _KERNEL__NSIG
|
#define __SIGRTMAX _KERNEL__NSIG
|
||||||
#define SA_ONSTACK 0x08000000
|
#define SA_ONSTACK 0x08000000
|
||||||
#define SA_RESETHAND 0x80000000
|
#define SA_RESETHAND 0x80000000
|
||||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
@ -71,8 +71,8 @@ typedef unsigned long sigset_t;
|
|||||||
#define SIGSYS 31
|
#define SIGSYS 31
|
||||||
#define SIGUNUSED 31
|
#define SIGUNUSED 31
|
||||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
#define SIGRTMIN 32
|
#define __SIGRTMIN 32
|
||||||
#define SIGRTMAX _KERNEL__NSIG
|
#define __SIGRTMAX _KERNEL__NSIG
|
||||||
#define SA_NOCLDSTOP 0x00000001u
|
#define SA_NOCLDSTOP 0x00000001u
|
||||||
#define SA_NOCLDWAIT 0x00000002u
|
#define SA_NOCLDWAIT 0x00000002u
|
||||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
@ -252,3 +252,21 @@ TEST(signal, sys_siglist) {
|
|||||||
ASSERT_TRUE(sys_siglist[0] == NULL);
|
ASSERT_TRUE(sys_siglist[0] == NULL);
|
||||||
ASSERT_STREQ("Hangup", sys_siglist[SIGHUP]);
|
ASSERT_STREQ("Hangup", sys_siglist[SIGHUP]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(signal, limits) {
|
||||||
|
// This comes from the kernel.
|
||||||
|
ASSERT_EQ(32, __SIGRTMIN);
|
||||||
|
|
||||||
|
// We reserve a non-zero number at the bottom for ourselves.
|
||||||
|
ASSERT_GT(SIGRTMIN, __SIGRTMIN);
|
||||||
|
|
||||||
|
// MIPS has more signals than everyone else.
|
||||||
|
#if defined(__mips__)
|
||||||
|
ASSERT_EQ(128, __SIGRTMAX);
|
||||||
|
#else
|
||||||
|
ASSERT_EQ(64, __SIGRTMAX);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// We don't currently reserve any at the top.
|
||||||
|
ASSERT_EQ(SIGRTMAX, __SIGRTMAX);
|
||||||
|
}
|
||||||
|
@ -100,11 +100,9 @@ TEST(string, strsignal) {
|
|||||||
ASSERT_STREQ("Hangup", strsignal(1));
|
ASSERT_STREQ("Hangup", strsignal(1));
|
||||||
|
|
||||||
// A real-time signal.
|
// A real-time signal.
|
||||||
#ifdef __GLIBC__ // glibc reserves real-time signals for internal use, and doesn't count those.
|
ASSERT_STREQ("Real-time signal 14", strsignal(SIGRTMIN + 14));
|
||||||
ASSERT_STREQ("Real-time signal 14", strsignal(48));
|
// One of the signals the C library keeps to itself.
|
||||||
#else
|
ASSERT_STREQ("Unknown signal 32", strsignal(__SIGRTMIN));
|
||||||
ASSERT_STREQ("Real-time signal 16", strsignal(48));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Errors.
|
// Errors.
|
||||||
ASSERT_STREQ("Unknown signal -1", strsignal(-1)); // Too small.
|
ASSERT_STREQ("Unknown signal -1", strsignal(-1)); // Too small.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user