1 #ifndef _LINUX_SIGNAL_H
2 #define _LINUX_SIGNAL_H
4 #include <asm/signal.h>
5 #include <asm/siginfo.h>
9 * Real Time signals may be queued.
14 struct signal_queue
*next
;
19 * Define some primitives to manipulate sigset_t.
22 #ifndef __HAVE_ARCH_SIG_BITOPS
23 #include <asm/bitops.h>
25 /* We don't use <asm/bitops.h> for these because there is no need to
27 extern inline void sigaddset(sigset_t
*set
, int _sig
)
29 unsigned long sig
= _sig
- 1;
31 set
->sig
[0] |= 1UL << sig
;
33 set
->sig
[sig
/ _NSIG_BPW
] |= 1UL << (sig
% _NSIG_BPW
);
36 extern inline void sigdelset(sigset_t
*set
, int _sig
)
38 unsigned long sig
= _sig
- 1;
40 set
->sig
[0] &= ~(1UL << sig
);
42 set
->sig
[sig
/ _NSIG_BPW
] &= ~(1UL << (sig
% _NSIG_BPW
));
45 extern inline int sigismember(sigset_t
*set
, int _sig
)
47 unsigned long sig
= _sig
- 1;
49 return 1 & (set
->sig
[0] >> sig
);
51 return 1 & (set
->sig
[sig
/ _NSIG_BPW
] >> (sig
% _NSIG_BPW
));
54 extern inline int sigfindinword(unsigned long word
)
59 #define sigmask(sig) (1UL << ((sig) - 1))
61 #endif /* __HAVE_ARCH_SIG_BITOPS */
63 #ifndef __HAVE_ARCH_SIG_SETOPS
64 #include <linux/string.h>
66 #define _SIG_SET_BINOP(name, op) \
67 extern inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
69 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
72 for (i = 0; i < _NSIG_WORDS/4; ++i) { \
73 a0 = a->sig[4*i+0]; a1 = a->sig[4*i+1]; \
74 a2 = a->sig[4*i+2]; a3 = a->sig[4*i+3]; \
75 b0 = b->sig[4*i+0]; b1 = b->sig[4*i+1]; \
76 b2 = b->sig[4*i+2]; b3 = b->sig[4*i+3]; \
77 r->sig[4*i+0] = op(a0, b0); \
78 r->sig[4*i+1] = op(a1, b1); \
79 r->sig[4*i+2] = op(a2, b2); \
80 r->sig[4*i+3] = op(a3, b3); \
82 switch (_NSIG_WORDS % 4) { \
84 a0 = a->sig[4*i+0]; a1 = a->sig[4*i+1]; a2 = a->sig[4*i+2]; \
85 b0 = b->sig[4*i+0]; b1 = b->sig[4*i+1]; b2 = b->sig[4*i+2]; \
86 r->sig[4*i+0] = op(a0, b0); \
87 r->sig[4*i+1] = op(a1, b1); \
88 r->sig[4*i+2] = op(a2, b2); \
91 a0 = a->sig[4*i+0]; a1 = a->sig[4*i+1]; \
92 b0 = b->sig[4*i+0]; b1 = b->sig[4*i+1]; \
93 r->sig[4*i+0] = op(a0, b0); \
94 r->sig[4*i+1] = op(a1, b1); \
97 a0 = a->sig[4*i+0]; b0 = b->sig[4*i+0]; \
98 r->sig[4*i+0] = op(a0, b0); \
103 #define _sig_or(x,y) ((x) | (y))
104 _SIG_SET_BINOP(sigorsets
, _sig_or
)
106 #define _sig_and(x,y) ((x) & (y))
107 _SIG_SET_BINOP(sigandsets
, _sig_and
)
109 #define _sig_nand(x,y) ((x) & ~(y))
110 _SIG_SET_BINOP(signandsets
, _sig_nand
)
112 #undef _SIG_SET_BINOP
117 #define _SIG_SET_OP(name, op) \
118 extern inline void name(sigset_t *set) \
122 for (i = 0; i < _NSIG_WORDS/4; ++i) { \
123 set->sig[4*i+0] = op(set->sig[4*i+0]); \
124 set->sig[4*i+1] = op(set->sig[4*i+1]); \
125 set->sig[4*i+2] = op(set->sig[4*i+2]); \
126 set->sig[4*i+3] = op(set->sig[4*i+3]); \
128 switch (_NSIG_WORDS % 4) { \
129 case 3: set->sig[4*i+2] = op(set->sig[4*i+2]); \
130 case 2: set->sig[4*i+1] = op(set->sig[4*i+1]); \
131 case 1: set->sig[4*i+0] = op(set->sig[4*i+0]); \
135 #define _sig_not(x) (~(x))
136 _SIG_SET_OP(signotset
, _sig_not
)
141 extern inline void sigemptyset(sigset_t
*set
)
143 switch (_NSIG_WORDS
) {
145 memset(set
, 0, sizeof(sigset_t
));
147 case 2: set
->sig
[1] = 0;
148 case 1: set
->sig
[0] = 0;
153 extern inline void sigfillset(sigset_t
*set
)
155 switch (_NSIG_WORDS
) {
157 memset(set
, -1, sizeof(sigset_t
));
159 case 2: set
->sig
[1] = -1;
160 case 1: set
->sig
[0] = -1;
165 extern char * render_sigset_t(sigset_t
*set
, char *buffer
);
167 /* Some extensions for manipulating the low 32 signals in particular. */
169 extern inline void sigaddsetmask(sigset_t
*set
, unsigned long mask
)
174 extern inline void sigdelsetmask(sigset_t
*set
, unsigned long mask
)
176 set
->sig
[0] &= ~mask
;
179 extern inline int sigtestsetmask(sigset_t
*set
, unsigned long mask
)
181 return (set
->sig
[0] & mask
) != 0;
184 extern inline void siginitset(sigset_t
*set
, unsigned long mask
)
187 switch (_NSIG_WORDS
) {
189 memset(&set
->sig
[1], 0, sizeof(long)*(_NSIG_WORDS
-1));
191 case 2: set
->sig
[1] = 0;
196 extern inline void siginitsetinv(sigset_t
*set
, unsigned long mask
)
199 switch (_NSIG_WORDS
) {
201 memset(&set
->sig
[1], -1, sizeof(long)*(_NSIG_WORDS
-1));
203 case 2: set
->sig
[1] = -1;
208 #endif /* __HAVE_ARCH_SIG_SETOPS */
210 #endif /* __KERNEL__ */
212 #endif /* _LINUX_SIGNAL_H */