OSDN Git Service

reduce sigset_t size for 128 bytes to 64 bits:
authorDenis Vlasenko <vda.linux@googlemail.com>
Sat, 29 Nov 2008 15:35:51 +0000 (15:35 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Sat, 29 Nov 2008 15:35:51 +0000 (15:35 -0000)
    text           data     bss     dec     hex filename
-  38457          18352    8636   65445    ffa5 lib/libpthread-0.9.30-svn.so
+  38015          18096    8636   64747    fceb lib/libpthread-0.9.30-svn.so
-   8205            280      12    8497    2131 lib/libthread_db-0.9.30-svn.so
+   8193            280      12    8485    2125 lib/libthread_db-0.9.30-svn.so
- 275208           1823   19132  296163   484e3 lib/libuClibc-0.9.30-svn.so
+ 274787           1823   19012  295622   482c6 lib/libuClibc-0.9.30-svn.so

libc/sysdeps/linux/common/bits/sigset.h

index 9a16e5c..1449767 100644 (file)
 
 typedef int __sig_atomic_t;
 
-/* A `sigset_t' has a bit for each signal.  */
-
-# define _SIGSET_NWORDS        (1024 / (8 * sizeof (unsigned long int)))
+/* 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
+ */
+
+# define _SIGSET_NWORDS        (64 / (8 * sizeof (unsigned long int)))
 typedef struct
   {
     unsigned long int __val[_SIGSET_NWORDS];
@@ -47,11 +52,12 @@ typedef struct
 # endif
 
 /* 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) << (((sig) - 1) % (8 * sizeof (unsigned long int))))
+  (((unsigned long int) 1) << ((unsigned)((sig) - 1) % (8 * sizeof (unsigned long int))))
 
 /* Return the word index for SIG.  */
-# define __sigword(sig)        (((sig) - 1) / (8 * sizeof (unsigned long int)))
+# define __sigword(sig)        ((unsigned)((sig) - 1) / (8 * sizeof (unsigned long int)))
 
 # if defined __GNUC__ && __GNUC__ >= 2
 #  define __sigemptyset(set) \