2.3.3-74
[glibc.git] / sysdeps / unix / sysv / sysv4 / bits / sigset.h
blob9093c72952e278537894b8fee11f3da3f655bc73
1 /* __sig_atomic_t, __sigset_t, and related definitions. SVR4 version.
2 Copyright (C) 1994-1996, 2002 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #ifndef _SIGSET_H_types
21 #define _SIGSET_H_types 1
23 typedef int __sig_atomic_t;
25 /* A `sigset_t' has a bit for each signal. */
26 typedef struct
28 unsigned long int __sigbits[4];
29 } __sigset_t;
31 #endif /* ! _SIGSET_H_types */
33 /* We only want to define these functions if <signal.h> was actually
34 included; otherwise we were included just to define the types. Since we
35 are namespace-clean, it wouldn't hurt to define extra macros. But
36 trouble can be caused by functions being defined (e.g., any global
37 register vars declared later will cause compilation errors). */
39 #if !defined (_SIGSET_H_fns) && defined (_SIGNAL_H)
40 #define _SIGSET_H_fns 1
42 /* Return a mask that includes SIG only. */
43 #define __sigmask(sig) (1 << ((sig) - 1))
46 /* It's easier to assume 8-bit bytes than to get CHAR_BIT. */
47 #define __NSSBITS (sizeof (unsigned long int) * 8)
48 #define __SSELT(s) ((s) / __NSSBITS)
49 #define __SSMASK(s) (1 << ((s) % __NSSBITS))
51 #ifdef __USE_EXTERN_INLINES
52 # ifndef _EXTERN_INLINE
53 # define _EXTERN_INLINE extern __inline
54 # endif
56 _EXTERN_INLINE int
57 __sigemptyset (__sigset_t *__set)
59 __set->__sigbits[0] = __set->__sigbits[1] =
60 __set->__sigbits[2] = __set->__sigbits[3] = 0L;
61 return 0;
64 _EXTERN_INLINE int
65 __sigfillset (__sigset_t *__set)
67 /* SVR4 has a system call for `sigfillset' (!), and it only sets the bits
68 for signals [1,31]. Setting bits for unimplemented signals seems
69 harmless (and we will find out if it really is). */
70 __set->__sigbits[0] = __set->__sigbits[1] =
71 __set->__sigbits[2] = __set->__sigbits[3] = ~0L;
72 return 0;
75 _EXTERN_INLINE int
76 __sigaddset (__sigset_t *__set, int __sig)
78 __set->__sigbits[__SSELT (__sig)] |= __SSMASK (__sig);
79 return 0;
82 _EXTERN_INLINE int
83 __sigdelset (__sigset_t *__set, int __sig)
85 __set->__sigbits[__SSELT (__sig)] &= ~__SSMASK (__sig);
86 return 0;
89 _EXTERN_INLINE int
90 __sigismember (__const __sigset_t *__set, int __sig)
92 if (__set->__sigbits[__SSELT (__sig)] & __SSMASK (__sig))
93 return 1;
94 return 0;
96 #endif /* use extern inlines. */
98 #endif /* ! _SIGSET_H_fns */