.
[glibc-ports.git] / sysdeps / unix / sysv / aix / bits / sigset.h
blob0dc6b40a7c0f66a73f7f2310ded2bf596d021948
1 /* __sig_atomic_t, __sigset_t, and related definitions. AIX version.
2 Copyright (C) 1991,1992,1994,1996,1997,2000 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. */
27 typedef struct
29 unsigned int __losigs;
30 unsigned int __hisigs;
31 } __sigset_t;
33 #endif
36 /* We only want to define these functions if <signal.h> was actually
37 included; otherwise we were included just to define the types. Since we
38 are namespace-clean, it wouldn't hurt to define extra macros. But
39 trouble can be caused by functions being defined (e.g., any global
40 register vars declared later will cause compilation errors). */
42 #if !defined _SIGSET_H_fns && defined _SIGNAL_H
43 # define _SIGSET_H_fns 1
45 # ifndef _EXTERN_INLINE
46 # define _EXTERN_INLINE extern __inline
47 # endif
49 /* Return a mask that includes the bit for SIG only. */
50 # define __sigmask(sig) \
51 (((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned int))))
53 # if defined __GNUC__ && __GNUC__ >= 2
54 # define __sigemptyset(set) \
55 (__extension__ ({ sigset_t *__set = (set); \
56 __set->__losigs = __set->__hisigs = 0; \
57 0; }))
58 # define __sigfillset(set) \
59 (__extension__ ({ sigset_t *__set = (set); \
60 __set->__losigs = __set->__hisigs = ~0u; \
61 0; }))
63 # ifdef __USE_GNU
64 /* The POSIX does not specify for handling the whole signal set in one
65 command. This is often wanted and so we define three more functions
66 here. */
67 # define __sigisemptyset(set) \
68 (__extension__ ({ const sigset_t *__set = (set); \
69 (__set->__losigs | __set->__hisigs) == 0; }))
70 # define __sigandset(dest, left, right) \
71 (__extension__ ({ sigset_t *__dest = (dest); \
72 const sigset_t *__left = (left); \
73 const sigset_t *__right = (right); \
74 __dest->__losigs = __left->__losigs & __right->__losigs; \
75 __dest->__hisigs = __left->__hisigs & __right->__hisigs; \
76 0; }))
77 # define __sigorset(dest, left, right) \
78 (__extension__ ({ sigset_t *__dest = (dest); \
79 const sigset_t *__left = (left); \
80 const sigset_t *__right = (right); \
81 __dest->__losigs = __left->__losigs | __right->__losigs; \
82 __dest->__hisigs = __left->__hisigs | __right->__hisigs; \
83 0; }))
84 # endif
85 # endif
87 /* These functions needn't check for a bogus signal number -- error
88 checking is done in the non __ versions. */
90 extern int __sigismember (__const __sigset_t *, int);
91 extern int __sigaddset (__sigset_t *, int);
92 extern int __sigdelset (__sigset_t *, int);
94 # ifdef __USE_EXTERN_INLINES
95 _EXTERN_INLINE int
96 __sigismember (__const __sigset_t *__set, int __sig)
98 unsigned int __mask = __sigmask (__sig);
100 return ((__sig < 33 ? __set->__losigs : __set->__hisigs) & __mask ) ? 1 : 0;
103 _EXTERN_INLINE int
104 __sigaddset (__sigset_t *__set, int __sig)
106 unsigned int __mask = __sigmask (__sig);
108 (__sig < 33 ? __set->__losigs : __set->__hisigs) |= __mask;
110 return 0;
113 _EXTERN_INLINE int
114 __sigdelset (__sigset_t *__set, int __sig)
116 unsigned int __mask = __sigmask (__sig);
118 (__sig < 33 ? __set->__losigs : __set->__hisigs) &= ~__mask;
120 return 0;
122 # endif
125 #endif /* ! _SIGSET_H_fns. */