[GFS2] Update ioctl() to new interface
[deliverable/linux.git] / include / linux / signal.h
1 #ifndef _LINUX_SIGNAL_H
2 #define _LINUX_SIGNAL_H
3
4 #include <linux/list.h>
5 #include <linux/spinlock.h>
6 #include <asm/signal.h>
7 #include <asm/siginfo.h>
8
9 #ifdef __KERNEL__
10
11 /*
12 * These values of sa_flags are used only by the kernel as part of the
13 * irq handling routines.
14 *
15 * SA_INTERRUPT is also used by the irq handling routines.
16 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
17 */
18 #define SA_PROBE SA_ONESHOT
19 #define SA_SAMPLE_RANDOM SA_RESTART
20 #define SA_SHIRQ 0x04000000
21 /*
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.
27 */
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)
34
35 /*
36 * Real Time signals may be queued.
37 */
38
39 struct sigqueue {
40 struct list_head list;
41 int flags;
42 siginfo_t info;
43 struct user_struct *user;
44 };
45
46 /* flags values. */
47 #define SIGQUEUE_PREALLOC 1
48
49 struct sigpending {
50 struct list_head list;
51 sigset_t signal;
52 };
53
54 /*
55 * Define some primitives to manipulate sigset_t.
56 */
57
58 #ifndef __HAVE_ARCH_SIG_BITOPS
59 #include <linux/bitops.h>
60
61 /* We don't use <linux/bitops.h> for these because there is no need to
62 be atomic. */
63 static inline void sigaddset(sigset_t *set, int _sig)
64 {
65 unsigned long sig = _sig - 1;
66 if (_NSIG_WORDS == 1)
67 set->sig[0] |= 1UL << sig;
68 else
69 set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW);
70 }
71
72 static inline void sigdelset(sigset_t *set, int _sig)
73 {
74 unsigned long sig = _sig - 1;
75 if (_NSIG_WORDS == 1)
76 set->sig[0] &= ~(1UL << sig);
77 else
78 set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW));
79 }
80
81 static inline int sigismember(sigset_t *set, int _sig)
82 {
83 unsigned long sig = _sig - 1;
84 if (_NSIG_WORDS == 1)
85 return 1 & (set->sig[0] >> sig);
86 else
87 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
88 }
89
90 static inline int sigfindinword(unsigned long word)
91 {
92 return ffz(~word);
93 }
94
95 #endif /* __HAVE_ARCH_SIG_BITOPS */
96
97 static inline int sigisemptyset(sigset_t *set)
98 {
99 extern void _NSIG_WORDS_is_unsupported_size(void);
100 switch (_NSIG_WORDS) {
101 case 4:
102 return (set->sig[3] | set->sig[2] |
103 set->sig[1] | set->sig[0]) == 0;
104 case 2:
105 return (set->sig[1] | set->sig[0]) == 0;
106 case 1:
107 return set->sig[0] == 0;
108 default:
109 _NSIG_WORDS_is_unsupported_size();
110 return 0;
111 }
112 }
113
114 #define sigmask(sig) (1UL << ((sig) - 1))
115
116 #ifndef __HAVE_ARCH_SIG_SETOPS
117 #include <linux/string.h>
118
119 #define _SIG_SET_BINOP(name, op) \
120 static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
121 { \
122 extern void _NSIG_WORDS_is_unsupported_size(void); \
123 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
124 \
125 switch (_NSIG_WORDS) { \
126 case 4: \
127 a3 = a->sig[3]; a2 = a->sig[2]; \
128 b3 = b->sig[3]; b2 = b->sig[2]; \
129 r->sig[3] = op(a3, b3); \
130 r->sig[2] = op(a2, b2); \
131 case 2: \
132 a1 = a->sig[1]; b1 = b->sig[1]; \
133 r->sig[1] = op(a1, b1); \
134 case 1: \
135 a0 = a->sig[0]; b0 = b->sig[0]; \
136 r->sig[0] = op(a0, b0); \
137 break; \
138 default: \
139 _NSIG_WORDS_is_unsupported_size(); \
140 } \
141 }
142
143 #define _sig_or(x,y) ((x) | (y))
144 _SIG_SET_BINOP(sigorsets, _sig_or)
145
146 #define _sig_and(x,y) ((x) & (y))
147 _SIG_SET_BINOP(sigandsets, _sig_and)
148
149 #define _sig_nand(x,y) ((x) & ~(y))
150 _SIG_SET_BINOP(signandsets, _sig_nand)
151
152 #undef _SIG_SET_BINOP
153 #undef _sig_or
154 #undef _sig_and
155 #undef _sig_nand
156
157 #define _SIG_SET_OP(name, op) \
158 static inline void name(sigset_t *set) \
159 { \
160 extern void _NSIG_WORDS_is_unsupported_size(void); \
161 \
162 switch (_NSIG_WORDS) { \
163 case 4: set->sig[3] = op(set->sig[3]); \
164 set->sig[2] = op(set->sig[2]); \
165 case 2: set->sig[1] = op(set->sig[1]); \
166 case 1: set->sig[0] = op(set->sig[0]); \
167 break; \
168 default: \
169 _NSIG_WORDS_is_unsupported_size(); \
170 } \
171 }
172
173 #define _sig_not(x) (~(x))
174 _SIG_SET_OP(signotset, _sig_not)
175
176 #undef _SIG_SET_OP
177 #undef _sig_not
178
179 static inline void sigemptyset(sigset_t *set)
180 {
181 switch (_NSIG_WORDS) {
182 default:
183 memset(set, 0, sizeof(sigset_t));
184 break;
185 case 2: set->sig[1] = 0;
186 case 1: set->sig[0] = 0;
187 break;
188 }
189 }
190
191 static inline void sigfillset(sigset_t *set)
192 {
193 switch (_NSIG_WORDS) {
194 default:
195 memset(set, -1, sizeof(sigset_t));
196 break;
197 case 2: set->sig[1] = -1;
198 case 1: set->sig[0] = -1;
199 break;
200 }
201 }
202
203 /* Some extensions for manipulating the low 32 signals in particular. */
204
205 static inline void sigaddsetmask(sigset_t *set, unsigned long mask)
206 {
207 set->sig[0] |= mask;
208 }
209
210 static inline void sigdelsetmask(sigset_t *set, unsigned long mask)
211 {
212 set->sig[0] &= ~mask;
213 }
214
215 static inline int sigtestsetmask(sigset_t *set, unsigned long mask)
216 {
217 return (set->sig[0] & mask) != 0;
218 }
219
220 static inline void siginitset(sigset_t *set, unsigned long mask)
221 {
222 set->sig[0] = mask;
223 switch (_NSIG_WORDS) {
224 default:
225 memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1));
226 break;
227 case 2: set->sig[1] = 0;
228 case 1: ;
229 }
230 }
231
232 static inline void siginitsetinv(sigset_t *set, unsigned long mask)
233 {
234 set->sig[0] = ~mask;
235 switch (_NSIG_WORDS) {
236 default:
237 memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
238 break;
239 case 2: set->sig[1] = -1;
240 case 1: ;
241 }
242 }
243
244 #endif /* __HAVE_ARCH_SIG_SETOPS */
245
246 static inline void init_sigpending(struct sigpending *sig)
247 {
248 sigemptyset(&sig->signal);
249 INIT_LIST_HEAD(&sig->list);
250 }
251
252 /* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
253 static inline int valid_signal(unsigned long sig)
254 {
255 return sig <= _NSIG ? 1 : 0;
256 }
257
258 extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
259 extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
260 extern long do_sigpending(void __user *, unsigned long);
261 extern int sigprocmask(int, sigset_t *, sigset_t *);
262
263 struct pt_regs;
264 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
265
266 #endif /* __KERNEL__ */
267
268 #endif /* _LINUX_SIGNAL_H */
This page took 0.039792 seconds and 5 git commands to generate.