Update.
[glibc.git] / bits / sigset.h
blob5fc8692df059d40d77394588d074c1cc1d83d0f2
1 /* __sig_atomic_t, __sigset_t, and related definitions. Generic/BSD version.
2 Copyright (C) 1991, 1992, 1994, 1996, 1997 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 unsigned long int __sigset_t;
28 #endif
31 /* We only want to define these functions if <signal.h> was actually
32 included; otherwise we were included just to define the types. Since we
33 are namespace-clean, it wouldn't hurt to define extra macros. But
34 trouble can be caused by functions being defined (e.g., any global
35 register vars declared later will cause compilation errors). */
37 #if !defined _SIGSET_H_fns && defined _SIGNAL_H
38 #define _SIGSET_H_fns 1
40 #ifndef _EXTERN_INLINE
41 # define _EXTERN_INLINE extern __inline
42 #endif
44 /* Return a mask that includes SIG only. The cast to `sigset_t' avoids
45 overflow if `sigset_t' is wider than `int'. */
46 #define __sigmask(sig) (((__sigset_t) 1) << ((sig) - 1))
48 #define __sigemptyset(set) ((*(set) = (__sigset_t) 0), 0)
49 #define __sigfillset(set) ((*(set) = ~(__sigset_t) 0), 0)
51 #ifdef _GNU_SOURCE
52 # define __sigisemptyset(set) (*(set) == (__sigset_t) 0)
53 # define __sigandset(dest, left, right) \
54 ((*(dest) = (*(left) & *(right))), 0)
55 # define __sigorset(dest, left, right) \
56 ((*(dest) = (*(left) | *(right))), 0)
57 #endif
59 /* These functions needn't check for a bogus signal number -- error
60 checking is done in the non __ versions. */
62 extern int __sigismember (__const __sigset_t *, int);
63 extern int __sigaddset (__sigset_t *, int);
64 extern int __sigdelset (__sigset_t *, int);
66 #ifdef __USE_EXTERN_INLINES
67 # define __SIGSETFN(NAME, BODY, CONST) \
68 _EXTERN_INLINE int \
69 NAME (CONST __sigset_t *__set, int __sig) \
70 { \
71 __sigset_t __mask = __sigmask (__sig); \
72 return BODY; \
75 __SIGSETFN (__sigismember, (*__set & __mask) ? 1 : 0, __const)
76 __SIGSETFN (__sigaddset, ((*__set |= __mask), 0), )
77 __SIGSETFN (__sigdelset, ((*__set &= ~__mask), 0), )
79 # undef __SIGSETFN
80 #endif
83 #endif /* ! _SIGSET_H_fns. */