Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / signal.h
blob99c97ad026c839d81ecaa0f1a65a15e9d88a1a34
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>
9 #ifdef __KERNEL__
12 * Real Time signals may be queued.
15 struct sigqueue {
16 struct list_head list;
17 spinlock_t *lock;
18 int flags;
19 siginfo_t info;
20 struct user_struct *user;
23 /* flags values. */
24 #define SIGQUEUE_PREALLOC 1
26 struct sigpending {
27 struct list_head list;
28 sigset_t signal;
32 * Define some primitives to manipulate sigset_t.
35 #ifndef __HAVE_ARCH_SIG_BITOPS
36 #include <linux/bitops.h>
38 /* We don't use <linux/bitops.h> for these because there is no need to
39 be atomic. */
40 static inline void sigaddset(sigset_t *set, int _sig)
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);
49 static inline void sigdelset(sigset_t *set, int _sig)
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));
58 static inline int sigismember(sigset_t *set, int _sig)
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));
67 static inline int sigfindinword(unsigned long word)
69 return ffz(~word);
72 #endif /* __HAVE_ARCH_SIG_BITOPS */
74 #define sigmask(sig) (1UL << ((sig) - 1))
76 #ifndef __HAVE_ARCH_SIG_SETOPS
77 #include <linux/string.h>
79 #define _SIG_SET_BINOP(name, op) \
80 static 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; \
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(); \
103 #define _sig_or(x,y) ((x) | (y))
104 _SIG_SET_BINOP(sigorsets, _sig_or)
106 #define _sig_and(x,y) ((x) & (y))
107 _SIG_SET_BINOP(sigandsets, _sig_and)
109 #define _sig_nand(x,y) ((x) & ~(y))
110 _SIG_SET_BINOP(signandsets, _sig_nand)
112 #undef _SIG_SET_BINOP
113 #undef _sig_or
114 #undef _sig_and
115 #undef _sig_nand
117 #define _SIG_SET_OP(name, op) \
118 static inline void name(sigset_t *set) \
120 extern void _NSIG_WORDS_is_unsupported_size(void); \
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(); \
133 #define _sig_not(x) (~(x))
134 _SIG_SET_OP(signotset, _sig_not)
136 #undef _SIG_SET_OP
137 #undef _sig_not
139 static inline void sigemptyset(sigset_t *set)
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;
151 static inline void sigfillset(sigset_t *set)
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;
163 /* Some extensions for manipulating the low 32 signals in particular. */
165 static inline void sigaddsetmask(sigset_t *set, unsigned long mask)
167 set->sig[0] |= mask;
170 static inline void sigdelsetmask(sigset_t *set, unsigned long mask)
172 set->sig[0] &= ~mask;
175 static inline int sigtestsetmask(sigset_t *set, unsigned long mask)
177 return (set->sig[0] & mask) != 0;
180 static inline void siginitset(sigset_t *set, unsigned long mask)
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: ;
192 static inline void siginitsetinv(sigset_t *set, unsigned long mask)
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: ;
204 #endif /* __HAVE_ARCH_SIG_SETOPS */
206 static inline void init_sigpending(struct sigpending *sig)
208 sigemptyset(&sig->signal);
209 INIT_LIST_HEAD(&sig->list);
212 extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
213 extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
214 extern long do_sigpending(void __user *, unsigned long);
215 extern int sigprocmask(int, sigset_t *, sigset_t *);
217 #ifndef HAVE_ARCH_GET_SIGNAL_TO_DELIVER
218 struct pt_regs;
219 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
220 #endif
222 #endif /* __KERNEL__ */
224 #endif /* _LINUX_SIGNAL_H */