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;
31 struct user_struct *user;
35 #define SIGQUEUE_PREALLOC 1
38 struct list_head list;
43 * Define some primitives to manipulate sigset_t.
46 #ifndef __HAVE_ARCH_SIG_BITOPS
47 #include <linux/bitops.h>
49 /* We don't use <linux/bitops.h> for these because there is no need to
51 static inline void sigaddset(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 void sigdelset(sigset_t *set, int _sig)
62 unsigned long sig = _sig - 1;
64 set->sig[0] &= ~(1UL << sig);
66 set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW));
69 static inline int sigismember(sigset_t *set, int _sig)
71 unsigned long sig = _sig - 1;
73 return 1 & (set->sig[0] >> sig);
75 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
78 static inline int sigfindinword(unsigned long word)
83 #endif /* __HAVE_ARCH_SIG_BITOPS */
85 #define sigmask(sig) (1UL << ((sig) - 1))
87 #ifndef __HAVE_ARCH_SIG_SETOPS
88 #include <linux/string.h>
90 #define _SIG_SET_BINOP(name, op) \
91 static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
93 extern void _NSIG_WORDS_is_unsupported_size(void); \
94 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
96 switch (_NSIG_WORDS) { \
98 a3 = a->sig[3]; a2 = a->sig[2]; \
99 b3 = b->sig[3]; b2 = b->sig[2]; \
100 r->sig[3] = op(a3, b3); \
101 r->sig[2] = op(a2, b2); \
103 a1 = a->sig[1]; b1 = b->sig[1]; \
104 r->sig[1] = op(a1, b1); \
106 a0 = a->sig[0]; b0 = b->sig[0]; \
107 r->sig[0] = op(a0, b0); \
110 _NSIG_WORDS_is_unsupported_size(); \
114 #define _sig_or(x,y) ((x) | (y))
115 _SIG_SET_BINOP(sigorsets, _sig_or)
117 #define _sig_and(x,y) ((x) & (y))
118 _SIG_SET_BINOP(sigandsets, _sig_and)
120 #define _sig_nand(x,y) ((x) & ~(y))
121 _SIG_SET_BINOP(signandsets, _sig_nand)
123 #undef _SIG_SET_BINOP
128 #define _SIG_SET_OP(name, op) \
129 static inline void name(sigset_t *set) \
131 extern void _NSIG_WORDS_is_unsupported_size(void); \
133 switch (_NSIG_WORDS) { \
134 case 4: set->sig[3] = op(set->sig[3]); \
135 set->sig[2] = op(set->sig[2]); \
136 case 2: set->sig[1] = op(set->sig[1]); \
137 case 1: set->sig[0] = op(set->sig[0]); \
140 _NSIG_WORDS_is_unsupported_size(); \
144 #define _sig_not(x) (~(x))
145 _SIG_SET_OP(signotset, _sig_not)
150 static inline void sigemptyset(sigset_t *set)
152 switch (_NSIG_WORDS) {
154 memset(set, 0, sizeof(sigset_t));
156 case 2: set->sig[1] = 0;
157 case 1: set->sig[0] = 0;
162 static inline void sigfillset(sigset_t *set)
164 switch (_NSIG_WORDS) {
166 memset(set, -1, sizeof(sigset_t));
168 case 2: set->sig[1] = -1;
169 case 1: set->sig[0] = -1;
174 /* Some extensions for manipulating the low 32 signals in particular. */
176 static inline void sigaddsetmask(sigset_t *set, unsigned long mask)
181 static inline void sigdelsetmask(sigset_t *set, unsigned long mask)
183 set->sig[0] &= ~mask;
186 static inline int sigtestsetmask(sigset_t *set, unsigned long mask)
188 return (set->sig[0] & mask) != 0;
191 static inline void siginitset(sigset_t *set, unsigned long mask)
194 switch (_NSIG_WORDS) {
196 memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1));
198 case 2: set->sig[1] = 0;
203 static inline void siginitsetinv(sigset_t *set, unsigned long mask)
206 switch (_NSIG_WORDS) {
208 memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
210 case 2: set->sig[1] = -1;
215 #endif /* __HAVE_ARCH_SIG_SETOPS */
217 static inline void init_sigpending(struct sigpending *sig)
219 sigemptyset(&sig->signal);
220 INIT_LIST_HEAD(&sig->list);
223 /* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
224 static inline int valid_signal(unsigned long sig)
226 return sig <= _NSIG ? 1 : 0;
229 extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
230 extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
231 extern long do_sigpending(void __user *, unsigned long);
232 extern int sigprocmask(int, sigset_t *, sigset_t *);
235 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
237 #endif /* __KERNEL__ */
239 #endif /* _LINUX_SIGNAL_H */