]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
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 | ||
7f261b5f SS |
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 | ||
1da177e4 LT |
22 | /* |
23 | * Real Time signals may be queued. | |
24 | */ | |
25 | ||
26 | struct sigqueue { | |
27 | struct list_head list; | |
28 | spinlock_t *lock; | |
29 | int flags; | |
30 | siginfo_t info; | |
31 | struct user_struct *user; | |
32 | }; | |
33 | ||
34 | /* flags values. */ | |
35 | #define SIGQUEUE_PREALLOC 1 | |
36 | ||
37 | struct sigpending { | |
38 | struct list_head list; | |
39 | sigset_t signal; | |
40 | }; | |
41 | ||
42 | /* | |
43 | * Define some primitives to manipulate sigset_t. | |
44 | */ | |
45 | ||
46 | #ifndef __HAVE_ARCH_SIG_BITOPS | |
47 | #include <linux/bitops.h> | |
48 | ||
49 | /* We don't use <linux/bitops.h> for these because there is no need to | |
50 | be atomic. */ | |
51 | static inline void sigaddset(sigset_t *set, int _sig) | |
52 | { | |
53 | unsigned long sig = _sig - 1; | |
54 | if (_NSIG_WORDS == 1) | |
55 | set->sig[0] |= 1UL << sig; | |
56 | else | |
57 | set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW); | |
58 | } | |
59 | ||
60 | static inline void sigdelset(sigset_t *set, int _sig) | |
61 | { | |
62 | unsigned long sig = _sig - 1; | |
63 | if (_NSIG_WORDS == 1) | |
64 | set->sig[0] &= ~(1UL << sig); | |
65 | else | |
66 | set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW)); | |
67 | } | |
68 | ||
69 | static inline int sigismember(sigset_t *set, int _sig) | |
70 | { | |
71 | unsigned long sig = _sig - 1; | |
72 | if (_NSIG_WORDS == 1) | |
73 | return 1 & (set->sig[0] >> sig); | |
74 | else | |
75 | return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); | |
76 | } | |
77 | ||
78 | static inline int sigfindinword(unsigned long word) | |
79 | { | |
80 | return ffz(~word); | |
81 | } | |
82 | ||
83 | #endif /* __HAVE_ARCH_SIG_BITOPS */ | |
84 | ||
85 | #define sigmask(sig) (1UL << ((sig) - 1)) | |
86 | ||
87 | #ifndef __HAVE_ARCH_SIG_SETOPS | |
88 | #include <linux/string.h> | |
89 | ||
90 | #define _SIG_SET_BINOP(name, op) \ | |
91 | static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \ | |
92 | { \ | |
93 | extern void _NSIG_WORDS_is_unsupported_size(void); \ | |
94 | unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \ | |
95 | \ | |
96 | switch (_NSIG_WORDS) { \ | |
97 | case 4: \ | |
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); \ | |
102 | case 2: \ | |
103 | a1 = a->sig[1]; b1 = b->sig[1]; \ | |
104 | r->sig[1] = op(a1, b1); \ | |
105 | case 1: \ | |
106 | a0 = a->sig[0]; b0 = b->sig[0]; \ | |
107 | r->sig[0] = op(a0, b0); \ | |
108 | break; \ | |
109 | default: \ | |
110 | _NSIG_WORDS_is_unsupported_size(); \ | |
111 | } \ | |
112 | } | |
113 | ||
114 | #define _sig_or(x,y) ((x) | (y)) | |
115 | _SIG_SET_BINOP(sigorsets, _sig_or) | |
116 | ||
117 | #define _sig_and(x,y) ((x) & (y)) | |
118 | _SIG_SET_BINOP(sigandsets, _sig_and) | |
119 | ||
120 | #define _sig_nand(x,y) ((x) & ~(y)) | |
121 | _SIG_SET_BINOP(signandsets, _sig_nand) | |
122 | ||
123 | #undef _SIG_SET_BINOP | |
124 | #undef _sig_or | |
125 | #undef _sig_and | |
126 | #undef _sig_nand | |
127 | ||
128 | #define _SIG_SET_OP(name, op) \ | |
129 | static inline void name(sigset_t *set) \ | |
130 | { \ | |
131 | extern void _NSIG_WORDS_is_unsupported_size(void); \ | |
132 | \ | |
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]); \ | |
138 | break; \ | |
139 | default: \ | |
140 | _NSIG_WORDS_is_unsupported_size(); \ | |
141 | } \ | |
142 | } | |
143 | ||
144 | #define _sig_not(x) (~(x)) | |
145 | _SIG_SET_OP(signotset, _sig_not) | |
146 | ||
147 | #undef _SIG_SET_OP | |
148 | #undef _sig_not | |
149 | ||
150 | static inline void sigemptyset(sigset_t *set) | |
151 | { | |
152 | switch (_NSIG_WORDS) { | |
153 | default: | |
154 | memset(set, 0, sizeof(sigset_t)); | |
155 | break; | |
156 | case 2: set->sig[1] = 0; | |
157 | case 1: set->sig[0] = 0; | |
158 | break; | |
159 | } | |
160 | } | |
161 | ||
162 | static inline void sigfillset(sigset_t *set) | |
163 | { | |
164 | switch (_NSIG_WORDS) { | |
165 | default: | |
166 | memset(set, -1, sizeof(sigset_t)); | |
167 | break; | |
168 | case 2: set->sig[1] = -1; | |
169 | case 1: set->sig[0] = -1; | |
170 | break; | |
171 | } | |
172 | } | |
173 | ||
174 | /* Some extensions for manipulating the low 32 signals in particular. */ | |
175 | ||
176 | static inline void sigaddsetmask(sigset_t *set, unsigned long mask) | |
177 | { | |
178 | set->sig[0] |= mask; | |
179 | } | |
180 | ||
181 | static inline void sigdelsetmask(sigset_t *set, unsigned long mask) | |
182 | { | |
183 | set->sig[0] &= ~mask; | |
184 | } | |
185 | ||
186 | static inline int sigtestsetmask(sigset_t *set, unsigned long mask) | |
187 | { | |
188 | return (set->sig[0] & mask) != 0; | |
189 | } | |
190 | ||
191 | static inline void siginitset(sigset_t *set, unsigned long mask) | |
192 | { | |
193 | set->sig[0] = mask; | |
194 | switch (_NSIG_WORDS) { | |
195 | default: | |
196 | memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1)); | |
197 | break; | |
198 | case 2: set->sig[1] = 0; | |
199 | case 1: ; | |
200 | } | |
201 | } | |
202 | ||
203 | static inline void siginitsetinv(sigset_t *set, unsigned long mask) | |
204 | { | |
205 | set->sig[0] = ~mask; | |
206 | switch (_NSIG_WORDS) { | |
207 | default: | |
208 | memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1)); | |
209 | break; | |
210 | case 2: set->sig[1] = -1; | |
211 | case 1: ; | |
212 | } | |
213 | } | |
214 | ||
215 | #endif /* __HAVE_ARCH_SIG_SETOPS */ | |
216 | ||
217 | static inline void init_sigpending(struct sigpending *sig) | |
218 | { | |
219 | sigemptyset(&sig->signal); | |
220 | INIT_LIST_HEAD(&sig->list); | |
221 | } | |
222 | ||
223 | extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p); | |
224 | extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *); | |
225 | extern long do_sigpending(void __user *, unsigned long); | |
226 | extern int sigprocmask(int, sigset_t *, sigset_t *); | |
227 | ||
228 | #ifndef HAVE_ARCH_GET_SIGNAL_TO_DELIVER | |
229 | struct pt_regs; | |
230 | extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie); | |
231 | #endif | |
232 | ||
233 | #endif /* __KERNEL__ */ | |
234 | ||
235 | #endif /* _LINUX_SIGNAL_H */ |