Linux v2.6.15-rc7
[pohmelfs.git] / include / linux / signal.h
blob5dd5f02c5c5fd6b1c3f192f13b6b28373763061f
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 int flags;
29 siginfo_t info;
30 struct user_struct *user;
33 /* flags values. */
34 #define SIGQUEUE_PREALLOC 1
36 struct sigpending {
37 struct list_head list;
38 sigset_t signal;
42 * Define some primitives to manipulate sigset_t.
45 #ifndef __HAVE_ARCH_SIG_BITOPS
46 #include <linux/bitops.h>
48 /* We don't use <linux/bitops.h> for these because there is no need to
49 be atomic. */
50 static inline void sigaddset(sigset_t *set, int _sig)
52 unsigned long sig = _sig - 1;
53 if (_NSIG_WORDS == 1)
54 set->sig[0] |= 1UL << sig;
55 else
56 set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW);
59 static inline void sigdelset(sigset_t *set, int _sig)
61 unsigned long sig = _sig - 1;
62 if (_NSIG_WORDS == 1)
63 set->sig[0] &= ~(1UL << sig);
64 else
65 set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW));
68 static inline int sigismember(sigset_t *set, int _sig)
70 unsigned long sig = _sig - 1;
71 if (_NSIG_WORDS == 1)
72 return 1 & (set->sig[0] >> sig);
73 else
74 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
77 static inline int sigfindinword(unsigned long word)
79 return ffz(~word);
82 #endif /* __HAVE_ARCH_SIG_BITOPS */
84 #define sigmask(sig) (1UL << ((sig) - 1))
86 #ifndef __HAVE_ARCH_SIG_SETOPS
87 #include <linux/string.h>
89 #define _SIG_SET_BINOP(name, op) \
90 static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
91 { \
92 extern void _NSIG_WORDS_is_unsupported_size(void); \
93 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
95 switch (_NSIG_WORDS) { \
96 case 4: \
97 a3 = a->sig[3]; a2 = a->sig[2]; \
98 b3 = b->sig[3]; b2 = b->sig[2]; \
99 r->sig[3] = op(a3, b3); \
100 r->sig[2] = op(a2, b2); \
101 case 2: \
102 a1 = a->sig[1]; b1 = b->sig[1]; \
103 r->sig[1] = op(a1, b1); \
104 case 1: \
105 a0 = a->sig[0]; b0 = b->sig[0]; \
106 r->sig[0] = op(a0, b0); \
107 break; \
108 default: \
109 _NSIG_WORDS_is_unsupported_size(); \
113 #define _sig_or(x,y) ((x) | (y))
114 _SIG_SET_BINOP(sigorsets, _sig_or)
116 #define _sig_and(x,y) ((x) & (y))
117 _SIG_SET_BINOP(sigandsets, _sig_and)
119 #define _sig_nand(x,y) ((x) & ~(y))
120 _SIG_SET_BINOP(signandsets, _sig_nand)
122 #undef _SIG_SET_BINOP
123 #undef _sig_or
124 #undef _sig_and
125 #undef _sig_nand
127 #define _SIG_SET_OP(name, op) \
128 static inline void name(sigset_t *set) \
130 extern void _NSIG_WORDS_is_unsupported_size(void); \
132 switch (_NSIG_WORDS) { \
133 case 4: set->sig[3] = op(set->sig[3]); \
134 set->sig[2] = op(set->sig[2]); \
135 case 2: set->sig[1] = op(set->sig[1]); \
136 case 1: set->sig[0] = op(set->sig[0]); \
137 break; \
138 default: \
139 _NSIG_WORDS_is_unsupported_size(); \
143 #define _sig_not(x) (~(x))
144 _SIG_SET_OP(signotset, _sig_not)
146 #undef _SIG_SET_OP
147 #undef _sig_not
149 static inline void sigemptyset(sigset_t *set)
151 switch (_NSIG_WORDS) {
152 default:
153 memset(set, 0, sizeof(sigset_t));
154 break;
155 case 2: set->sig[1] = 0;
156 case 1: set->sig[0] = 0;
157 break;
161 static inline void sigfillset(sigset_t *set)
163 switch (_NSIG_WORDS) {
164 default:
165 memset(set, -1, sizeof(sigset_t));
166 break;
167 case 2: set->sig[1] = -1;
168 case 1: set->sig[0] = -1;
169 break;
173 /* Some extensions for manipulating the low 32 signals in particular. */
175 static inline void sigaddsetmask(sigset_t *set, unsigned long mask)
177 set->sig[0] |= mask;
180 static inline void sigdelsetmask(sigset_t *set, unsigned long mask)
182 set->sig[0] &= ~mask;
185 static inline int sigtestsetmask(sigset_t *set, unsigned long mask)
187 return (set->sig[0] & mask) != 0;
190 static inline void siginitset(sigset_t *set, unsigned long mask)
192 set->sig[0] = mask;
193 switch (_NSIG_WORDS) {
194 default:
195 memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1));
196 break;
197 case 2: set->sig[1] = 0;
198 case 1: ;
202 static inline void siginitsetinv(sigset_t *set, unsigned long mask)
204 set->sig[0] = ~mask;
205 switch (_NSIG_WORDS) {
206 default:
207 memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
208 break;
209 case 2: set->sig[1] = -1;
210 case 1: ;
214 #endif /* __HAVE_ARCH_SIG_SETOPS */
216 static inline void init_sigpending(struct sigpending *sig)
218 sigemptyset(&sig->signal);
219 INIT_LIST_HEAD(&sig->list);
222 /* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
223 static inline int valid_signal(unsigned long sig)
225 return sig <= _NSIG ? 1 : 0;
228 extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
229 extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
230 extern long do_sigpending(void __user *, unsigned long);
231 extern int sigprocmask(int, sigset_t *, sigset_t *);
233 struct pt_regs;
234 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
236 #endif /* __KERNEL__ */
238 #endif /* _LINUX_SIGNAL_H */