MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / include / linux / signal.h
blob117135e33d67116e4cf303b2f3872d2c6e63a1b8
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 * Real Time signals may be queued.
15 struct sigqueue {
16 struct list_head list;
17 int flags;
18 siginfo_t info;
19 struct user_struct *user;
22 /* flags values. */
23 #define SIGQUEUE_PREALLOC 1
25 struct sigpending {
26 struct list_head list;
27 sigset_t signal;
31 * Define some primitives to manipulate sigset_t.
34 #ifndef __HAVE_ARCH_SIG_BITOPS
35 #include <linux/bitops.h>
37 /* We don't use <linux/bitops.h> for these because there is no need to
38 be atomic. */
39 static inline void sigaddset(sigset_t *set, int _sig)
41 unsigned long sig = _sig - 1;
42 if (_NSIG_WORDS == 1)
43 set->sig[0] |= 1UL << sig;
44 else
45 set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW);
48 static inline void sigdelset(sigset_t *set, int _sig)
50 unsigned long sig = _sig - 1;
51 if (_NSIG_WORDS == 1)
52 set->sig[0] &= ~(1UL << sig);
53 else
54 set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW));
57 static inline int sigismember(sigset_t *set, int _sig)
59 unsigned long sig = _sig - 1;
60 if (_NSIG_WORDS == 1)
61 return 1 & (set->sig[0] >> sig);
62 else
63 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
66 static inline int sigfindinword(unsigned long word)
68 return ffz(~word);
71 #endif /* __HAVE_ARCH_SIG_BITOPS */
73 static inline int sigisemptyset(sigset_t *set)
75 extern void _NSIG_WORDS_is_unsupported_size(void);
76 switch (_NSIG_WORDS) {
77 case 4:
78 return (set->sig[3] | set->sig[2] |
79 set->sig[1] | set->sig[0]) == 0;
80 case 2:
81 return (set->sig[1] | set->sig[0]) == 0;
82 case 1:
83 return set->sig[0] == 0;
84 default:
85 _NSIG_WORDS_is_unsupported_size();
86 return 0;
90 #define sigmask(sig) (1UL << ((sig) - 1))
92 #ifndef __HAVE_ARCH_SIG_SETOPS
93 #include <linux/string.h>
95 #define _SIG_SET_BINOP(name, op) \
96 static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
97 { \
98 extern void _NSIG_WORDS_is_unsupported_size(void); \
99 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
101 switch (_NSIG_WORDS) { \
102 case 4: \
103 a3 = a->sig[3]; a2 = a->sig[2]; \
104 b3 = b->sig[3]; b2 = b->sig[2]; \
105 r->sig[3] = op(a3, b3); \
106 r->sig[2] = op(a2, b2); \
107 case 2: \
108 a1 = a->sig[1]; b1 = b->sig[1]; \
109 r->sig[1] = op(a1, b1); \
110 case 1: \
111 a0 = a->sig[0]; b0 = b->sig[0]; \
112 r->sig[0] = op(a0, b0); \
113 break; \
114 default: \
115 _NSIG_WORDS_is_unsupported_size(); \
119 #define _sig_or(x,y) ((x) | (y))
120 _SIG_SET_BINOP(sigorsets, _sig_or)
122 #define _sig_and(x,y) ((x) & (y))
123 _SIG_SET_BINOP(sigandsets, _sig_and)
125 #define _sig_nand(x,y) ((x) & ~(y))
126 _SIG_SET_BINOP(signandsets, _sig_nand)
128 #undef _SIG_SET_BINOP
129 #undef _sig_or
130 #undef _sig_and
131 #undef _sig_nand
133 #define _SIG_SET_OP(name, op) \
134 static inline void name(sigset_t *set) \
136 extern void _NSIG_WORDS_is_unsupported_size(void); \
138 switch (_NSIG_WORDS) { \
139 case 4: set->sig[3] = op(set->sig[3]); \
140 set->sig[2] = op(set->sig[2]); \
141 case 2: set->sig[1] = op(set->sig[1]); \
142 case 1: set->sig[0] = op(set->sig[0]); \
143 break; \
144 default: \
145 _NSIG_WORDS_is_unsupported_size(); \
149 #define _sig_not(x) (~(x))
150 _SIG_SET_OP(signotset, _sig_not)
152 #undef _SIG_SET_OP
153 #undef _sig_not
155 static inline void sigemptyset(sigset_t *set)
157 switch (_NSIG_WORDS) {
158 default:
159 memset(set, 0, sizeof(sigset_t));
160 break;
161 case 2: set->sig[1] = 0;
162 case 1: set->sig[0] = 0;
163 break;
167 static inline void sigfillset(sigset_t *set)
169 switch (_NSIG_WORDS) {
170 default:
171 memset(set, -1, sizeof(sigset_t));
172 break;
173 case 2: set->sig[1] = -1;
174 case 1: set->sig[0] = -1;
175 break;
179 /* Some extensions for manipulating the low 32 signals in particular. */
181 static inline void sigaddsetmask(sigset_t *set, unsigned long mask)
183 set->sig[0] |= mask;
186 static inline void sigdelsetmask(sigset_t *set, unsigned long mask)
188 set->sig[0] &= ~mask;
191 static inline int sigtestsetmask(sigset_t *set, unsigned long mask)
193 return (set->sig[0] & mask) != 0;
196 static inline void siginitset(sigset_t *set, unsigned long mask)
198 set->sig[0] = mask;
199 switch (_NSIG_WORDS) {
200 default:
201 memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1));
202 break;
203 case 2: set->sig[1] = 0;
204 case 1: ;
208 static inline void siginitsetinv(sigset_t *set, unsigned long mask)
210 set->sig[0] = ~mask;
211 switch (_NSIG_WORDS) {
212 default:
213 memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
214 break;
215 case 2: set->sig[1] = -1;
216 case 1: ;
220 #endif /* __HAVE_ARCH_SIG_SETOPS */
222 static inline void init_sigpending(struct sigpending *sig)
224 sigemptyset(&sig->signal);
225 INIT_LIST_HEAD(&sig->list);
228 extern void flush_sigqueue(struct sigpending *queue);
230 /* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
231 static inline int valid_signal(unsigned long sig)
233 return sig <= _NSIG ? 1 : 0;
236 extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
237 extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
238 extern long do_sigpending(void __user *, unsigned long);
239 extern int sigprocmask(int, sigset_t *, sigset_t *);
241 struct pt_regs;
242 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
244 #endif /* __KERNEL__ */
246 #endif /* _LINUX_SIGNAL_H */