[PATCH] swsusp: add architecture special saveable pages support
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / signal.h
blob1e4ce7225eeef979c26cfc8a8cde48eba797dad2
1 #ifndef _LINUX_SIGNAL_H
2 #define _LINUX_SIGNAL_H
4 #include <asm/signal.h>
5 #include <asm/siginfo.h>
7 #ifdef __KERNEL__
8 #include <linux/list.h>
9 #include <linux/spinlock.h>
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.
17 * SA_PROBEIRQ is set by callers when they expect sharing mismatches to occur
19 #define SA_SAMPLE_RANDOM SA_RESTART
20 #define SA_SHIRQ 0x04000000
21 #define SA_PROBEIRQ 0x08000000
24 * As above, these correspond to the IORESOURCE_IRQ_* defines in
25 * linux/ioport.h to select the interrupt line behaviour. When
26 * requesting an interrupt without specifying a SA_TRIGGER, the
27 * setting should be assumed to be "as already configured", which
28 * may be as per machine or firmware initialisation.
30 #define SA_TRIGGER_LOW 0x00000008
31 #define SA_TRIGGER_HIGH 0x00000004
32 #define SA_TRIGGER_FALLING 0x00000002
33 #define SA_TRIGGER_RISING 0x00000001
34 #define SA_TRIGGER_MASK (SA_TRIGGER_HIGH|SA_TRIGGER_LOW|\
35 SA_TRIGGER_RISING|SA_TRIGGER_FALLING)
38 * Real Time signals may be queued.
41 struct sigqueue {
42 struct list_head list;
43 int flags;
44 siginfo_t info;
45 struct user_struct *user;
48 /* flags values. */
49 #define SIGQUEUE_PREALLOC 1
51 struct sigpending {
52 struct list_head list;
53 sigset_t signal;
57 * Define some primitives to manipulate sigset_t.
60 #ifndef __HAVE_ARCH_SIG_BITOPS
61 #include <linux/bitops.h>
63 /* We don't use <linux/bitops.h> for these because there is no need to
64 be atomic. */
65 static inline void sigaddset(sigset_t *set, int _sig)
67 unsigned long sig = _sig - 1;
68 if (_NSIG_WORDS == 1)
69 set->sig[0] |= 1UL << sig;
70 else
71 set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW);
74 static inline void sigdelset(sigset_t *set, int _sig)
76 unsigned long sig = _sig - 1;
77 if (_NSIG_WORDS == 1)
78 set->sig[0] &= ~(1UL << sig);
79 else
80 set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW));
83 static inline int sigismember(sigset_t *set, int _sig)
85 unsigned long sig = _sig - 1;
86 if (_NSIG_WORDS == 1)
87 return 1 & (set->sig[0] >> sig);
88 else
89 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
92 static inline int sigfindinword(unsigned long word)
94 return ffz(~word);
97 #endif /* __HAVE_ARCH_SIG_BITOPS */
99 static inline int sigisemptyset(sigset_t *set)
101 extern void _NSIG_WORDS_is_unsupported_size(void);
102 switch (_NSIG_WORDS) {
103 case 4:
104 return (set->sig[3] | set->sig[2] |
105 set->sig[1] | set->sig[0]) == 0;
106 case 2:
107 return (set->sig[1] | set->sig[0]) == 0;
108 case 1:
109 return set->sig[0] == 0;
110 default:
111 _NSIG_WORDS_is_unsupported_size();
112 return 0;
116 #define sigmask(sig) (1UL << ((sig) - 1))
118 #ifndef __HAVE_ARCH_SIG_SETOPS
119 #include <linux/string.h>
121 #define _SIG_SET_BINOP(name, op) \
122 static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
124 extern void _NSIG_WORDS_is_unsupported_size(void); \
125 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
127 switch (_NSIG_WORDS) { \
128 case 4: \
129 a3 = a->sig[3]; a2 = a->sig[2]; \
130 b3 = b->sig[3]; b2 = b->sig[2]; \
131 r->sig[3] = op(a3, b3); \
132 r->sig[2] = op(a2, b2); \
133 case 2: \
134 a1 = a->sig[1]; b1 = b->sig[1]; \
135 r->sig[1] = op(a1, b1); \
136 case 1: \
137 a0 = a->sig[0]; b0 = b->sig[0]; \
138 r->sig[0] = op(a0, b0); \
139 break; \
140 default: \
141 _NSIG_WORDS_is_unsupported_size(); \
145 #define _sig_or(x,y) ((x) | (y))
146 _SIG_SET_BINOP(sigorsets, _sig_or)
148 #define _sig_and(x,y) ((x) & (y))
149 _SIG_SET_BINOP(sigandsets, _sig_and)
151 #define _sig_nand(x,y) ((x) & ~(y))
152 _SIG_SET_BINOP(signandsets, _sig_nand)
154 #undef _SIG_SET_BINOP
155 #undef _sig_or
156 #undef _sig_and
157 #undef _sig_nand
159 #define _SIG_SET_OP(name, op) \
160 static inline void name(sigset_t *set) \
162 extern void _NSIG_WORDS_is_unsupported_size(void); \
164 switch (_NSIG_WORDS) { \
165 case 4: set->sig[3] = op(set->sig[3]); \
166 set->sig[2] = op(set->sig[2]); \
167 case 2: set->sig[1] = op(set->sig[1]); \
168 case 1: set->sig[0] = op(set->sig[0]); \
169 break; \
170 default: \
171 _NSIG_WORDS_is_unsupported_size(); \
175 #define _sig_not(x) (~(x))
176 _SIG_SET_OP(signotset, _sig_not)
178 #undef _SIG_SET_OP
179 #undef _sig_not
181 static inline void sigemptyset(sigset_t *set)
183 switch (_NSIG_WORDS) {
184 default:
185 memset(set, 0, sizeof(sigset_t));
186 break;
187 case 2: set->sig[1] = 0;
188 case 1: set->sig[0] = 0;
189 break;
193 static inline void sigfillset(sigset_t *set)
195 switch (_NSIG_WORDS) {
196 default:
197 memset(set, -1, sizeof(sigset_t));
198 break;
199 case 2: set->sig[1] = -1;
200 case 1: set->sig[0] = -1;
201 break;
205 /* Some extensions for manipulating the low 32 signals in particular. */
207 static inline void sigaddsetmask(sigset_t *set, unsigned long mask)
209 set->sig[0] |= mask;
212 static inline void sigdelsetmask(sigset_t *set, unsigned long mask)
214 set->sig[0] &= ~mask;
217 static inline int sigtestsetmask(sigset_t *set, unsigned long mask)
219 return (set->sig[0] & mask) != 0;
222 static inline void siginitset(sigset_t *set, unsigned long mask)
224 set->sig[0] = mask;
225 switch (_NSIG_WORDS) {
226 default:
227 memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1));
228 break;
229 case 2: set->sig[1] = 0;
230 case 1: ;
234 static inline void siginitsetinv(sigset_t *set, unsigned long mask)
236 set->sig[0] = ~mask;
237 switch (_NSIG_WORDS) {
238 default:
239 memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
240 break;
241 case 2: set->sig[1] = -1;
242 case 1: ;
246 #endif /* __HAVE_ARCH_SIG_SETOPS */
248 static inline void init_sigpending(struct sigpending *sig)
250 sigemptyset(&sig->signal);
251 INIT_LIST_HEAD(&sig->list);
254 extern void flush_sigqueue(struct sigpending *queue);
256 /* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
257 static inline int valid_signal(unsigned long sig)
259 return sig <= _NSIG ? 1 : 0;
262 extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
263 extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
264 extern long do_sigpending(void __user *, unsigned long);
265 extern int sigprocmask(int, sigset_t *, sigset_t *);
267 struct pt_regs;
268 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
270 #endif /* __KERNEL__ */
272 #endif /* _LINUX_SIGNAL_H */