Automatic merge of rsync://rsync.kernel.org/pub/scm/linux/kernel/git/gregkh/driver...
[linux-2.6/verdex.git] / include / linux / signal.h
blob0a98f5ec5caed28fdfcaa91c183e7ef181534833
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 * 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.
18 #define SA_PROBE SA_ONESHOT
19 #define SA_SAMPLE_RANDOM SA_RESTART
20 #define SA_SHIRQ 0x04000000
23 * Real Time signals may be queued.
26 struct sigqueue {
27 struct list_head list;
28 spinlock_t *lock;
29 int flags;
30 siginfo_t info;
31 struct user_struct *user;
34 /* flags values. */
35 #define SIGQUEUE_PREALLOC 1
37 struct sigpending {
38 struct list_head list;
39 sigset_t signal;
43 * Define some primitives to manipulate sigset_t.
46 #ifndef __HAVE_ARCH_SIG_BITOPS
47 #include <linux/bitops.h>
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)
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);
60 static inline void sigdelset(sigset_t *set, int _sig)
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));
69 static inline int sigismember(sigset_t *set, int _sig)
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));
78 static inline int sigfindinword(unsigned long word)
80 return ffz(~word);
83 #endif /* __HAVE_ARCH_SIG_BITOPS */
85 #define sigmask(sig) (1UL << ((sig) - 1))
87 #ifndef __HAVE_ARCH_SIG_SETOPS
88 #include <linux/string.h>
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; \
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(); \
114 #define _sig_or(x,y) ((x) | (y))
115 _SIG_SET_BINOP(sigorsets, _sig_or)
117 #define _sig_and(x,y) ((x) & (y))
118 _SIG_SET_BINOP(sigandsets, _sig_and)
120 #define _sig_nand(x,y) ((x) & ~(y))
121 _SIG_SET_BINOP(signandsets, _sig_nand)
123 #undef _SIG_SET_BINOP
124 #undef _sig_or
125 #undef _sig_and
126 #undef _sig_nand
128 #define _SIG_SET_OP(name, op) \
129 static inline void name(sigset_t *set) \
131 extern void _NSIG_WORDS_is_unsupported_size(void); \
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(); \
144 #define _sig_not(x) (~(x))
145 _SIG_SET_OP(signotset, _sig_not)
147 #undef _SIG_SET_OP
148 #undef _sig_not
150 static inline void sigemptyset(sigset_t *set)
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;
162 static inline void sigfillset(sigset_t *set)
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;
174 /* Some extensions for manipulating the low 32 signals in particular. */
176 static inline void sigaddsetmask(sigset_t *set, unsigned long mask)
178 set->sig[0] |= mask;
181 static inline void sigdelsetmask(sigset_t *set, unsigned long mask)
183 set->sig[0] &= ~mask;
186 static inline int sigtestsetmask(sigset_t *set, unsigned long mask)
188 return (set->sig[0] & mask) != 0;
191 static inline void siginitset(sigset_t *set, unsigned long mask)
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: ;
203 static inline void siginitsetinv(sigset_t *set, unsigned long mask)
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: ;
215 #endif /* __HAVE_ARCH_SIG_SETOPS */
217 static inline void init_sigpending(struct sigpending *sig)
219 sigemptyset(&sig->signal);
220 INIT_LIST_HEAD(&sig->list);
223 /* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
224 static inline int valid_signal(unsigned long sig)
226 return sig <= _NSIG ? 1 : 0;
229 extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
230 extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
231 extern long do_sigpending(void __user *, unsigned long);
232 extern int sigprocmask(int, sigset_t *, sigset_t *);
234 #ifndef HAVE_ARCH_GET_SIGNAL_TO_DELIVER
235 struct pt_regs;
236 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
237 #endif
239 #endif /* __KERNEL__ */
241 #endif /* _LINUX_SIGNAL_H */