]>
Commit | Line | Data |
---|---|---|
28f540f4 | 1 | /* __sig_atomic_t, __sigset_t, and related definitions. Generic/BSD version. |
a784e502 | 2 | Copyright (C) 1991, 1992, 1994, 1996, 1997, 2007, 2012 |
b037a293 | 3 | Free Software Foundation, Inc. |
54d79e99 | 4 | This file is part of the GNU C Library. |
28f540f4 | 5 | |
54d79e99 | 6 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
7 | modify it under the terms of the GNU Lesser General Public |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
28f540f4 | 10 | |
54d79e99 UD |
11 | The GNU C Library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 14 | Lesser General Public License for more details. |
28f540f4 | 15 | |
41bdb6e2 AJ |
16 | You should have received a copy of the GNU Lesser General Public |
17 | License along with the GNU C Library; if not, write to the Free | |
18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
19 | 02111-1307 USA. */ | |
28f540f4 RM |
20 | |
21 | #ifndef _SIGSET_H_types | |
22 | #define _SIGSET_H_types 1 | |
23 | ||
24 | typedef int __sig_atomic_t; | |
25 | ||
26 | /* A `sigset_t' has a bit for each signal. */ | |
27 | typedef unsigned long int __sigset_t; | |
28 | ||
29 | #endif | |
30 | ||
31 | ||
32 | /* We only want to define these functions if <signal.h> was actually | |
33 | included; otherwise we were included just to define the types. Since we | |
34 | are namespace-clean, it wouldn't hurt to define extra macros. But | |
35 | trouble can be caused by functions being defined (e.g., any global | |
36 | register vars declared later will cause compilation errors). */ | |
37 | ||
d71b808a | 38 | #if !defined _SIGSET_H_fns && defined _SIGNAL_H |
28f540f4 RM |
39 | #define _SIGSET_H_fns 1 |
40 | ||
84384f5b | 41 | #ifndef _EXTERN_INLINE |
b037a293 | 42 | # define _EXTERN_INLINE __extern_inline |
84384f5b UD |
43 | #endif |
44 | ||
28f540f4 RM |
45 | /* Return a mask that includes SIG only. The cast to `sigset_t' avoids |
46 | overflow if `sigset_t' is wider than `int'. */ | |
47 | #define __sigmask(sig) (((__sigset_t) 1) << ((sig) - 1)) | |
48 | ||
49 | #define __sigemptyset(set) ((*(set) = (__sigset_t) 0), 0) | |
50 | #define __sigfillset(set) ((*(set) = ~(__sigset_t) 0), 0) | |
51 | ||
e7fd8a39 UD |
52 | #ifdef _GNU_SOURCE |
53 | # define __sigisemptyset(set) (*(set) == (__sigset_t) 0) | |
54 | # define __sigandset(dest, left, right) \ | |
779ae82e | 55 | ((*(dest) = (*(left) & *(right))), 0) |
e7fd8a39 | 56 | # define __sigorset(dest, left, right) \ |
779ae82e | 57 | ((*(dest) = (*(left) | *(right))), 0) |
e7fd8a39 UD |
58 | #endif |
59 | ||
84384f5b UD |
60 | /* These functions needn't check for a bogus signal number -- error |
61 | checking is done in the non __ versions. */ | |
28f540f4 | 62 | |
a784e502 | 63 | extern int __sigismember (const __sigset_t *, int); |
26761c28 UD |
64 | extern int __sigaddset (__sigset_t *, int); |
65 | extern int __sigdelset (__sigset_t *, int); | |
510ca033 | 66 | |
0c6cee5d UD |
67 | #ifdef __USE_EXTERN_INLINES |
68 | # define __SIGSETFN(NAME, BODY, CONST) \ | |
28f540f4 | 69 | _EXTERN_INLINE int \ |
84384f5b | 70 | NAME (CONST __sigset_t *__set, int __sig) \ |
28f540f4 | 71 | { \ |
84384f5b UD |
72 | __sigset_t __mask = __sigmask (__sig); \ |
73 | return BODY; \ | |
28f540f4 RM |
74 | } |
75 | ||
a784e502 | 76 | __SIGSETFN (__sigismember, (*__set & __mask) ? 1 : 0, const) |
84384f5b UD |
77 | __SIGSETFN (__sigaddset, ((*__set |= __mask), 0), ) |
78 | __SIGSETFN (__sigdelset, ((*__set &= ~__mask), 0), ) | |
28f540f4 | 79 | |
0c6cee5d UD |
80 | # undef __SIGSETFN |
81 | #endif | |
28f540f4 RM |
82 | |
83 | ||
84 | #endif /* ! _SIGSET_H_fns. */ |