[PATCH] remove bogus comment from init/main.c
[linux-2.6/mini2440.git] / include / linux / signal.h
blobb7d093520bb6c0011b385c4ab4faaddbd6c50e6e
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
22 * As above, these correspond to the IORESOURCE_IRQ_* defines in
23 * linux/ioport.h to select the interrupt line behaviour. When
24 * requesting an interrupt without specifying a SA_TRIGGER, the
25 * setting should be assumed to be "as already configured", which
26 * may be as per machine or firmware initialisation.
28 #define SA_TRIGGER_LOW 0x00000008
29 #define SA_TRIGGER_HIGH 0x00000004
30 #define SA_TRIGGER_FALLING 0x00000002
31 #define SA_TRIGGER_RISING 0x00000001
32 #define SA_TRIGGER_MASK (SA_TRIGGER_HIGH|SA_TRIGGER_LOW|\
33 SA_TRIGGER_RISING|SA_TRIGGER_FALLING)
36 * Real Time signals may be queued.
39 struct sigqueue {
40 struct list_head list;
41 int flags;
42 siginfo_t info;
43 struct user_struct *user;
46 /* flags values. */
47 #define SIGQUEUE_PREALLOC 1
49 struct sigpending {
50 struct list_head list;
51 sigset_t signal;
55 * Define some primitives to manipulate sigset_t.
58 #ifndef __HAVE_ARCH_SIG_BITOPS
59 #include <linux/bitops.h>
61 /* We don't use <linux/bitops.h> for these because there is no need to
62 be atomic. */
63 static inline void sigaddset(sigset_t *set, int _sig)
65 unsigned long sig = _sig - 1;
66 if (_NSIG_WORDS == 1)
67 set->sig[0] |= 1UL << sig;
68 else
69 set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW);
72 static inline void sigdelset(sigset_t *set, int _sig)
74 unsigned long sig = _sig - 1;
75 if (_NSIG_WORDS == 1)
76 set->sig[0] &= ~(1UL << sig);
77 else
78 set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW));
81 static inline int sigismember(sigset_t *set, int _sig)
83 unsigned long sig = _sig - 1;
84 if (_NSIG_WORDS == 1)
85 return 1 & (set->sig[0] >> sig);
86 else
87 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
90 static inline int sigfindinword(unsigned long word)
92 return ffz(~word);
95 #endif /* __HAVE_ARCH_SIG_BITOPS */
97 static inline int sigisemptyset(sigset_t *set)
99 extern void _NSIG_WORDS_is_unsupported_size(void);
100 switch (_NSIG_WORDS) {
101 case 4:
102 return (set->sig[3] | set->sig[2] |
103 set->sig[1] | set->sig[0]) == 0;
104 case 2:
105 return (set->sig[1] | set->sig[0]) == 0;
106 case 1:
107 return set->sig[0] == 0;
108 default:
109 _NSIG_WORDS_is_unsupported_size();
110 return 0;
114 #define sigmask(sig) (1UL << ((sig) - 1))
116 #ifndef __HAVE_ARCH_SIG_SETOPS
117 #include <linux/string.h>
119 #define _SIG_SET_BINOP(name, op) \
120 static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
122 extern void _NSIG_WORDS_is_unsupported_size(void); \
123 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
125 switch (_NSIG_WORDS) { \
126 case 4: \
127 a3 = a->sig[3]; a2 = a->sig[2]; \
128 b3 = b->sig[3]; b2 = b->sig[2]; \
129 r->sig[3] = op(a3, b3); \
130 r->sig[2] = op(a2, b2); \
131 case 2: \
132 a1 = a->sig[1]; b1 = b->sig[1]; \
133 r->sig[1] = op(a1, b1); \
134 case 1: \
135 a0 = a->sig[0]; b0 = b->sig[0]; \
136 r->sig[0] = op(a0, b0); \
137 break; \
138 default: \
139 _NSIG_WORDS_is_unsupported_size(); \
143 #define _sig_or(x,y) ((x) | (y))
144 _SIG_SET_BINOP(sigorsets, _sig_or)
146 #define _sig_and(x,y) ((x) & (y))
147 _SIG_SET_BINOP(sigandsets, _sig_and)
149 #define _sig_nand(x,y) ((x) & ~(y))
150 _SIG_SET_BINOP(signandsets, _sig_nand)
152 #undef _SIG_SET_BINOP
153 #undef _sig_or
154 #undef _sig_and
155 #undef _sig_nand
157 #define _SIG_SET_OP(name, op) \
158 static inline void name(sigset_t *set) \
160 extern void _NSIG_WORDS_is_unsupported_size(void); \
162 switch (_NSIG_WORDS) { \
163 case 4: set->sig[3] = op(set->sig[3]); \
164 set->sig[2] = op(set->sig[2]); \
165 case 2: set->sig[1] = op(set->sig[1]); \
166 case 1: set->sig[0] = op(set->sig[0]); \
167 break; \
168 default: \
169 _NSIG_WORDS_is_unsupported_size(); \
173 #define _sig_not(x) (~(x))
174 _SIG_SET_OP(signotset, _sig_not)
176 #undef _SIG_SET_OP
177 #undef _sig_not
179 static inline void sigemptyset(sigset_t *set)
181 switch (_NSIG_WORDS) {
182 default:
183 memset(set, 0, sizeof(sigset_t));
184 break;
185 case 2: set->sig[1] = 0;
186 case 1: set->sig[0] = 0;
187 break;
191 static inline void sigfillset(sigset_t *set)
193 switch (_NSIG_WORDS) {
194 default:
195 memset(set, -1, sizeof(sigset_t));
196 break;
197 case 2: set->sig[1] = -1;
198 case 1: set->sig[0] = -1;
199 break;
203 /* Some extensions for manipulating the low 32 signals in particular. */
205 static inline void sigaddsetmask(sigset_t *set, unsigned long mask)
207 set->sig[0] |= mask;
210 static inline void sigdelsetmask(sigset_t *set, unsigned long mask)
212 set->sig[0] &= ~mask;
215 static inline int sigtestsetmask(sigset_t *set, unsigned long mask)
217 return (set->sig[0] & mask) != 0;
220 static inline void siginitset(sigset_t *set, unsigned long mask)
222 set->sig[0] = mask;
223 switch (_NSIG_WORDS) {
224 default:
225 memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1));
226 break;
227 case 2: set->sig[1] = 0;
228 case 1: ;
232 static inline void siginitsetinv(sigset_t *set, unsigned long mask)
234 set->sig[0] = ~mask;
235 switch (_NSIG_WORDS) {
236 default:
237 memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
238 break;
239 case 2: set->sig[1] = -1;
240 case 1: ;
244 #endif /* __HAVE_ARCH_SIG_SETOPS */
246 static inline void init_sigpending(struct sigpending *sig)
248 sigemptyset(&sig->signal);
249 INIT_LIST_HEAD(&sig->list);
252 /* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
253 static inline int valid_signal(unsigned long sig)
255 return sig <= _NSIG ? 1 : 0;
258 extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
259 extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
260 extern long do_sigpending(void __user *, unsigned long);
261 extern int sigprocmask(int, sigset_t *, sigset_t *);
263 struct pt_regs;
264 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
266 #endif /* __KERNEL__ */
268 #endif /* _LINUX_SIGNAL_H */