mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
linux: Fix __NSIG_WORDS and add __NSIG_BYTES
The __NSIG_WORDS value is based on minimum number of words to hold the maximum number of signals supported by the architecture. This patch also adds __NSIG_BYTES, which is the number of bytes required to represent the supported number of signals. It is used in syscalls which takes a sigset_t. Checked on x86_64-linux-gnu and i686-linux-gnu. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
@ -20,23 +20,31 @@
|
||||
#define _SIGSETOPS_H 1
|
||||
|
||||
#include <signal.h>
|
||||
#include <limits.h>
|
||||
#include <libc-pointer-arith.h>
|
||||
|
||||
/* Return a mask that includes the bit for SIG only. */
|
||||
# define __sigmask(sig) \
|
||||
(((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int))))
|
||||
#define __sigmask(sig) \
|
||||
(1UL << (((sig) - 1) % ULONG_WIDTH))
|
||||
|
||||
/* Return the word index for SIG. */
|
||||
static inline unsigned long int
|
||||
__sigword (int sig)
|
||||
{
|
||||
return (sig - 1) / (8 * sizeof (unsigned long int));
|
||||
return (sig - 1) / ULONG_WIDTH;
|
||||
}
|
||||
|
||||
/* Linux sig* functions only handle up to __NSIG_WORDS words instead of
|
||||
full _SIGSET_NWORDS sigset size. The signal numbers are 1-based, and
|
||||
bit 0 of a signal mask is for signal 1. */
|
||||
#define __NSIG_WORDS (ALIGN_UP ((_NSIG - 1), ULONG_WIDTH) / ULONG_WIDTH)
|
||||
_Static_assert (__NSIG_WORDS <= _SIGSET_NWORDS,
|
||||
"__NSIG_WORDS > _SIGSET_WORDS");
|
||||
|
||||
# define __NSIG_WORDS (_NSIG / (8 * sizeof (unsigned long int )))
|
||||
/* This macro is used on syscall that takes a sigset_t to specify the expected
|
||||
size in bytes. As for glibc, kernel sigset is implemented as an array of
|
||||
unsigned long. */
|
||||
#define __NSIG_BYTES (__NSIG_WORDS * (ULONG_WIDTH / UCHAR_WIDTH))
|
||||
|
||||
static inline void
|
||||
__sigemptyset (sigset_t *set)
|
||||
|
Reference in New Issue
Block a user