blob: 0dba8b7a6ac7c6d8824e563d01889ca7134304a6 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_SIGNAL_H
2#define _ASM_X86_SIGNAL_H
Thomas Gleixner33185c52007-10-23 22:37:24 +02003
4#ifndef __ASSEMBLY__
5#include <linux/types.h>
6#include <linux/time.h>
7#include <linux/compiler.h>
8
9/* Avoid too many header ordering problems. */
10struct siginfo;
11
Thomas Gleixner96a388d2007-10-11 11:20:03 +020012#ifdef __KERNEL__
Thomas Gleixner33185c52007-10-23 22:37:24 +020013#include <linux/linkage.h>
14
15/* Most things should be clean enough to redefine this at will, if care
16 is taken to make libc match. */
17
18#define _NSIG 64
19
20#ifdef __i386__
21# define _NSIG_BPW 32
Thomas Gleixner96a388d2007-10-11 11:20:03 +020022#else
Thomas Gleixner33185c52007-10-23 22:37:24 +020023# define _NSIG_BPW 64
24#endif
25
26#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
27
28typedef unsigned long old_sigset_t; /* at least 32 bits */
29
30typedef struct {
31 unsigned long sig[_NSIG_WORDS];
32} sigset_t;
33
Suresh Siddha050902c2012-07-24 16:05:27 -070034#ifndef CONFIG_COMPAT
35typedef sigset_t compat_sigset_t;
36#endif
37
Thomas Gleixner33185c52007-10-23 22:37:24 +020038#else
39/* Here we must cater to libcs that poke about in kernel headers. */
40
41#define NSIG 32
42typedef unsigned long sigset_t;
43
44#endif /* __KERNEL__ */
45#endif /* __ASSEMBLY__ */
46
47#define SIGHUP 1
48#define SIGINT 2
49#define SIGQUIT 3
50#define SIGILL 4
51#define SIGTRAP 5
52#define SIGABRT 6
53#define SIGIOT 6
54#define SIGBUS 7
55#define SIGFPE 8
56#define SIGKILL 9
57#define SIGUSR1 10
58#define SIGSEGV 11
59#define SIGUSR2 12
60#define SIGPIPE 13
61#define SIGALRM 14
62#define SIGTERM 15
63#define SIGSTKFLT 16
64#define SIGCHLD 17
65#define SIGCONT 18
66#define SIGSTOP 19
67#define SIGTSTP 20
68#define SIGTTIN 21
69#define SIGTTOU 22
70#define SIGURG 23
71#define SIGXCPU 24
72#define SIGXFSZ 25
73#define SIGVTALRM 26
74#define SIGPROF 27
75#define SIGWINCH 28
76#define SIGIO 29
77#define SIGPOLL SIGIO
78/*
79#define SIGLOST 29
80*/
81#define SIGPWR 30
82#define SIGSYS 31
83#define SIGUNUSED 31
84
85/* These should not be considered constants from userland. */
86#define SIGRTMIN 32
87#define SIGRTMAX _NSIG
88
89/*
90 * SA_FLAGS values:
91 *
92 * SA_ONSTACK indicates that a registered stack_t will be used.
93 * SA_RESTART flag to get restarting signals (which were the default long ago)
94 * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
95 * SA_RESETHAND clears the handler when the signal is delivered.
96 * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
97 * SA_NODEFER prevents the current signal from being masked in the handler.
98 *
99 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
100 * Unix names RESETHAND and NODEFER respectively.
101 */
102#define SA_NOCLDSTOP 0x00000001u
103#define SA_NOCLDWAIT 0x00000002u
104#define SA_SIGINFO 0x00000004u
105#define SA_ONSTACK 0x08000000u
106#define SA_RESTART 0x10000000u
107#define SA_NODEFER 0x40000000u
108#define SA_RESETHAND 0x80000000u
109
110#define SA_NOMASK SA_NODEFER
111#define SA_ONESHOT SA_RESETHAND
112
113#define SA_RESTORER 0x04000000
114
115/*
116 * sigaltstack controls
117 */
118#define SS_ONSTACK 1
119#define SS_DISABLE 2
120
121#define MINSIGSTKSZ 2048
122#define SIGSTKSZ 8192
123
Arnd Bergmann63b852a2009-05-13 22:56:24 +0000124#include <asm-generic/signal-defs.h>
Thomas Gleixner33185c52007-10-23 22:37:24 +0200125
126#ifndef __ASSEMBLY__
127
Jaswinder Singh7b5b50f2008-12-15 22:24:48 +0530128# ifdef __KERNEL__
129extern void do_notify_resume(struct pt_regs *, void *, __u32);
130# endif /* __KERNEL__ */
131
Thomas Gleixner33185c52007-10-23 22:37:24 +0200132#ifdef __i386__
133# ifdef __KERNEL__
134struct old_sigaction {
135 __sighandler_t sa_handler;
136 old_sigset_t sa_mask;
137 unsigned long sa_flags;
138 __sigrestore_t sa_restorer;
139};
140
141struct sigaction {
142 __sighandler_t sa_handler;
143 unsigned long sa_flags;
144 __sigrestore_t sa_restorer;
145 sigset_t sa_mask; /* mask last for extensibility */
146};
147
148struct k_sigaction {
149 struct sigaction sa;
150};
Jaswinder Singhb994b6c2008-07-21 21:37:52 +0530151
Thomas Gleixner33185c52007-10-23 22:37:24 +0200152# else /* __KERNEL__ */
153/* Here we must cater to libcs that poke about in kernel headers. */
154
155struct sigaction {
156 union {
157 __sighandler_t _sa_handler;
158 void (*_sa_sigaction)(int, struct siginfo *, void *);
159 } _u;
160 sigset_t sa_mask;
161 unsigned long sa_flags;
162 void (*sa_restorer)(void);
163};
164
165#define sa_handler _u._sa_handler
166#define sa_sigaction _u._sa_sigaction
167
168# endif /* ! __KERNEL__ */
169#else /* __i386__ */
170
171struct sigaction {
172 __sighandler_t sa_handler;
173 unsigned long sa_flags;
174 __sigrestore_t sa_restorer;
175 sigset_t sa_mask; /* mask last for extensibility */
176};
177
178struct k_sigaction {
179 struct sigaction sa;
180};
181
182#endif /* !__i386__ */
183
184typedef struct sigaltstack {
185 void __user *ss_sp;
186 int ss_flags;
187 size_t ss_size;
188} stack_t;
189
190#ifdef __KERNEL__
191#include <asm/sigcontext.h>
192
Herton Ronaldo Krzesinski723edb52008-07-14 17:40:23 -0300193#ifdef __i386__
Thomas Gleixner33185c52007-10-23 22:37:24 +0200194
195#define __HAVE_ARCH_SIG_BITOPS
196
Joe Perches9551b122008-03-23 01:03:28 -0700197#define sigaddset(set,sig) \
Herton Ronaldo Krzesinski723edb52008-07-14 17:40:23 -0300198 (__builtin_constant_p(sig) \
Joe Perches9551b122008-03-23 01:03:28 -0700199 ? __const_sigaddset((set), (sig)) \
200 : __gen_sigaddset((set), (sig)))
Thomas Gleixner33185c52007-10-23 22:37:24 +0200201
Joe Perches9551b122008-03-23 01:03:28 -0700202static inline void __gen_sigaddset(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +0200203{
Joe Perches9551b122008-03-23 01:03:28 -0700204 asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
Thomas Gleixner33185c52007-10-23 22:37:24 +0200205}
206
Joe Perches9551b122008-03-23 01:03:28 -0700207static inline void __const_sigaddset(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +0200208{
209 unsigned long sig = _sig - 1;
210 set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW);
211}
212
Joe Perches9551b122008-03-23 01:03:28 -0700213#define sigdelset(set, sig) \
214 (__builtin_constant_p(sig) \
215 ? __const_sigdelset((set), (sig)) \
216 : __gen_sigdelset((set), (sig)))
Thomas Gleixner33185c52007-10-23 22:37:24 +0200217
218
Joe Perches9551b122008-03-23 01:03:28 -0700219static inline void __gen_sigdelset(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +0200220{
Joe Perches9551b122008-03-23 01:03:28 -0700221 asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
Thomas Gleixner33185c52007-10-23 22:37:24 +0200222}
223
Joe Perches9551b122008-03-23 01:03:28 -0700224static inline void __const_sigdelset(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +0200225{
226 unsigned long sig = _sig - 1;
227 set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW));
228}
229
Joe Perches9551b122008-03-23 01:03:28 -0700230static inline int __const_sigismember(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +0200231{
232 unsigned long sig = _sig - 1;
233 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
234}
235
Joe Perches9551b122008-03-23 01:03:28 -0700236static inline int __gen_sigismember(sigset_t *set, int _sig)
Thomas Gleixner33185c52007-10-23 22:37:24 +0200237{
238 int ret;
Joe Perches9551b122008-03-23 01:03:28 -0700239 asm("btl %2,%1\n\tsbbl %0,%0"
240 : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc");
Thomas Gleixner33185c52007-10-23 22:37:24 +0200241 return ret;
242}
243
Joe Perches9551b122008-03-23 01:03:28 -0700244#define sigismember(set, sig) \
245 (__builtin_constant_p(sig) \
246 ? __const_sigismember((set), (sig)) \
247 : __gen_sigismember((set), (sig)))
Thomas Gleixner33185c52007-10-23 22:37:24 +0200248
Joe Perches9551b122008-03-23 01:03:28 -0700249static inline int sigfindinword(unsigned long word)
Thomas Gleixner33185c52007-10-23 22:37:24 +0200250{
Joe Perches9551b122008-03-23 01:03:28 -0700251 asm("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc");
Thomas Gleixner33185c52007-10-23 22:37:24 +0200252 return word;
253}
254
255struct pt_regs;
256
Thomas Gleixner33185c52007-10-23 22:37:24 +0200257#else /* __i386__ */
258
259#undef __HAVE_ARCH_SIG_BITOPS
260
Roland McGrathe1f28772008-01-30 13:30:50 +0100261#endif /* !__i386__ */
262
Thomas Gleixner33185c52007-10-23 22:37:24 +0200263#endif /* __KERNEL__ */
264#endif /* __ASSEMBLY__ */
265
H. Peter Anvin1965aae2008-10-22 22:26:29 -0700266#endif /* _ASM_X86_SIGNAL_H */