Fix an off-by-one error in the sigset_t function error handling.

Spotted while running the tests on MIPS, where sigset_t is
actually large enough. The bits in sigset_t are used such that
signal 1 is represented by bit 0, so the range of signals is
actually [1, 8*sizeof(sigset_t)]; it seems clearer to reword
the code in terms of valid bit offsets [0, 8*sizeof(sigset_t)),
which leads to the usual bounds checking idiom.

Change-Id: Id899c288e15ff71c85dd2fd33c47f8e97aa1956f
This commit is contained in:
Elliott Hughes
2013-01-07 13:58:49 -08:00
parent 26c5b2d460
commit fb5e5cbdd4
2 changed files with 13 additions and 13 deletions

View File

@@ -48,13 +48,13 @@ static void TestSigSet2(Fn fn) {
int min_signal = SIGHUP;
int max_signal = SIGRTMAX;
#if __BIONIC__
// bionic's sigset_t is too small: 32 bits instead of 64.
#if defined(__BIONIC__) && !defined(__mips__)
// 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.
// See http://b/3038348 and http://b/5828899.
max_signal = 31;
max_signal = 32;
#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));
#endif