]>
git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - include/linux/signal.h
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>
12 * Real Time signals may be queued.
16 struct list_head list
;
20 struct user_struct
*user
;
24 #define SIGQUEUE_PREALLOC 1
27 struct list_head list
;
32 * Define some primitives to manipulate sigset_t.
35 #ifndef __HAVE_ARCH_SIG_BITOPS
36 #include <linux/bitops.h>
38 /* We don't use <linux/bitops.h> for these because there is no need to
40 static inline void sigaddset(sigset_t
*set
, int _sig
)
42 unsigned long sig
= _sig
- 1;
44 set
->sig
[0] |= 1UL << sig
;
46 set
->sig
[sig
/ _NSIG_BPW
] |= 1UL << (sig
% _NSIG_BPW
);
49 static inline void sigdelset(sigset_t
*set
, int _sig
)
51 unsigned long sig
= _sig
- 1;
53 set
->sig
[0] &= ~(1UL << sig
);
55 set
->sig
[sig
/ _NSIG_BPW
] &= ~(1UL << (sig
% _NSIG_BPW
));
58 static inline int sigismember(sigset_t
*set
, int _sig
)
60 unsigned long sig
= _sig
- 1;
62 return 1 & (set
->sig
[0] >> sig
);
64 return 1 & (set
->sig
[sig
/ _NSIG_BPW
] >> (sig
% _NSIG_BPW
));
67 static inline int sigfindinword(unsigned long word
)
72 #endif /* __HAVE_ARCH_SIG_BITOPS */
74 #define sigmask(sig) (1UL << ((sig) - 1))
76 #ifndef __HAVE_ARCH_SIG_SETOPS
77 #include <linux/string.h>
79 #define _SIG_SET_BINOP(name, op) \
80 static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
82 extern void _NSIG_WORDS_is_unsupported_size(void); \
83 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
85 switch (_NSIG_WORDS) { \
87 a3 = a->sig[3]; a2 = a->sig[2]; \
88 b3 = b->sig[3]; b2 = b->sig[2]; \
89 r->sig[3] = op(a3, b3); \
90 r->sig[2] = op(a2, b2); \
92 a1 = a->sig[1]; b1 = b->sig[1]; \
93 r->sig[1] = op(a1, b1); \
95 a0 = a->sig[0]; b0 = b->sig[0]; \
96 r->sig[0] = op(a0, b0); \
99 _NSIG_WORDS_is_unsupported_size(); \
103 #define _sig_or(x,y) ((x) | (y))
104 _SIG_SET_BINOP(sigorsets
, _sig_or
)
106 #define _sig_and(x,y) ((x) & (y))
107 _SIG_SET_BINOP(sigandsets
, _sig_and
)
109 #define _sig_nand(x,y) ((x) & ~(y))
110 _SIG_SET_BINOP(signandsets
, _sig_nand
)
112 #undef _SIG_SET_BINOP
117 #define _SIG_SET_OP(name, op) \
118 static inline void name(sigset_t *set) \
120 extern void _NSIG_WORDS_is_unsupported_size(void); \
122 switch (_NSIG_WORDS) { \
123 case 4: set->sig[3] = op(set->sig[3]); \
124 set->sig[2] = op(set->sig[2]); \
125 case 2: set->sig[1] = op(set->sig[1]); \
126 case 1: set->sig[0] = op(set->sig[0]); \
129 _NSIG_WORDS_is_unsupported_size(); \
133 #define _sig_not(x) (~(x))
134 _SIG_SET_OP(signotset
, _sig_not
)
139 static inline void sigemptyset(sigset_t
*set
)
141 switch (_NSIG_WORDS
) {
143 memset(set
, 0, sizeof(sigset_t
));
145 case 2: set
->sig
[1] = 0;
146 case 1: set
->sig
[0] = 0;
151 static inline void sigfillset(sigset_t
*set
)
153 switch (_NSIG_WORDS
) {
155 memset(set
, -1, sizeof(sigset_t
));
157 case 2: set
->sig
[1] = -1;
158 case 1: set
->sig
[0] = -1;
163 /* Some extensions for manipulating the low 32 signals in particular. */
165 static inline void sigaddsetmask(sigset_t
*set
, unsigned long mask
)
170 static inline void sigdelsetmask(sigset_t
*set
, unsigned long mask
)
172 set
->sig
[0] &= ~mask
;
175 static inline int sigtestsetmask(sigset_t
*set
, unsigned long mask
)
177 return (set
->sig
[0] & mask
) != 0;
180 static inline void siginitset(sigset_t
*set
, unsigned long mask
)
183 switch (_NSIG_WORDS
) {
185 memset(&set
->sig
[1], 0, sizeof(long)*(_NSIG_WORDS
-1));
187 case 2: set
->sig
[1] = 0;
192 static inline void siginitsetinv(sigset_t
*set
, unsigned long mask
)
195 switch (_NSIG_WORDS
) {
197 memset(&set
->sig
[1], -1, sizeof(long)*(_NSIG_WORDS
-1));
199 case 2: set
->sig
[1] = -1;
204 #endif /* __HAVE_ARCH_SIG_SETOPS */
206 static inline void init_sigpending(struct sigpending
*sig
)
208 sigemptyset(&sig
->signal
);
209 INIT_LIST_HEAD(&sig
->list
);
212 extern int group_send_sig_info(int sig
, struct siginfo
*info
, struct task_struct
*p
);
213 extern int __group_send_sig_info(int, struct siginfo
*, struct task_struct
*);
214 extern long do_sigpending(void __user
*, unsigned long);
215 extern int sigprocmask(int, sigset_t
*, sigset_t
*);
217 #ifndef HAVE_ARCH_GET_SIGNAL_TO_DELIVER
219 extern int get_signal_to_deliver(siginfo_t
*info
, struct k_sigaction
*return_ka
, struct pt_regs
*regs
, void *cookie
);
222 #endif /* __KERNEL__ */
224 #endif /* _LINUX_SIGNAL_H */