MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / include / linux / signal.h
blobe5f3d83ab215e79a9d56c418785f64df3099a190
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__
11 #define MAX_SIGPENDING 1024
14 * Real Time signals may be queued.
17 struct sigqueue {
18 struct list_head list;
19 spinlock_t *lock;
20 int flags;
21 siginfo_t info;
22 struct user_struct *user;
25 /* flags values. */
26 #define SIGQUEUE_PREALLOC 1
28 struct sigpending {
29 struct list_head list;
30 sigset_t signal;
34 * Define some primitives to manipulate sigset_t.
37 #ifndef __HAVE_ARCH_SIG_BITOPS
38 #include <linux/bitops.h>
40 /* We don't use <linux/bitops.h> for these because there is no need to
41 be atomic. */
42 static inline void sigaddset(sigset_t *set, int _sig)
44 unsigned long sig = _sig - 1;
45 if (_NSIG_WORDS == 1)
46 set->sig[0] |= 1UL << sig;
47 else
48 set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW);
51 static inline void sigdelset(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 int sigismember(sigset_t *set, int _sig)
62 unsigned long sig = _sig - 1;
63 if (_NSIG_WORDS == 1)
64 return 1 & (set->sig[0] >> sig);
65 else
66 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
69 static inline int sigfindinword(unsigned long word)
71 return ffz(~word);
74 #endif /* __HAVE_ARCH_SIG_BITOPS */
76 #define sigmask(sig) (1UL << ((sig) - 1))
78 #ifndef __HAVE_ARCH_SIG_SETOPS
79 #include <linux/string.h>
81 #define _SIG_SET_BINOP(name, op) \
82 static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
83 { \
84 extern void _NSIG_WORDS_is_unsupported_size(void); \
85 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
87 switch (_NSIG_WORDS) { \
88 case 4: \
89 a3 = a->sig[3]; a2 = a->sig[2]; \
90 b3 = b->sig[3]; b2 = b->sig[2]; \
91 r->sig[3] = op(a3, b3); \
92 r->sig[2] = op(a2, b2); \
93 case 2: \
94 a1 = a->sig[1]; b1 = b->sig[1]; \
95 r->sig[1] = op(a1, b1); \
96 case 1: \
97 a0 = a->sig[0]; b0 = b->sig[0]; \
98 r->sig[0] = op(a0, b0); \
99 break; \
100 default: \
101 _NSIG_WORDS_is_unsupported_size(); \
105 #define _sig_or(x,y) ((x) | (y))
106 _SIG_SET_BINOP(sigorsets, _sig_or)
108 #define _sig_and(x,y) ((x) & (y))
109 _SIG_SET_BINOP(sigandsets, _sig_and)
111 #define _sig_nand(x,y) ((x) & ~(y))
112 _SIG_SET_BINOP(signandsets, _sig_nand)
114 #undef _SIG_SET_BINOP
115 #undef _sig_or
116 #undef _sig_and
117 #undef _sig_nand
119 #define _SIG_SET_OP(name, op) \
120 static inline void name(sigset_t *set) \
122 extern void _NSIG_WORDS_is_unsupported_size(void); \
124 switch (_NSIG_WORDS) { \
125 case 4: set->sig[3] = op(set->sig[3]); \
126 set->sig[2] = op(set->sig[2]); \
127 case 2: set->sig[1] = op(set->sig[1]); \
128 case 1: set->sig[0] = op(set->sig[0]); \
129 break; \
130 default: \
131 _NSIG_WORDS_is_unsupported_size(); \
135 #define _sig_not(x) (~(x))
136 _SIG_SET_OP(signotset, _sig_not)
138 #undef _SIG_SET_OP
139 #undef _sig_not
141 static inline void sigemptyset(sigset_t *set)
143 switch (_NSIG_WORDS) {
144 default:
145 memset(set, 0, sizeof(sigset_t));
146 break;
147 case 2: set->sig[1] = 0;
148 case 1: set->sig[0] = 0;
149 break;
153 static inline void sigfillset(sigset_t *set)
155 switch (_NSIG_WORDS) {
156 default:
157 memset(set, -1, sizeof(sigset_t));
158 break;
159 case 2: set->sig[1] = -1;
160 case 1: set->sig[0] = -1;
161 break;
165 /* Some extensions for manipulating the low 32 signals in particular. */
167 static inline void sigaddsetmask(sigset_t *set, unsigned long mask)
169 set->sig[0] |= mask;
172 static inline void sigdelsetmask(sigset_t *set, unsigned long mask)
174 set->sig[0] &= ~mask;
177 static inline int sigtestsetmask(sigset_t *set, unsigned long mask)
179 return (set->sig[0] & mask) != 0;
182 static inline void siginitset(sigset_t *set, unsigned long mask)
184 set->sig[0] = mask;
185 switch (_NSIG_WORDS) {
186 default:
187 memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1));
188 break;
189 case 2: set->sig[1] = 0;
190 case 1: ;
194 static inline void siginitsetinv(sigset_t *set, unsigned long mask)
196 set->sig[0] = ~mask;
197 switch (_NSIG_WORDS) {
198 default:
199 memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
200 break;
201 case 2: set->sig[1] = -1;
202 case 1: ;
206 #endif /* __HAVE_ARCH_SIG_SETOPS */
208 static inline void init_sigpending(struct sigpending *sig)
210 sigemptyset(&sig->signal);
211 INIT_LIST_HEAD(&sig->list);
214 extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
215 extern long do_sigpending(void __user *, unsigned long);
216 extern int sigprocmask(int, sigset_t *, sigset_t *);
218 #ifndef HAVE_ARCH_GET_SIGNAL_TO_DELIVER
219 struct pt_regs;
220 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
221 #endif
223 #endif /* __KERNEL__ */
225 #endif /* _LINUX_SIGNAL_H */