Fix stack_t decoding and sigset_t decoding.

Corresponds to the following upstream patches:

commit d153bfc505dd30dabc2509091e67460c3ca1675b
Author: Dmitry V. Levin <ldv@altlinux.org>
Date:   Wed Feb 26 22:29:27 2014 +0000

    Add multi-personality support to stack_t decoding

    stack_t is one of many structures that contain members
    whose size differs between 32-bit and 64-bit personalities.

    * signal.c (print_stack_t): Decode 32-bit stack_t on a 64-bit host.

    Reported-by: Elliott Hughes <enh@google.com>

commit 38593e942ad4b16b2c3c43ea521167368771cbfb
Author: Dmitry V. Levin <ldv@altlinux.org>
Date:   Wed Feb 26 16:51:28 2014 +0000

    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.

Change-Id: I4598a97290b3d8415b4946a3e5121248cd97e7b9
4 files changed