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>
12 * These values of sa_flags are used only by the kernel as part of the
13 * irq handling routines.
15 * SA_INTERRUPT is also used by the irq handling routines.
16 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
18 #define SA_PROBE SA_ONESHOT
19 #define SA_SAMPLE_RANDOM SA_RESTART
20 #define SA_SHIRQ 0x04000000
23 * Real Time signals may be queued.
27 struct list_head list;
30 struct user_struct *user;
34 #define SIGQUEUE_PREALLOC 1
37 struct list_head list;
42 * Define some primitives to manipulate sigset_t.
45 #ifndef __HAVE_ARCH_SIG_BITOPS
46 #include <linux/bitops.h>
48 /* We don't use <linux/bitops.h> for these because there is no need to
50 static inline void sigaddset(sigset_t *set, int _sig)
52 unsigned long sig = _sig - 1;
54 set->sig[0] |= 1UL << sig;
56 set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW);
59 static inline void sigdelset(sigset_t *set, int _sig)
61 unsigned long sig = _sig - 1;
63 set->sig[0] &= ~(1UL << sig);
65 set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW));
68 static inline int sigismember(sigset_t *set, int _sig)
70 unsigned long sig = _sig - 1;
72 return 1 & (set->sig[0] >> sig);
74 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
77 static inline int sigfindinword(unsigned long word)
82 #endif /* __HAVE_ARCH_SIG_BITOPS */
84 #define sigmask(sig) (1UL << ((sig) - 1))
86 #ifndef __HAVE_ARCH_SIG_SETOPS
87 #include <linux/string.h>
89 #define _SIG_SET_BINOP(name, op) \
90 static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
92 extern void _NSIG_WORDS_is_unsupported_size(void); \
93 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
95 switch (_NSIG_WORDS) { \
97 a3 = a->sig[3]; a2 = a->sig[2]; \
98 b3 = b->sig[3]; b2 = b->sig[2]; \
99 r->sig[3] = op(a3, b3); \
100 r->sig[2] = op(a2, b2); \
102 a1 = a->sig[1]; b1 = b->sig[1]; \
103 r->sig[1] = op(a1, b1); \
105 a0 = a->sig[0]; b0 = b->sig[0]; \
106 r->sig[0] = op(a0, b0); \
109 _NSIG_WORDS_is_unsupported_size(); \
113 #define _sig_or(x,y) ((x) | (y))
114 _SIG_SET_BINOP(sigorsets, _sig_or)
116 #define _sig_and(x,y) ((x) & (y))
117 _SIG_SET_BINOP(sigandsets, _sig_and)
119 #define _sig_nand(x,y) ((x) & ~(y))
120 _SIG_SET_BINOP(signandsets, _sig_nand)
122 #undef _SIG_SET_BINOP
127 #define _SIG_SET_OP(name, op) \
128 static inline void name(sigset_t *set) \
130 extern void _NSIG_WORDS_is_unsupported_size(void); \
132 switch (_NSIG_WORDS) { \
133 case 4: set->sig[3] = op(set->sig[3]); \
134 set->sig[2] = op(set->sig[2]); \
135 case 2: set->sig[1] = op(set->sig[1]); \
136 case 1: set->sig[0] = op(set->sig[0]); \
139 _NSIG_WORDS_is_unsupported_size(); \
143 #define _sig_not(x) (~(x))
144 _SIG_SET_OP(signotset, _sig_not)
149 static inline void sigemptyset(sigset_t *set)
151 switch (_NSIG_WORDS) {
153 memset(set, 0, sizeof(sigset_t));
155 case 2: set->sig[1] = 0;
156 case 1: set->sig[0] = 0;
161 static inline void sigfillset(sigset_t *set)
163 switch (_NSIG_WORDS) {
165 memset(set, -1, sizeof(sigset_t));
167 case 2: set->sig[1] = -1;
168 case 1: set->sig[0] = -1;
173 /* Some extensions for manipulating the low 32 signals in particular. */
175 static inline void sigaddsetmask(sigset_t *set, unsigned long mask)
180 static inline void sigdelsetmask(sigset_t *set, unsigned long mask)
182 set->sig[0] &= ~mask;
185 static inline int sigtestsetmask(sigset_t *set, unsigned long mask)
187 return (set->sig[0] & mask) != 0;
190 static inline void siginitset(sigset_t *set, unsigned long mask)
193 switch (_NSIG_WORDS) {
195 memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1));
197 case 2: set->sig[1] = 0;
202 static inline void siginitsetinv(sigset_t *set, unsigned long mask)
205 switch (_NSIG_WORDS) {
207 memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
209 case 2: set->sig[1] = -1;
214 #endif /* __HAVE_ARCH_SIG_SETOPS */
216 static inline void init_sigpending(struct sigpending *sig)
218 sigemptyset(&sig->signal);
219 INIT_LIST_HEAD(&sig->list);
222 /* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
223 static inline int valid_signal(unsigned long sig)
225 return sig <= _NSIG ? 1 : 0;
228 extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
229 extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
230 extern long do_sigpending(void __user *, unsigned long);
231 extern int sigprocmask(int, sigset_t *, sigset_t *);
234 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
236 #endif /* __KERNEL__ */
238 #endif /* _LINUX_SIGNAL_H */