From 83eb4d5219f920fde59c9edd9204664f0c2f9f36 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Mon, 1 Dec 2008 18:00:04 +0000 Subject: fix sigset_t size for mips (it's the only arch with 128 signals). fix _NSIG for it. better document what's going on in sigaction(). seems to not induce any actual code changes (sans mips). --- libc/sysdeps/linux/common/bits/kernel_sigaction.h | 11 ++++++-- libc/sysdeps/linux/common/bits/sigset.h | 31 +++++++++++++++-------- 2 files changed, 29 insertions(+), 13 deletions(-) (limited to 'libc/sysdeps/linux/common/bits') diff --git a/libc/sysdeps/linux/common/bits/kernel_sigaction.h b/libc/sysdeps/linux/common/bits/kernel_sigaction.h index 99148e608..89aa2bb88 100644 --- a/libc/sysdeps/linux/common/bits/kernel_sigaction.h +++ b/libc/sysdeps/linux/common/bits/kernel_sigaction.h @@ -7,6 +7,10 @@ #undef NO_OLD_SIGACTION #if defined(__mips__) +/* We have libc/sysdeps/linux/mips/bits/kernel_sigaction.h, + * so this should never be used. Lets see whether it is true. */ +struct BUG_is_here { char BUG_is_here[-1]; }; + #undef HAVE_SA_RESTORER /* This is the sigaction structure from the Linux 2.1.24 kernel. */ #include @@ -18,11 +22,9 @@ struct old_kernel_sigaction { #define _KERNEL_NSIG 128 #define _KERNEL_NSIG_BPW 32 #define _KERNEL_NSIG_WORDS (_KERNEL_NSIG / _KERNEL_NSIG_BPW) - typedef struct { unsigned long sig[_KERNEL_NSIG_WORDS]; } kernel_sigset_t; - /* This is the sigaction structure from the Linux 2.1.68 kernel. */ struct kernel_sigaction { unsigned int sa_flags; @@ -31,7 +33,9 @@ struct kernel_sigaction { void (*sa_restorer)(void); int s_resv[1]; /* reserved */ }; + #elif defined(__ia64__) + #define NO_OLD_SIGACTION #undef HAVE_SA_RESTORER struct kernel_sigaction { @@ -39,7 +43,9 @@ struct kernel_sigaction { unsigned long sa_flags; sigset_t sa_mask; }; + #else + #define HAVE_SA_RESTORER /* This is the sigaction structure from the Linux 2.1.20 kernel. */ struct old_kernel_sigaction { @@ -55,6 +61,7 @@ struct kernel_sigaction { void (*sa_restorer) (void); sigset_t sa_mask; }; + #endif #ifndef NO_OLD_SIGACTION diff --git a/libc/sysdeps/linux/common/bits/sigset.h b/libc/sysdeps/linux/common/bits/sigset.h index 964b09178..7ec87eb1d 100644 --- a/libc/sysdeps/linux/common/bits/sigset.h +++ b/libc/sysdeps/linux/common/bits/sigset.h @@ -23,15 +23,24 @@ typedef int __sig_atomic_t; /* A 'sigset_t' has a bit for each signal. - * Signal 0 does not exist, so we have signals 1..64. - * glibc has space for 1024 signals (!), but all arches supported - * by Linux have 64 signals only. - * See, for example, _NSIG (defined to 65) in signum.h + * glibc has space for 1024 signals (!), but most arches supported + * by Linux have 64 signals, and only MIPS has 128. + * There seems to be some historical baggage in sparc[64] + * where they might have (or had in the past) 32 signals only, + * I hope it's irrelevant now. + * Signal 0 does not exist, so we have signals 1..64, not 0..63. + * Note that struct sigaction has embedded sigset_t, + * and this necessitates translation in sigaction() + * to convert it to struct kernel_sigaction. + * See libc/.../sigaction.c, libc/.../kernel_sigaction.h */ - -# define _SIGSET_NWORDS (64 / (8 * sizeof (unsigned long int))) +#if defined(__mips__) +# define _SIGSET_NWORDS (128 / (8 * sizeof (unsigned long))) +#else +# define _SIGSET_NWORDS (64 / (8 * sizeof (unsigned long))) +#endif typedef struct { - unsigned long int __val[_SIGSET_NWORDS]; + unsigned long __val[_SIGSET_NWORDS]; } __sigset_t; #endif @@ -53,10 +62,10 @@ typedef struct { /* Return a mask that includes the bit for SIG only. */ /* Unsigned cast ensures shift/mask insns are used. */ # define __sigmask(sig) \ - (((unsigned long int) 1) << ((unsigned)((sig) - 1) % (8 * sizeof (unsigned long int)))) + (((unsigned long) 1) << ((unsigned)((sig) - 1) % (8 * sizeof (unsigned long)))) /* Return the word index for SIG. */ -# define __sigword(sig) ((unsigned)((sig) - 1) / (8 * sizeof (unsigned long int))) +# define __sigword(sig) ((unsigned)((sig) - 1) / (8 * sizeof (unsigned long))) /* gcc 4.3.1 is not clever enough to optimize for _SIGSET_NWORDS == 1 and 2, * which are about the only values which can be there */ @@ -161,8 +170,8 @@ libc_hidden_proto(__sigdelset) _EXTERN_INLINE int \ NAME (CONST __sigset_t *__set, int __sig) \ { \ - unsigned long int __mask = __sigmask (__sig); \ - unsigned long int __word = __sigword (__sig); \ + unsigned long __mask = __sigmask (__sig); \ + unsigned long __word = __sigword (__sig); \ return BODY; \ } -- cgit v1.2.3