]>
Commit | Line | Data |
---|---|---|
28f540f4 | 1 | /* __sig_atomic_t, __sigset_t, and related definitions. SVR4 version. |
54d79e99 UD |
2 | Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. | |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Library General Public License as | |
7 | published by the Free Software Foundation; either version 2 of the | |
8 | License, or (at your option) any later version. | |
9 | ||
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 | Library General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Library General Public | |
16 | License along with the GNU C Library; see the file COPYING.LIB. If not, | |
17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
18 | Boston, MA 02111-1307, USA. */ | |
28f540f4 RM |
19 | |
20 | #ifndef _SIGSET_H_types | |
21 | #define _SIGSET_H_types 1 | |
22 | ||
23 | typedef int __sig_atomic_t; | |
24 | ||
25 | /* A `sigset_t' has a bit for each signal. */ | |
26 | typedef struct | |
27 | { | |
28 | unsigned long int __sigbits[4]; | |
29 | } __sigset_t; | |
30 | ||
31 | #endif /* ! _SIGSET_H_types */ | |
32 | ||
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). */ | |
38 | ||
39 | #if !defined (_SIGSET_H_fns) && defined (_SIGNAL_H) | |
40 | #define _SIGSET_H_fns 1 | |
41 | ||
42 | /* Return a mask that includes SIG only. */ | |
43 | #define __sigmask(sig) (1 << ((sig) - 1)) | |
44 | ||
45 | ||
46 | /* It's easier to assume 8-bit bytes than to get CHAR_BIT. */ | |
47 | #define __NSSBITS (sizeof (__sigset_t) * 8) | |
48 | #define __SSELT(s) ((s) / __NSSBITS) | |
49 | #define __SSMASK(s) (1 << ((s) % __NSSBITS)) | |
50 | ||
51 | #ifndef _EXTERN_INLINE | |
52 | #define _EXTERN_INLINE extern __inline | |
53 | #endif | |
54 | ||
55 | _EXTERN_INLINE int | |
56 | __sigemptyset (__sigset_t *__set) | |
57 | { | |
58 | __set->__sigbits[0] = __set->__sigbits[1] = | |
59 | __set->__sigbits[2] = __set->__sigbits[3] = 0L; | |
60 | return 0; | |
61 | } | |
62 | ||
63 | _EXTERN_INLINE int | |
64 | __sigfillset (__sigset_t *__set) | |
65 | { | |
66 | /* SVR4 has a system call for `sigfillset' (!), and it only sets the bits | |
67 | for signals [1,31]. Setting bits for unimplemented signals seems | |
68 | harmless (and we will find out if it really is). */ | |
69 | __set->__sigbits[0] = __set->__sigbits[1] = | |
e627021e | 70 | __set->__sigbits[2] = __set->__sigbits[3] = ~0L; |
28f540f4 RM |
71 | return 0; |
72 | } | |
73 | ||
74 | _EXTERN_INLINE int | |
75 | __sigaddset (__sigset_t *__set, int __sig) | |
76 | { | |
77 | __set->__sigbits[__SSELT (__sig)] |= __SSMASK (__sig); | |
78 | return 0; | |
79 | } | |
80 | ||
81 | _EXTERN_INLINE int | |
82 | __sigdelset (__sigset_t *__set, int __sig) | |
83 | { | |
84 | __set->__sigbits[__SSELT (__sig)] &= ~__SSMASK (__sig); | |
85 | return 0; | |
86 | } | |
87 | ||
88 | _EXTERN_INLINE int | |
89 | __sigismember (__const __sigset_t *__set, int __sig) | |
90 | { | |
91 | if (__set->__sigbits[__SSELT (__sig)] & __SSMASK (__sig)) | |
92 | return 1; | |
93 | return 0; | |
94 | } | |
95 | ||
96 | #endif /* ! _SIGSET_H_fns */ |