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.
17 * SA_PROBEIRQ is set by callers when they expect sharing mismatches to occur
19 #define SA_SAMPLE_RANDOM SA_RESTART
20 #define SA_SHIRQ 0x04000000
21 #define SA_PROBEIRQ 0x08000000
24 * As above, these correspond to the IORESOURCE_IRQ_* defines in
25 * linux/ioport.h to select the interrupt line behaviour. When
26 * requesting an interrupt without specifying a SA_TRIGGER, the
27 * setting should be assumed to be "as already configured", which
28 * may be as per machine or firmware initialisation.
30 #define SA_TRIGGER_LOW 0x00000008
31 #define SA_TRIGGER_HIGH 0x00000004
32 #define SA_TRIGGER_FALLING 0x00000002
33 #define SA_TRIGGER_RISING 0x00000001
34 #define SA_TRIGGER_MASK (SA_TRIGGER_HIGH|SA_TRIGGER_LOW|\
35 SA_TRIGGER_RISING|SA_TRIGGER_FALLING)
38 * Real Time signals may be queued.
42 struct list_head list;
45 struct user_struct *user;
49 #define SIGQUEUE_PREALLOC 1
52 struct list_head list;
57 * Define some primitives to manipulate sigset_t.
60 #ifndef __HAVE_ARCH_SIG_BITOPS
61 #include <linux/bitops.h>
63 /* We don't use <linux/bitops.h> for these because there is no need to
65 static inline void sigaddset(sigset_t *set, int _sig)
67 unsigned long sig = _sig - 1;
69 set->sig[0] |= 1UL << sig;
71 set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW);
74 static inline void sigdelset(sigset_t *set, int _sig)
76 unsigned long sig = _sig - 1;
78 set->sig[0] &= ~(1UL << sig);
80 set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW));
83 static inline int sigismember(sigset_t *set, int _sig)
85 unsigned long sig = _sig - 1;
87 return 1 & (set->sig[0] >> sig);
89 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
92 static inline int sigfindinword(unsigned long word)
97 #endif /* __HAVE_ARCH_SIG_BITOPS */
99 static inline int sigisemptyset(sigset_t *set)
101 extern void _NSIG_WORDS_is_unsupported_size(void);
102 switch (_NSIG_WORDS) {
104 return (set->sig[3] | set->sig[2] |
105 set->sig[1] | set->sig[0]) == 0;
107 return (set->sig[1] | set->sig[0]) == 0;
109 return set->sig[0] == 0;
111 _NSIG_WORDS_is_unsupported_size();
116 #define sigmask(sig) (1UL << ((sig) - 1))
118 #ifndef __HAVE_ARCH_SIG_SETOPS
119 #include <linux/string.h>
121 #define _SIG_SET_BINOP(name, op) \
122 static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
124 extern void _NSIG_WORDS_is_unsupported_size(void); \
125 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
127 switch (_NSIG_WORDS) { \
129 a3 = a->sig[3]; a2 = a->sig[2]; \
130 b3 = b->sig[3]; b2 = b->sig[2]; \
131 r->sig[3] = op(a3, b3); \
132 r->sig[2] = op(a2, b2); \
134 a1 = a->sig[1]; b1 = b->sig[1]; \
135 r->sig[1] = op(a1, b1); \
137 a0 = a->sig[0]; b0 = b->sig[0]; \
138 r->sig[0] = op(a0, b0); \
141 _NSIG_WORDS_is_unsupported_size(); \
145 #define _sig_or(x,y) ((x) | (y))
146 _SIG_SET_BINOP(sigorsets, _sig_or)
148 #define _sig_and(x,y) ((x) & (y))
149 _SIG_SET_BINOP(sigandsets, _sig_and)
151 #define _sig_nand(x,y) ((x) & ~(y))
152 _SIG_SET_BINOP(signandsets, _sig_nand)
154 #undef _SIG_SET_BINOP
159 #define _SIG_SET_OP(name, op) \
160 static inline void name(sigset_t *set) \
162 extern void _NSIG_WORDS_is_unsupported_size(void); \
164 switch (_NSIG_WORDS) { \
165 case 4: set->sig[3] = op(set->sig[3]); \
166 set->sig[2] = op(set->sig[2]); \
167 case 2: set->sig[1] = op(set->sig[1]); \
168 case 1: set->sig[0] = op(set->sig[0]); \
171 _NSIG_WORDS_is_unsupported_size(); \
175 #define _sig_not(x) (~(x))
176 _SIG_SET_OP(signotset, _sig_not)
181 static inline void sigemptyset(sigset_t *set)
183 switch (_NSIG_WORDS) {
185 memset(set, 0, sizeof(sigset_t));
187 case 2: set->sig[1] = 0;
188 case 1: set->sig[0] = 0;
193 static inline void sigfillset(sigset_t *set)
195 switch (_NSIG_WORDS) {
197 memset(set, -1, sizeof(sigset_t));
199 case 2: set->sig[1] = -1;
200 case 1: set->sig[0] = -1;
205 /* Some extensions for manipulating the low 32 signals in particular. */
207 static inline void sigaddsetmask(sigset_t *set, unsigned long mask)
212 static inline void sigdelsetmask(sigset_t *set, unsigned long mask)
214 set->sig[0] &= ~mask;
217 static inline int sigtestsetmask(sigset_t *set, unsigned long mask)
219 return (set->sig[0] & mask) != 0;
222 static inline void siginitset(sigset_t *set, unsigned long mask)
225 switch (_NSIG_WORDS) {
227 memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1));
229 case 2: set->sig[1] = 0;
234 static inline void siginitsetinv(sigset_t *set, unsigned long mask)
237 switch (_NSIG_WORDS) {
239 memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
241 case 2: set->sig[1] = -1;
246 #endif /* __HAVE_ARCH_SIG_SETOPS */
248 static inline void init_sigpending(struct sigpending *sig)
250 sigemptyset(&sig->signal);
251 INIT_LIST_HEAD(&sig->list);
254 extern void flush_sigqueue(struct sigpending *queue);
256 /* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
257 static inline int valid_signal(unsigned long sig)
259 return sig <= _NSIG ? 1 : 0;
262 extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
263 extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
264 extern long do_sigpending(void __user *, unsigned long);
265 extern int sigprocmask(int, sigset_t *, sigset_t *);
268 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
270 #endif /* __KERNEL__ */
272 #endif /* _LINUX_SIGNAL_H */