ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-i386 / signal.h
1 #ifndef _ASMi386_SIGNAL_H
2 #define _ASMi386_SIGNAL_H
3
4 #include <linux/types.h>
5 #include <linux/linkage.h>
6 #include <linux/time.h>
7
8 /* Avoid too many header ordering problems.  */
9 struct siginfo;
10
11 #ifdef __KERNEL__
12 /* Most things should be clean enough to redefine this at will, if care
13    is taken to make libc match.  */
14
15 #define _NSIG           64
16 #define _NSIG_BPW       32
17 #define _NSIG_WORDS     (_NSIG / _NSIG_BPW)
18
19 typedef unsigned long old_sigset_t;             /* at least 32 bits */
20
21 typedef struct {
22         unsigned long sig[_NSIG_WORDS];
23 } sigset_t;
24
25 #else
26 /* Here we must cater to libcs that poke about in kernel headers.  */
27
28 #define NSIG            32
29 typedef unsigned long sigset_t;
30
31 #endif /* __KERNEL__ */
32
33 #define SIGHUP           1
34 #define SIGINT           2
35 #define SIGQUIT          3
36 #define SIGILL           4
37 #define SIGTRAP          5
38 #define SIGABRT          6
39 #define SIGIOT           6
40 #define SIGBUS           7
41 #define SIGFPE           8
42 #define SIGKILL          9
43 #define SIGUSR1         10
44 #define SIGSEGV         11
45 #define SIGUSR2         12
46 #define SIGPIPE         13
47 #define SIGALRM         14
48 #define SIGTERM         15
49 #define SIGSTKFLT       16
50 #define SIGCHLD         17
51 #define SIGCONT         18
52 #define SIGSTOP         19
53 #define SIGTSTP         20
54 #define SIGTTIN         21
55 #define SIGTTOU         22
56 #define SIGURG          23
57 #define SIGXCPU         24
58 #define SIGXFSZ         25
59 #define SIGVTALRM       26
60 #define SIGPROF         27
61 #define SIGWINCH        28
62 #define SIGIO           29
63 #define SIGPOLL         SIGIO
64 /*
65 #define SIGLOST         29
66 */
67 #define SIGPWR          30
68 #define SIGSYS          31
69 #define SIGUNUSED       31
70
71 /* These should not be considered constants from userland.  */
72 #define SIGRTMIN        32
73 #define SIGRTMAX        _NSIG
74
75 /*
76  * SA_FLAGS values:
77  *
78  * SA_ONSTACK indicates that a registered stack_t will be used.
79  * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the
80  * SA_RESTART flag to get restarting signals (which were the default long ago)
81  * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
82  * SA_RESETHAND clears the handler when the signal is delivered.
83  * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
84  * SA_NODEFER prevents the current signal from being masked in the handler.
85  *
86  * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
87  * Unix names RESETHAND and NODEFER respectively.
88  */
89 #define SA_NOCLDSTOP    0x00000001u
90 #define SA_NOCLDWAIT    0x00000002u
91 #define SA_SIGINFO      0x00000004u
92 #define SA_ONSTACK      0x08000000u
93 #define SA_RESTART      0x10000000u
94 #define SA_NODEFER      0x40000000u
95 #define SA_RESETHAND    0x80000000u
96
97 #define SA_NOMASK       SA_NODEFER
98 #define SA_ONESHOT      SA_RESETHAND
99 #define SA_INTERRUPT    0x20000000 /* dummy -- ignored */
100
101 #define SA_RESTORER     0x04000000
102
103 /* 
104  * sigaltstack controls
105  */
106 #define SS_ONSTACK      1
107 #define SS_DISABLE      2
108
109 #define MINSIGSTKSZ     2048
110 #define SIGSTKSZ        8192
111
112 #ifdef __KERNEL__
113
114 /*
115  * These values of sa_flags are used only by the kernel as part of the
116  * irq handling routines.
117  *
118  * SA_INTERRUPT is also used by the irq handling routines.
119  * SA_SHIRQ is for shared interrupt support on PCI and EISA.
120  */
121 #define SA_PROBE                SA_ONESHOT
122 #define SA_SAMPLE_RANDOM        SA_RESTART
123 #define SA_SHIRQ                0x04000000
124 #endif
125
126 #define SIG_BLOCK          0    /* for blocking signals */
127 #define SIG_UNBLOCK        1    /* for unblocking signals */
128 #define SIG_SETMASK        2    /* for setting the signal mask */
129
130 /* Type of a signal handler.  */
131 typedef void (*__sighandler_t)(int);
132
133 #define SIG_DFL ((__sighandler_t)0)     /* default signal handling */
134 #define SIG_IGN ((__sighandler_t)1)     /* ignore signal */
135 #define SIG_ERR ((__sighandler_t)-1)    /* error return from signal */
136
137 #ifdef __KERNEL__
138 struct old_sigaction {
139         __sighandler_t sa_handler;
140         old_sigset_t sa_mask;
141         unsigned long sa_flags;
142         void (*sa_restorer)(void);
143 };
144
145 struct sigaction {
146         __sighandler_t sa_handler;
147         unsigned long sa_flags;
148         void (*sa_restorer)(void);
149         sigset_t sa_mask;               /* mask last for extensibility */
150 };
151
152 struct k_sigaction {
153         struct sigaction sa;
154 };
155 #else
156 /* Here we must cater to libcs that poke about in kernel headers.  */
157
158 struct sigaction {
159         union {
160           __sighandler_t _sa_handler;
161           void (*_sa_sigaction)(int, struct siginfo *, void *);
162         } _u;
163         sigset_t sa_mask;
164         unsigned long sa_flags;
165         void (*sa_restorer)(void);
166 };
167
168 #define sa_handler      _u._sa_handler
169 #define sa_sigaction    _u._sa_sigaction
170
171 #endif /* __KERNEL__ */
172
173 typedef struct sigaltstack {
174         void *ss_sp;
175         int ss_flags;
176         size_t ss_size;
177 } stack_t;
178
179 #ifdef __KERNEL__
180 #include <asm/sigcontext.h>
181
182 #define __HAVE_ARCH_SIG_BITOPS
183
184 static __inline__ void sigaddset(sigset_t *set, int _sig)
185 {
186         __asm__("btsl %1,%0" : "=m"(*set) : "Ir"(_sig - 1) : "cc");
187 }
188
189 static __inline__ void sigdelset(sigset_t *set, int _sig)
190 {
191         __asm__("btrl %1,%0" : "=m"(*set) : "Ir"(_sig - 1) : "cc");
192 }
193
194 static __inline__ int __const_sigismember(sigset_t *set, int _sig)
195 {
196         unsigned long sig = _sig - 1;
197         return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
198 }
199
200 static __inline__ int __gen_sigismember(sigset_t *set, int _sig)
201 {
202         int ret;
203         __asm__("btl %2,%1\n\tsbbl %0,%0"
204                 : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc");
205         return ret;
206 }
207
208 #define sigismember(set,sig)                    \
209         (__builtin_constant_p(sig) ?            \
210          __const_sigismember((set),(sig)) :     \
211          __gen_sigismember((set),(sig)))
212
213 static __inline__ int sigfindinword(unsigned long word)
214 {
215         __asm__("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc");
216         return word;
217 }
218
219 struct pt_regs;
220 extern int FASTCALL(do_signal(struct pt_regs *regs, sigset_t *oldset));
221 #define ptrace_signal_deliver(regs, cookie) do { } while (0)
222
223 #endif /* __KERNEL__ */
224
225 #endif