]> granicus.if.org Git - strace/commit
Rewrite signal mask decoding without sigset_t
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 26 Feb 2014 16:51:28 +0000 (16:51 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 27 Feb 2014 00:28:39 +0000 (00:28 +0000)
commit38593e942ad4b16b2c3c43ea521167368771cbfb
tree1d495359a95b84a1ffebddd5c4ad19a5fcd1f121
parentd354130b3ac060051b55cda46c45ab5f5574548d
Rewrite signal mask decoding without sigset_t

The sigset_t provided by libc is not quite convenient.
In glibc, sigset_t is an array with space for 1024 bits, which is much
more than required: all architectures supported by Linux have only 64
signals except MIPS, which has 128.
In bionic libc, LP32 sigset_t is only 4 bytes long, which is less than
necessary.

With this change, signal mask is decoded without use of intermediate
sigset_t structure, which saves us some cpu cycles in case of glibc with
its inflated sigset_t, and enables build with libcs where sigset_t is
broken.

Old implementation used to check each signal number in the given signal
mask twice using sigismember().
New implementation is based on popcount and next_set_bit() so it's
noticeably faster.

* configure.ac: Check for __builtin_popcount.
* signal.c: Ensure that NSIG >= 32.
(sprintsigmask, sprintsigmask_long, printsigmask): Remove.
(popcount32, sprintsigmask_n): New functions.
(tprintsigmask_addr, sprintsigmask_val, tprintsigmask_val): New macros.
(print_sigset_addr_len, sys_sigsetmask, sys_sigreturn, sys_siggetmask,
sys_sigsuspend, sys_sigprocmask, decode_new_sigaction): Update to use
new signal mask decoding interface.
* tests/sigaction.c (main): Add a test with almost filled signal mask.
* tests/sigaction.awk: Update.
configure.ac
signal.c
tests/sigaction.awk
tests/sigaction.c