aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/sigsetops.h
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/sigsetops.h')
-rw-r--r--sysdeps/unix/sysv/linux/sigsetops.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/sysdeps/unix/sysv/linux/sigsetops.h b/sysdeps/unix/sysv/linux/sigsetops.h
index db8f378cf0..3f29ead009 100644
--- a/sysdeps/unix/sysv/linux/sigsetops.h
+++ b/sysdeps/unix/sysv/linux/sigsetops.h
@@ -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 (_NSIG / (8 * sizeof (unsigned long int )))
+#define __NSIG_WORDS (ALIGN_UP ((_NSIG - 1), ULONG_WIDTH) / ULONG_WIDTH)
+_Static_assert (__NSIG_WORDS <= _SIGSET_NWORDS,
+ "__NSIG_WORDS > _SIGSET_WORDS");
+
+/* 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)