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
22 * As above, these correspond to the IORESOURCE_IRQ_* defines in
23 * linux/ioport.h to select the interrupt line behaviour. When
24 * requesting an interrupt without specifying a SA_TRIGGER, the
25 * setting should be assumed to be "as already configured", which
26 * may be as per machine or firmware initialisation.
28 #define SA_TRIGGER_LOW 0x00000008
29 #define SA_TRIGGER_HIGH 0x00000004
30 #define SA_TRIGGER_FALLING 0x00000002
31 #define SA_TRIGGER_RISING 0x00000001
32 #define SA_TRIGGER_MASK (SA_TRIGGER_HIGH|SA_TRIGGER_LOW|\
33 SA_TRIGGER_RISING|SA_TRIGGER_FALLING)
36 * Real Time signals may be queued.
40 struct list_head list;
43 struct user_struct *user;
47 #define SIGQUEUE_PREALLOC 1
50 struct list_head list;
55 * Define some primitives to manipulate sigset_t.
58 #ifndef __HAVE_ARCH_SIG_BITOPS
59 #include <linux/bitops.h>
61 /* We don't use <linux/bitops.h> for these because there is no need to
63 static inline void sigaddset(sigset_t *set, int _sig)
65 unsigned long sig = _sig - 1;
67 set->sig[0] |= 1UL << sig;
69 set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW);
72 static inline void sigdelset(sigset_t *set, int _sig)
74 unsigned long sig = _sig - 1;
76 set->sig[0] &= ~(1UL << sig);
78 set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW));
81 static inline int sigismember(sigset_t *set, int _sig)
83 unsigned long sig = _sig - 1;
85 return 1 & (set->sig[0] >> sig);
87 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
90 static inline int sigfindinword(unsigned long word)
95 #endif /* __HAVE_ARCH_SIG_BITOPS */
97 #define sigmask(sig) (1UL << ((sig) - 1))
99 #ifndef __HAVE_ARCH_SIG_SETOPS
100 #include <linux/string.h>
102 #define _SIG_SET_BINOP(name, op) \
103 static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
105 extern void _NSIG_WORDS_is_unsupported_size(void); \
106 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
108 switch (_NSIG_WORDS) { \
110 a3 = a->sig[3]; a2 = a->sig[2]; \
111 b3 = b->sig[3]; b2 = b->sig[2]; \
112 r->sig[3] = op(a3, b3); \
113 r->sig[2] = op(a2, b2); \
115 a1 = a->sig[1]; b1 = b->sig[1]; \
116 r->sig[1] = op(a1, b1); \
118 a0 = a->sig[0]; b0 = b->sig[0]; \
119 r->sig[0] = op(a0, b0); \
122 _NSIG_WORDS_is_unsupported_size(); \
126 #define _sig_or(x,y) ((x) | (y))
127 _SIG_SET_BINOP(sigorsets, _sig_or)
129 #define _sig_and(x,y) ((x) & (y))
130 _SIG_SET_BINOP(sigandsets, _sig_and)
132 #define _sig_nand(x,y) ((x) & ~(y))
133 _SIG_SET_BINOP(signandsets, _sig_nand)
135 #undef _SIG_SET_BINOP
140 #define _SIG_SET_OP(name, op) \
141 static inline void name(sigset_t *set) \
143 extern void _NSIG_WORDS_is_unsupported_size(void); \
145 switch (_NSIG_WORDS) { \
146 case 4: set->sig[3] = op(set->sig[3]); \
147 set->sig[2] = op(set->sig[2]); \
148 case 2: set->sig[1] = op(set->sig[1]); \
149 case 1: set->sig[0] = op(set->sig[0]); \
152 _NSIG_WORDS_is_unsupported_size(); \
156 #define _sig_not(x) (~(x))
157 _SIG_SET_OP(signotset, _sig_not)
162 static inline void sigemptyset(sigset_t *set)
164 switch (_NSIG_WORDS) {
166 memset(set, 0, sizeof(sigset_t));
168 case 2: set->sig[1] = 0;
169 case 1: set->sig[0] = 0;
174 static inline void sigfillset(sigset_t *set)
176 switch (_NSIG_WORDS) {
178 memset(set, -1, sizeof(sigset_t));
180 case 2: set->sig[1] = -1;
181 case 1: set->sig[0] = -1;
186 /* Some extensions for manipulating the low 32 signals in particular. */
188 static inline void sigaddsetmask(sigset_t *set, unsigned long mask)
193 static inline void sigdelsetmask(sigset_t *set, unsigned long mask)
195 set->sig[0] &= ~mask;
198 static inline int sigtestsetmask(sigset_t *set, unsigned long mask)
200 return (set->sig[0] & mask) != 0;
203 static inline void siginitset(sigset_t *set, unsigned long mask)
206 switch (_NSIG_WORDS) {
208 memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1));
210 case 2: set->sig[1] = 0;
215 static inline void siginitsetinv(sigset_t *set, unsigned long mask)
218 switch (_NSIG_WORDS) {
220 memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
222 case 2: set->sig[1] = -1;
227 #endif /* __HAVE_ARCH_SIG_SETOPS */
229 static inline void init_sigpending(struct sigpending *sig)
231 sigemptyset(&sig->signal);
232 INIT_LIST_HEAD(&sig->list);
235 /* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
236 static inline int valid_signal(unsigned long sig)
238 return sig <= _NSIG ? 1 : 0;
241 extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
242 extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
243 extern long do_sigpending(void __user *, unsigned long);
244 extern int sigprocmask(int, sigset_t *, sigset_t *);
247 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
249 #endif /* __KERNEL__ */
251 #endif /* _LINUX_SIGNAL_H */