Merge "Fix an off-by-one error in the sigset_t function error handling."
This commit is contained in:
commit
7e22db037e
@ -58,34 +58,34 @@ extern const char* const sys_siglist[];
|
|||||||
extern const char* const sys_signame[];
|
extern const char* const sys_signame[];
|
||||||
|
|
||||||
static __inline__ int sigismember(sigset_t* set, int signum) {
|
static __inline__ int sigismember(sigset_t* set, int signum) {
|
||||||
if (set == NULL || signum < 1 || signum >= 8*sizeof(sigset_t)) {
|
int bit = signum - 1; // Signal numbers start at 1, but bit positions start at 0.
|
||||||
|
if (set == NULL || bit < 0 || bit >= 8*sizeof(sigset_t)) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
unsigned long* local_set = (unsigned long*) set;
|
unsigned long* local_set = (unsigned long*) set;
|
||||||
signum--;
|
return (int) ((local_set[bit / LONG_BIT] >> (bit % LONG_BIT)) & 1);
|
||||||
return (int) ((local_set[signum/LONG_BIT] >> (signum%LONG_BIT)) & 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ int sigaddset(sigset_t* set, int signum) {
|
static __inline__ int sigaddset(sigset_t* set, int signum) {
|
||||||
if (set == NULL || signum < 1 || signum >= 8*sizeof(sigset_t)) {
|
int bit = signum - 1; // Signal numbers start at 1, but bit positions start at 0.
|
||||||
|
if (set == NULL || bit < 0 || bit >= 8*sizeof(sigset_t)) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
unsigned long* local_set = (unsigned long*) set;
|
unsigned long* local_set = (unsigned long*) set;
|
||||||
signum--;
|
local_set[bit / LONG_BIT] |= 1UL << (bit % LONG_BIT);
|
||||||
local_set[signum/LONG_BIT] |= 1UL << (signum%LONG_BIT);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ int sigdelset(sigset_t* set, int signum) {
|
static __inline__ int sigdelset(sigset_t* set, int signum) {
|
||||||
if (set == NULL || signum < 1 || signum >= 8*sizeof(sigset_t)) {
|
int bit = signum - 1; // Signal numbers start at 1, but bit positions start at 0.
|
||||||
|
if (set == NULL || bit < 0 || bit >= 8*sizeof(sigset_t)) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
unsigned long* local_set = (unsigned long*) set;
|
unsigned long* local_set = (unsigned long*) set;
|
||||||
signum--;
|
local_set[bit / LONG_BIT] &= ~(1UL << (bit % LONG_BIT));
|
||||||
local_set[signum/LONG_BIT] &= ~(1UL << (signum%LONG_BIT));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,13 +48,13 @@ static void TestSigSet2(Fn fn) {
|
|||||||
int min_signal = SIGHUP;
|
int min_signal = SIGHUP;
|
||||||
int max_signal = SIGRTMAX;
|
int max_signal = SIGRTMAX;
|
||||||
|
|
||||||
#if __BIONIC__
|
#if defined(__BIONIC__) && !defined(__mips__)
|
||||||
// bionic's sigset_t is too small: 32 bits instead of 64.
|
// bionic's sigset_t is too small for ARM and x86: 32 bits instead of 64.
|
||||||
// This means you can't refer to any of the real-time signals.
|
// This means you can't refer to any of the real-time signals.
|
||||||
// See http://b/3038348 and http://b/5828899.
|
// See http://b/3038348 and http://b/5828899.
|
||||||
max_signal = 31;
|
max_signal = 32;
|
||||||
#else
|
#else
|
||||||
// Other C libraries are perfectly capable of using their largest signal.
|
// Other C libraries (or bionic for MIPS) are perfectly capable of using their largest signal.
|
||||||
ASSERT_GE(sizeof(sigset_t) * 8, static_cast<size_t>(SIGRTMAX));
|
ASSERT_GE(sizeof(sigset_t) * 8, static_cast<size_t>(SIGRTMAX));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user