1 #ifndef _LINUX_SIGNAL_H
2 #define _LINUX_SIGNAL_H
4 #include <linux/list.h>
5 #include <linux/spinlock.h>
6 #include <asm/signal.h>
7 #include <asm/siginfo.h>
11 #define MAX_SIGPENDING 1024
14 * Real Time signals may be queued.
18 struct list_head list
;
22 struct user_struct
*user
;
26 #define SIGQUEUE_PREALLOC 1
29 struct list_head list
;
34 * Define some primitives to manipulate sigset_t.
37 #ifndef __HAVE_ARCH_SIG_BITOPS
38 #include <linux/bitops.h>
40 /* We don't use <linux/bitops.h> for these because there is no need to
42 static inline void sigaddset(sigset_t
*set
, int _sig
)
44 unsigned long sig
= _sig
- 1;
46 set
->sig
[0] |= 1UL << sig
;
48 set
->sig
[sig
/ _NSIG_BPW
] |= 1UL << (sig
% _NSIG_BPW
);
51 static inline void sigdelset(sigset_t
*set
, int _sig
)
53 unsigned long sig
= _sig
- 1;
55 set
->sig
[0] &= ~(1UL << sig
);
57 set
->sig
[sig
/ _NSIG_BPW
] &= ~(1UL << (sig
% _NSIG_BPW
));
60 static inline int sigismember(sigset_t
*set
, int _sig
)
62 unsigned long sig
= _sig
- 1;
64 return 1 & (set
->sig
[0] >> sig
);
66 return 1 & (set
->sig
[sig
/ _NSIG_BPW
] >> (sig
% _NSIG_BPW
));
69 static inline int sigfindinword(unsigned long word
)
74 #endif /* __HAVE_ARCH_SIG_BITOPS */
76 #define sigmask(sig) (1UL << ((sig) - 1))
78 #ifndef __HAVE_ARCH_SIG_SETOPS
79 #include <linux/string.h>
81 #define _SIG_SET_BINOP(name, op) \
82 static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
84 extern void _NSIG_WORDS_is_unsupported_size(void); \
85 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
87 switch (_NSIG_WORDS) { \
89 a3 = a->sig[3]; a2 = a->sig[2]; \
90 b3 = b->sig[3]; b2 = b->sig[2]; \
91 r->sig[3] = op(a3, b3); \
92 r->sig[2] = op(a2, b2); \
94 a1 = a->sig[1]; b1 = b->sig[1]; \
95 r->sig[1] = op(a1, b1); \
97 a0 = a->sig[0]; b0 = b->sig[0]; \
98 r->sig[0] = op(a0, b0); \
101 _NSIG_WORDS_is_unsupported_size(); \
105 #define _sig_or(x,y) ((x) | (y))
106 _SIG_SET_BINOP(sigorsets
, _sig_or
)
108 #define _sig_and(x,y) ((x) & (y))
109 _SIG_SET_BINOP(sigandsets
, _sig_and
)
111 #define _sig_nand(x,y) ((x) & ~(y))
112 _SIG_SET_BINOP(signandsets
, _sig_nand
)
114 #undef _SIG_SET_BINOP
119 #define _SIG_SET_OP(name, op) \
120 static inline void name(sigset_t *set) \
122 extern void _NSIG_WORDS_is_unsupported_size(void); \
124 switch (_NSIG_WORDS) { \
125 case 4: set->sig[3] = op(set->sig[3]); \
126 set->sig[2] = op(set->sig[2]); \
127 case 2: set->sig[1] = op(set->sig[1]); \
128 case 1: set->sig[0] = op(set->sig[0]); \
131 _NSIG_WORDS_is_unsupported_size(); \
135 #define _sig_not(x) (~(x))
136 _SIG_SET_OP(signotset
, _sig_not
)
141 static 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 static 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 /* Some extensions for manipulating the low 32 signals in particular. */
167 static inline void sigaddsetmask(sigset_t
*set
, unsigned long mask
)
172 static inline void sigdelsetmask(sigset_t
*set
, unsigned long mask
)
174 set
->sig
[0] &= ~mask
;
177 static inline int sigtestsetmask(sigset_t
*set
, unsigned long mask
)
179 return (set
->sig
[0] & mask
) != 0;
182 static inline void siginitset(sigset_t
*set
, unsigned long mask
)
185 switch (_NSIG_WORDS
) {
187 memset(&set
->sig
[1], 0, sizeof(long)*(_NSIG_WORDS
-1));
189 case 2: set
->sig
[1] = 0;
194 static inline void siginitsetinv(sigset_t
*set
, unsigned long mask
)
197 switch (_NSIG_WORDS
) {
199 memset(&set
->sig
[1], -1, sizeof(long)*(_NSIG_WORDS
-1));
201 case 2: set
->sig
[1] = -1;
206 #endif /* __HAVE_ARCH_SIG_SETOPS */
208 static inline void init_sigpending(struct sigpending
*sig
)
210 sigemptyset(&sig
->signal
);
211 INIT_LIST_HEAD(&sig
->list
);
214 extern int group_send_sig_info(int sig
, struct siginfo
*info
, struct task_struct
*p
);
215 extern long do_sigpending(void __user
*, unsigned long);
216 extern int sigprocmask(int, sigset_t
*, sigset_t
*);
218 #ifndef HAVE_ARCH_GET_SIGNAL_TO_DELIVER
220 extern int get_signal_to_deliver(siginfo_t
*info
, struct k_sigaction
*return_ka
, struct pt_regs
*regs
, void *cookie
);
223 #endif /* __KERNEL__ */
225 #endif /* _LINUX_SIGNAL_H */