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 * Real Time signals may be queued.
15 struct list_head list;
22 #define SIGQUEUE_PREALLOC 1
25 struct list_head list;
30 * Define some primitives to manipulate sigset_t.
33 #ifndef __HAVE_ARCH_SIG_BITOPS
34 #include <linux/bitops.h>
36 /* We don't use <linux/bitops.h> for these because there is no need to
38 static inline void sigaddset(sigset_t *set, int _sig)
40 unsigned long sig = _sig - 1;
42 set->sig[0] |= 1UL << sig;
44 set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW);
47 static inline void sigdelset(sigset_t *set, int _sig)
49 unsigned long sig = _sig - 1;
51 set->sig[0] &= ~(1UL << sig);
53 set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW));
56 static inline int sigismember(sigset_t *set, int _sig)
58 unsigned long sig = _sig - 1;
60 return 1 & (set->sig[0] >> sig);
62 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
65 static inline int sigfindinword(unsigned long word)
70 #endif /* __HAVE_ARCH_SIG_BITOPS */
72 #define sigmask(sig) (1UL << ((sig) - 1))
74 #ifndef __HAVE_ARCH_SIG_SETOPS
75 #include <linux/string.h>
77 #define _SIG_SET_BINOP(name, op) \
78 static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
80 extern void _NSIG_WORDS_is_unsupported_size(void); \
81 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
83 switch (_NSIG_WORDS) { \
85 a3 = a->sig[3]; a2 = a->sig[2]; \
86 b3 = b->sig[3]; b2 = b->sig[2]; \
87 r->sig[3] = op(a3, b3); \
88 r->sig[2] = op(a2, b2); \
90 a1 = a->sig[1]; b1 = b->sig[1]; \
91 r->sig[1] = op(a1, b1); \
93 a0 = a->sig[0]; b0 = b->sig[0]; \
94 r->sig[0] = op(a0, b0); \
97 _NSIG_WORDS_is_unsupported_size(); \
101 #define _sig_or(x,y) ((x) | (y))
102 _SIG_SET_BINOP(sigorsets, _sig_or)
104 #define _sig_and(x,y) ((x) & (y))
105 _SIG_SET_BINOP(sigandsets, _sig_and)
107 #define _sig_nand(x,y) ((x) & ~(y))
108 _SIG_SET_BINOP(signandsets, _sig_nand)
110 #undef _SIG_SET_BINOP
115 #define _SIG_SET_OP(name, op) \
116 static inline void name(sigset_t *set) \
118 extern void _NSIG_WORDS_is_unsupported_size(void); \
120 switch (_NSIG_WORDS) { \
121 case 4: set->sig[3] = op(set->sig[3]); \
122 set->sig[2] = op(set->sig[2]); \
123 case 2: set->sig[1] = op(set->sig[1]); \
124 case 1: set->sig[0] = op(set->sig[0]); \
127 _NSIG_WORDS_is_unsupported_size(); \
131 #define _sig_not(x) (~(x))
132 _SIG_SET_OP(signotset, _sig_not)
137 static inline void sigemptyset(sigset_t *set)
139 switch (_NSIG_WORDS) {
141 memset(set, 0, sizeof(sigset_t));
143 case 2: set->sig[1] = 0;
144 case 1: set->sig[0] = 0;
149 static inline void sigfillset(sigset_t *set)
151 switch (_NSIG_WORDS) {
153 memset(set, -1, sizeof(sigset_t));
155 case 2: set->sig[1] = -1;
156 case 1: set->sig[0] = -1;
161 /* Some extensions for manipulating the low 32 signals in particular. */
163 static inline void sigaddsetmask(sigset_t *set, unsigned long mask)
168 static inline void sigdelsetmask(sigset_t *set, unsigned long mask)
170 set->sig[0] &= ~mask;
173 static inline int sigtestsetmask(sigset_t *set, unsigned long mask)
175 return (set->sig[0] & mask) != 0;
178 static inline void siginitset(sigset_t *set, unsigned long mask)
181 switch (_NSIG_WORDS) {
183 memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1));
185 case 2: set->sig[1] = 0;
190 static inline void siginitsetinv(sigset_t *set, unsigned long mask)
193 switch (_NSIG_WORDS) {
195 memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
197 case 2: set->sig[1] = -1;
202 #endif /* __HAVE_ARCH_SIG_SETOPS */
204 static inline void init_sigpending(struct sigpending *sig)
206 sigemptyset(&sig->signal);
207 INIT_LIST_HEAD(&sig->list);
210 extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
211 extern long do_sigpending(void __user *, unsigned long);
212 extern int sigprocmask(int, sigset_t *, sigset_t *);
214 #ifndef HAVE_ARCH_GET_SIGNAL_TO_DELIVER
216 extern int get_signal_to_deliver(siginfo_t *info, struct pt_regs *regs, void *cookie);
219 #endif /* __KERNEL__ */
221 #endif /* _LINUX_SIGNAL_H */