aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/signal.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/signal.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/linux/signal.h')
-rw-r--r--include/linux/signal.h224
1 files changed, 224 insertions, 0 deletions
diff --git a/include/linux/signal.h b/include/linux/signal.h
new file mode 100644
index 000000000000..99c97ad026c8
--- /dev/null
+++ b/include/linux/signal.h
@@ -0,0 +1,224 @@
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 * Real Time signals may be queued.
13 */
14
15struct sigqueue {
16 struct list_head list;
17 spinlock_t *lock;
18 int flags;
19 siginfo_t info;
20 struct user_struct *user;
21};
22
23/* flags values. */
24#define SIGQUEUE_PREALLOC 1
25
26struct sigpending {
27 struct list_head list;
28 sigset_t signal;
29};
30
31/*
32 * Define some primitives to manipulate sigset_t.
33 */
34
35#ifndef __HAVE_ARCH_SIG_BITOPS
36#include <linux/bitops.h>
37
38/* We don't use <linux/bitops.h> for these because there is no need to
39 be atomic. */
40static inline void sigaddset(sigset_t *set, int _sig)
41{
42 unsigned long sig = _sig - 1;
43 if (_NSIG_WORDS == 1)
44 set->sig[0] |= 1UL << sig;
45 else
46 set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW);
47}
48
49static inline void sigdelset(sigset_t *set, int _sig)
50{
51 unsigned long sig = _sig - 1;
52 if (_NSIG_WORDS == 1)
53 set->sig[0] &= ~(1UL << sig);
54 else
55 set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW));
56}
57
58static inline int sigismember(sigset_t *set, int _sig)
59{
60 unsigned long sig = _sig - 1;
61 if (_NSIG_WORDS == 1)
62 return 1 & (set->sig[0] >> sig);
63 else
64 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
65}
66
67static inline int sigfindinword(unsigned long word)
68{
69 return ffz(~word);
70}
71
72#endif /* __HAVE_ARCH_SIG_BITOPS */
73
74#define sigmask(sig) (1UL << ((sig) - 1))
75
76#ifndef __HAVE_ARCH_SIG_SETOPS
77#include <linux/string.h>
78
79#define _SIG_SET_BINOP(name, op) \
80static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
81{ \
82 extern void _NSIG_WORDS_is_unsupported_size(void); \
83 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
84 \
85 switch (_NSIG_WORDS) { \
86 case 4: \
87 a3 = a->sig[3]; a2 = a->sig[2]; \
88 b3 = b->sig[3]; b2 = b->sig[2]; \
89 r->sig[3] = op(a3, b3); \
90 r->sig[2] = op(a2, b2); \
91 case 2: \
92 a1 = a->sig[1]; b1 = b->sig[1]; \
93 r->sig[1] = op(a1, b1); \
94 case 1: \
95 a0 = a->sig[0]; b0 = b->sig[0]; \
96 r->sig[0] = op(a0, b0); \
97 break; \
98 default: \
99 _NSIG_WORDS_is_unsupported_size(); \
100 } \
101}
102
103#define _sig_or(x,y) ((x) | (y))
104_SIG_SET_BINOP(sigorsets, _sig_or)
105
106#define _sig_and(x,y) ((x) & (y))
107_SIG_SET_BINOP(sigandsets, _sig_and)
108
109#define _sig_nand(x,y) ((x) & ~(y))
110_SIG_SET_BINOP(signandsets, _sig_nand)
111
112#undef _SIG_SET_BINOP
113#undef _sig_or
114#undef _sig_and
115#undef _sig_nand
116
117#define _SIG_SET_OP(name, op) \
118static inline void name(sigset_t *set) \
119{ \
120 extern void _NSIG_WORDS_is_unsupported_size(void); \
121 \
122 switch (_NSIG_WORDS) { \
123 case 4: set->sig[3] = op(set->sig[3]); \
124 set->sig[2] = op(set->sig[2]); \
125 case 2: set->sig[1] = op(set->sig[1]); \
126 case 1: set->sig[0] = op(set->sig[0]); \
127 break; \
128 default: \
129 _NSIG_WORDS_is_unsupported_size(); \
130 } \
131}
132
133#define _sig_not(x) (~(x))
134_SIG_SET_OP(signotset, _sig_not)
135
136#undef _SIG_SET_OP
137#undef _sig_not
138
139static inline void sigemptyset(sigset_t *set)
140{
141 switch (_NSIG_WORDS) {
142 default:
143 memset(set, 0, sizeof(sigset_t));
144 break;
145 case 2: set->sig[1] = 0;
146 case 1: set->sig[0] = 0;
147 break;
148 }
149}
150
151static inline void sigfillset(sigset_t *set)
152{
153 switch (_NSIG_WORDS) {
154 default:
155 memset(set, -1, sizeof(sigset_t));
156 break;
157 case 2: set->sig[1] = -1;
158 case 1: set->sig[0] = -1;
159 break;
160 }
161}
162
163/* Some extensions for manipulating the low 32 signals in particular. */
164
165static inline void sigaddsetmask(sigset_t *set, unsigned long mask)
166{
167 set->sig[0] |= mask;
168}
169
170static inline void sigdelsetmask(sigset_t *set, unsigned long mask)
171{
172 set->sig[0] &= ~mask;
173}
174
175static inline int sigtestsetmask(sigset_t *set, unsigned long mask)
176{
177 return (set->sig[0] & mask) != 0;
178}
179
180static inline void siginitset(sigset_t *set, unsigned long mask)
181{
182 set->sig[0] = mask;
183 switch (_NSIG_WORDS) {
184 default:
185 memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1));
186 break;
187 case 2: set->sig[1] = 0;
188 case 1: ;
189 }
190}
191
192static inline void siginitsetinv(sigset_t *set, unsigned long mask)
193{
194 set->sig[0] = ~mask;
195 switch (_NSIG_WORDS) {
196 default:
197 memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
198 break;
199 case 2: set->sig[1] = -1;
200 case 1: ;
201 }
202}
203
204#endif /* __HAVE_ARCH_SIG_SETOPS */
205
206static inline void init_sigpending(struct sigpending *sig)
207{
208 sigemptyset(&sig->signal);
209 INIT_LIST_HEAD(&sig->list);
210}
211
212extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
213extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
214extern long do_sigpending(void __user *, unsigned long);
215extern int sigprocmask(int, sigset_t *, sigset_t *);
216
217#ifndef HAVE_ARCH_GET_SIGNAL_TO_DELIVER
218struct pt_regs;
219extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
220#endif
221
222#endif /* __KERNEL__ */
223
224#endif /* _LINUX_SIGNAL_H */