]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ | |
29 | /* | |
30 | * Copyright (c) 1982, 1986, 1989, 1991, 1993 | |
31 | * The Regents of the University of California. All rights reserved. | |
32 | * (c) UNIX System Laboratories, Inc. | |
33 | * All or some portions of this file are derived from material licensed | |
34 | * to the University of California by American Telephone and Telegraph | |
35 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | |
36 | * the permission of UNIX System Laboratories, Inc. | |
37 | * | |
38 | * Redistribution and use in source and binary forms, with or without | |
39 | * modification, are permitted provided that the following conditions | |
40 | * are met: | |
41 | * 1. Redistributions of source code must retain the above copyright | |
42 | * notice, this list of conditions and the following disclaimer. | |
43 | * 2. Redistributions in binary form must reproduce the above copyright | |
44 | * notice, this list of conditions and the following disclaimer in the | |
45 | * documentation and/or other materials provided with the distribution. | |
46 | * 3. All advertising materials mentioning features or use of this software | |
47 | * must display the following acknowledgement: | |
48 | * This product includes software developed by the University of | |
49 | * California, Berkeley and its contributors. | |
50 | * 4. Neither the name of the University nor the names of its contributors | |
51 | * may be used to endorse or promote products derived from this software | |
52 | * without specific prior written permission. | |
53 | * | |
54 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
55 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
56 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
57 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
58 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
59 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
60 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
61 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
62 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
63 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
64 | * SUCH DAMAGE. | |
65 | * | |
66 | * @(#)signal.h 8.2 (Berkeley) 1/21/94 | |
67 | */ | |
68 | ||
69 | #ifndef _SYS_SIGNAL_H_ | |
70 | #define _SYS_SIGNAL_H_ | |
71 | ||
91447636 | 72 | #include <sys/cdefs.h> |
9bccf70c A |
73 | #include <sys/appleapiopts.h> |
74 | ||
2d21ac55 A |
75 | #define __DARWIN_NSIG 32 /* counting 0; could be 33 (mask is 1-32) */ |
76 | ||
77 | #if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) | |
78 | #define NSIG __DARWIN_NSIG | |
1c79356b A |
79 | #endif |
80 | ||
81 | #include <machine/signal.h> /* sigcontext; codes for SIGILL, SIGFPE */ | |
82 | ||
83 | #define SIGHUP 1 /* hangup */ | |
84 | #define SIGINT 2 /* interrupt */ | |
85 | #define SIGQUIT 3 /* quit */ | |
86 | #define SIGILL 4 /* illegal instruction (not reset when caught) */ | |
1c79356b | 87 | #define SIGTRAP 5 /* trace trap (not reset when caught) */ |
1c79356b | 88 | #define SIGABRT 6 /* abort() */ |
2d21ac55 | 89 | #if (defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE)) |
91447636 | 90 | #define SIGPOLL 7 /* pollable event ([XSR] generated, not supported) */ |
2d21ac55 | 91 | #else /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b A |
92 | #define SIGIOT SIGABRT /* compatibility */ |
93 | #define SIGEMT 7 /* EMT instruction */ | |
2d21ac55 | 94 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b A |
95 | #define SIGFPE 8 /* floating point exception */ |
96 | #define SIGKILL 9 /* kill (cannot be caught or ignored) */ | |
1c79356b | 97 | #define SIGBUS 10 /* bus error */ |
1c79356b | 98 | #define SIGSEGV 11 /* segmentation violation */ |
1c79356b | 99 | #define SIGSYS 12 /* bad argument to system call */ |
1c79356b A |
100 | #define SIGPIPE 13 /* write on a pipe with no one to read it */ |
101 | #define SIGALRM 14 /* alarm clock */ | |
102 | #define SIGTERM 15 /* software termination signal from kill */ | |
1c79356b | 103 | #define SIGURG 16 /* urgent condition on IO channel */ |
1c79356b A |
104 | #define SIGSTOP 17 /* sendable stop signal not from tty */ |
105 | #define SIGTSTP 18 /* stop signal from tty */ | |
106 | #define SIGCONT 19 /* continue a stopped process */ | |
107 | #define SIGCHLD 20 /* to parent on child stop or exit */ | |
108 | #define SIGTTIN 21 /* to readers pgrp upon background tty read */ | |
109 | #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ | |
2d21ac55 | 110 | #if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) |
1c79356b | 111 | #define SIGIO 23 /* input/output possible signal */ |
91447636 | 112 | #endif |
1c79356b A |
113 | #define SIGXCPU 24 /* exceeded CPU time limit */ |
114 | #define SIGXFSZ 25 /* exceeded file size limit */ | |
115 | #define SIGVTALRM 26 /* virtual time alarm */ | |
116 | #define SIGPROF 27 /* profiling time alarm */ | |
2d21ac55 | 117 | #if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) |
1c79356b A |
118 | #define SIGWINCH 28 /* window size changes */ |
119 | #define SIGINFO 29 /* information request */ | |
120 | #endif | |
121 | #define SIGUSR1 30 /* user defined signal 1 */ | |
122 | #define SIGUSR2 31 /* user defined signal 2 */ | |
123 | ||
2d21ac55 | 124 | #if defined(_ANSI_SOURCE) || __DARWIN_UNIX03 || defined(__cplusplus) |
1c79356b A |
125 | /* |
126 | * Language spec sez we must list exactly one parameter, even though we | |
127 | * actually supply three. Ugh! | |
91447636 | 128 | * SIG_HOLD is chosen to avoid KERN_SIG_* values in <sys/signalvar.h> |
1c79356b A |
129 | */ |
130 | #define SIG_DFL (void (*)(int))0 | |
131 | #define SIG_IGN (void (*)(int))1 | |
91447636 A |
132 | #define SIG_HOLD (void (*)(int))5 |
133 | #define SIG_ERR ((void (*)(int))-1) | |
1c79356b | 134 | #else |
91447636 A |
135 | /* DO NOT REMOVE THE COMMENTED OUT int: fixincludes needs to see them */ |
136 | #define SIG_DFL (void (*)(/*int*/))0 | |
137 | #define SIG_IGN (void (*)(/*int*/))1 | |
138 | #define SIG_HOLD (void (*)(/*int*/))5 | |
139 | #define SIG_ERR ((void (*)(/*int*/))-1) | |
1c79356b A |
140 | #endif |
141 | ||
142 | #ifndef _ANSI_SOURCE | |
91447636 A |
143 | #include <sys/_types.h> |
144 | ||
39236c6e | 145 | #include <machine/_mcontext.h> |
fe8ab488 A |
146 | |
147 | #ifndef KERNEL | |
148 | #include <sys/_pthread/_pthread_attr_t.h> | |
149 | #endif /* KERNEL */ | |
150 | ||
39236c6e A |
151 | #include <sys/_types/_sigaltstack.h> |
152 | #include <sys/_types/_ucontext.h> | |
91447636 | 153 | |
39236c6e | 154 | #include <sys/_types/_pid_t.h> |
39236c6e A |
155 | #include <sys/_types/_sigset_t.h> |
156 | #include <sys/_types/_size_t.h> | |
157 | #include <sys/_types/_uid_t.h> | |
1c79356b | 158 | |
9bccf70c A |
159 | union sigval { |
160 | /* Members as suggested by Annex C of POSIX 1003.1b. */ | |
91447636 A |
161 | int sival_int; |
162 | void *sival_ptr; | |
9bccf70c A |
163 | }; |
164 | ||
b0d623f7 A |
165 | #define SIGEV_NONE 0 /* No async notification */ |
166 | #define SIGEV_SIGNAL 1 /* aio - completion notification */ | |
167 | #define SIGEV_THREAD 3 /* [NOTIMP] [RTS] call notification function */ | |
9bccf70c | 168 | |
fe8ab488 | 169 | #ifndef KERNEL |
55e303ae A |
170 | struct sigevent { |
171 | int sigev_notify; /* Notification type */ | |
172 | int sigev_signo; /* Signal number */ | |
173 | union sigval sigev_value; /* Signal value */ | |
174 | void (*sigev_notify_function)(union sigval); /* Notification function */ | |
175 | pthread_attr_t *sigev_notify_attributes; /* Notification attributes */ | |
176 | }; | |
fe8ab488 | 177 | #endif /* KERNEL */ |
55e303ae | 178 | |
91447636 A |
179 | #ifdef BSD_KERNEL_PRIVATE |
180 | ||
b0d623f7 A |
181 | union user64_sigval { |
182 | struct { | |
183 | uint32_t pad; /* assumes Motorola byte order */ | |
184 | int32_t sival_int; | |
185 | } size_equivalent; | |
186 | user64_addr_t sival_ptr; | |
187 | }; | |
188 | ||
189 | union user32_sigval { | |
190 | /* Members as suggested by Annex C of POSIX 1003.1b. */ | |
191 | int32_t sival_int; | |
192 | user32_addr_t sival_ptr; | |
193 | }; | |
194 | ||
91447636 A |
195 | union user_sigval { |
196 | struct { | |
b0d623f7 A |
197 | uint32_t pad; /* assumes Motorola byte order */ |
198 | int32_t sival_int; | |
91447636 | 199 | } size_equivalent; |
b0d623f7 A |
200 | user_addr_t sival_ptr; |
201 | }; | |
202 | ||
203 | struct user64_sigevent { | |
204 | int sigev_notify; /* Notification type */ | |
205 | int sigev_signo; /* Signal number */ | |
206 | union user64_sigval sigev_value; /* Signal value */ | |
207 | user64_addr_t sigev_notify_function; /* Notify function */ | |
208 | user64_addr_t sigev_notify_attributes; /* Notify attributes */ | |
209 | }; | |
210 | ||
211 | struct user32_sigevent { | |
212 | int sigev_notify; /* Notification type */ | |
213 | int sigev_signo; /* Signal number */ | |
214 | union user32_sigval sigev_value; /* Signal value */ | |
215 | user32_addr_t sigev_notify_function; /* Notify function */ | |
216 | user32_addr_t sigev_notify_attributes; /* Notify attributes */ | |
91447636 A |
217 | }; |
218 | ||
219 | struct user_sigevent { | |
220 | int sigev_notify; /* Notification type */ | |
221 | int sigev_signo; /* Signal number */ | |
222 | union user_sigval sigev_value; /* Signal value */ | |
223 | user_addr_t sigev_notify_function; /* Notify function */ | |
224 | user_addr_t sigev_notify_attributes; /* Notify attributes */ | |
225 | }; | |
226 | ||
91447636 A |
227 | #endif /* BSD_KERNEL_PRIVATE */ |
228 | ||
9bccf70c A |
229 | typedef struct __siginfo { |
230 | int si_signo; /* signal number */ | |
231 | int si_errno; /* errno association */ | |
232 | int si_code; /* signal code */ | |
91447636 A |
233 | pid_t si_pid; /* sending process */ |
234 | uid_t si_uid; /* sender's ruid */ | |
9bccf70c A |
235 | int si_status; /* exit value */ |
236 | void *si_addr; /* faulting instruction */ | |
237 | union sigval si_value; /* signal value */ | |
238 | long si_band; /* band event for SIGPOLL */ | |
2d21ac55 | 239 | unsigned long __pad[7]; /* Reserved for Future Use */ |
9bccf70c A |
240 | } siginfo_t; |
241 | ||
91447636 A |
242 | #ifdef BSD_KERNEL_PRIVATE |
243 | ||
b0d623f7 | 244 | typedef struct user_siginfo { |
91447636 A |
245 | int si_signo; /* signal number */ |
246 | int si_errno; /* errno association */ | |
247 | int si_code; /* signal code */ | |
248 | pid_t si_pid; /* sending process */ | |
249 | uid_t si_uid; /* sender's ruid */ | |
250 | int si_status; /* exit value */ | |
2d21ac55 | 251 | user_addr_t si_addr; /* faulting instruction (see below) */ |
91447636 A |
252 | union user_sigval si_value; /* signal value */ |
253 | user_long_t si_band; /* band event for SIGPOLL */ | |
254 | user_ulong_t pad[7]; /* Reserved for Future Use */ | |
255 | } user_siginfo_t; | |
256 | ||
b0d623f7 A |
257 | typedef struct user64_siginfo { |
258 | int si_signo; /* signal number */ | |
259 | int si_errno; /* errno association */ | |
260 | int si_code; /* signal code */ | |
261 | pid_t si_pid; /* sending process */ | |
262 | uid_t si_uid; /* sender's ruid */ | |
263 | int si_status; /* exit value */ | |
264 | user64_addr_t si_addr; /* faulting instruction (see below) */ | |
265 | union user64_sigval si_value; /* signal value */ | |
266 | user64_long_t si_band; /* band event for SIGPOLL */ | |
267 | user64_ulong_t __pad[7]; /* Reserved for Future Use */ | |
268 | } user64_siginfo_t; | |
269 | ||
270 | typedef struct user32_siginfo { | |
271 | int si_signo; /* signal number */ | |
272 | int si_errno; /* errno association */ | |
273 | int si_code; /* signal code */ | |
274 | pid_t si_pid; /* sending process */ | |
275 | uid_t si_uid; /* sender's ruid */ | |
276 | int si_status; /* exit value */ | |
277 | user32_addr_t si_addr; /* faulting instruction (see below) */ | |
278 | union user32_sigval si_value; /* signal value */ | |
279 | user32_long_t si_band; /* band event for SIGPOLL */ | |
280 | user32_ulong_t __pad[7]; /* Reserved for Future Use */ | |
281 | } user32_siginfo_t; | |
282 | ||
316670eb A |
283 | void siginfo_user_to_user32(user_siginfo_t *, user32_siginfo_t *); |
284 | void siginfo_user_to_user64(user_siginfo_t *, user64_siginfo_t *); | |
285 | ||
91447636 A |
286 | #endif /* BSD_KERNEL_PRIVATE */ |
287 | ||
9bccf70c | 288 | /* |
2d21ac55 A |
289 | * When the signal is SIGILL or SIGFPE, si_addr contains the address of |
290 | * the faulting instruction. | |
291 | * When the signal is SIGSEGV or SIGBUS, si_addr contains the address of | |
292 | * the faulting memory reference. Although for x86 there are cases of SIGSEGV | |
293 | * for which si_addr cannot be determined and is NULL. | |
294 | * If the signal is SIGCHLD, the si_pid field will contain the child process ID, | |
295 | * si_status contains the exit value or signal and | |
296 | * si_uid contains the real user ID of the process that sent the signal. | |
9bccf70c A |
297 | */ |
298 | ||
299 | /* Values for si_code */ | |
300 | ||
301 | /* Codes for SIGILL */ | |
2d21ac55 | 302 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
9bccf70c | 303 | #define ILL_NOOP 0 /* if only I knew... */ |
91447636 A |
304 | #endif |
305 | #define ILL_ILLOPC 1 /* [XSI] illegal opcode */ | |
306 | #define ILL_ILLTRP 2 /* [XSI] illegal trap */ | |
307 | #define ILL_PRVOPC 3 /* [XSI] privileged opcode */ | |
308 | #define ILL_ILLOPN 4 /* [XSI] illegal operand -NOTIMP */ | |
309 | #define ILL_ILLADR 5 /* [XSI] illegal addressing mode -NOTIMP */ | |
310 | #define ILL_PRVREG 6 /* [XSI] privileged register -NOTIMP */ | |
311 | #define ILL_COPROC 7 /* [XSI] coprocessor error -NOTIMP */ | |
312 | #define ILL_BADSTK 8 /* [XSI] internal stack error -NOTIMP */ | |
9bccf70c A |
313 | |
314 | /* Codes for SIGFPE */ | |
2d21ac55 | 315 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
9bccf70c | 316 | #define FPE_NOOP 0 /* if only I knew... */ |
91447636 A |
317 | #endif |
318 | #define FPE_FLTDIV 1 /* [XSI] floating point divide by zero */ | |
319 | #define FPE_FLTOVF 2 /* [XSI] floating point overflow */ | |
320 | #define FPE_FLTUND 3 /* [XSI] floating point underflow */ | |
321 | #define FPE_FLTRES 4 /* [XSI] floating point inexact result */ | |
322 | #define FPE_FLTINV 5 /* [XSI] invalid floating point operation */ | |
323 | #define FPE_FLTSUB 6 /* [XSI] subscript out of range -NOTIMP */ | |
b0d623f7 A |
324 | #define FPE_INTDIV 7 /* [XSI] integer divide by zero */ |
325 | #define FPE_INTOVF 8 /* [XSI] integer overflow */ | |
9bccf70c A |
326 | |
327 | /* Codes for SIGSEGV */ | |
2d21ac55 | 328 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
9bccf70c | 329 | #define SEGV_NOOP 0 /* if only I knew... */ |
91447636 A |
330 | #endif |
331 | #define SEGV_MAPERR 1 /* [XSI] address not mapped to object */ | |
332 | #define SEGV_ACCERR 2 /* [XSI] invalid permission for mapped object */ | |
9bccf70c A |
333 | |
334 | /* Codes for SIGBUS */ | |
2d21ac55 | 335 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
9bccf70c | 336 | #define BUS_NOOP 0 /* if only I knew... */ |
91447636 A |
337 | #endif |
338 | #define BUS_ADRALN 1 /* [XSI] Invalid address alignment */ | |
339 | #define BUS_ADRERR 2 /* [XSI] Nonexistent physical address -NOTIMP */ | |
340 | #define BUS_OBJERR 3 /* [XSI] Object-specific HW error - NOTIMP */ | |
341 | ||
342 | /* Codes for SIGTRAP */ | |
343 | #define TRAP_BRKPT 1 /* [XSI] Process breakpoint -NOTIMP */ | |
344 | #define TRAP_TRACE 2 /* [XSI] Process trace trap -NOTIMP */ | |
9bccf70c A |
345 | |
346 | /* Codes for SIGCHLD */ | |
2d21ac55 | 347 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
9bccf70c | 348 | #define CLD_NOOP 0 /* if only I knew... */ |
91447636 A |
349 | #endif |
350 | #define CLD_EXITED 1 /* [XSI] child has exited */ | |
351 | #define CLD_KILLED 2 /* [XSI] terminated abnormally, no core file */ | |
352 | #define CLD_DUMPED 3 /* [XSI] terminated abnormally, core file */ | |
353 | #define CLD_TRAPPED 4 /* [XSI] traced child has trapped */ | |
354 | #define CLD_STOPPED 5 /* [XSI] child has stopped */ | |
355 | #define CLD_CONTINUED 6 /* [XSI] stopped child has continued */ | |
356 | ||
357 | /* Codes for SIGPOLL */ | |
358 | #define POLL_IN 1 /* [XSR] Data input available */ | |
359 | #define POLL_OUT 2 /* [XSR] Output buffers available */ | |
360 | #define POLL_MSG 3 /* [XSR] Input message available */ | |
361 | #define POLL_ERR 4 /* [XSR] I/O error */ | |
362 | #define POLL_PRI 5 /* [XSR] High priority input available */ | |
363 | #define POLL_HUP 6 /* [XSR] Device disconnected */ | |
9bccf70c A |
364 | |
365 | /* union for signal handlers */ | |
366 | union __sigaction_u { | |
367 | void (*__sa_handler)(int); | |
368 | void (*__sa_sigaction)(int, struct __siginfo *, | |
369 | void *); | |
370 | }; | |
371 | ||
372 | /* Signal vector template for Kernel user boundary */ | |
373 | struct __sigaction { | |
374 | union __sigaction_u __sigaction_u; /* signal handler */ | |
375 | void (*sa_tramp)(void *, int, int, siginfo_t *, void *); | |
376 | sigset_t sa_mask; /* signal mask to apply */ | |
377 | int sa_flags; /* see signal options below */ | |
378 | }; | |
379 | ||
1c79356b A |
380 | /* |
381 | * Signal vector "template" used in sigaction call. | |
382 | */ | |
383 | struct sigaction { | |
9bccf70c | 384 | union __sigaction_u __sigaction_u; /* signal handler */ |
1c79356b A |
385 | sigset_t sa_mask; /* signal mask to apply */ |
386 | int sa_flags; /* see signal options below */ | |
387 | }; | |
91447636 A |
388 | |
389 | #ifdef BSD_KERNEL_PRIVATE | |
390 | #include <machine/types.h> | |
391 | ||
b0d623f7 A |
392 | union __user32_sigaction_u { |
393 | user32_addr_t __sa_handler; | |
394 | user32_addr_t __sa_sigaction; | |
395 | }; | |
396 | ||
397 | struct user32_sigaction { | |
398 | union __user32_sigaction_u __sigaction_u; /* signal handler */ | |
399 | sigset_t sa_mask; /* signal mask to apply */ | |
400 | int sa_flags; /* see signal options below */ | |
401 | }; | |
402 | ||
403 | struct __user32_sigaction { | |
404 | union __user32_sigaction_u __sigaction_u; /* signal handler */ | |
405 | user32_addr_t sa_tramp; | |
406 | sigset_t sa_mask; /* signal mask to apply */ | |
407 | int sa_flags; /* see signal options below */ | |
408 | }; | |
409 | ||
410 | union __user64_sigaction_u { | |
411 | user64_addr_t __sa_handler; | |
412 | user64_addr_t __sa_sigaction; | |
413 | }; | |
414 | ||
415 | struct user64_sigaction { | |
416 | union __user64_sigaction_u __sigaction_u; /* signal handler */ | |
417 | sigset_t sa_mask; /* signal mask to apply */ | |
418 | int sa_flags; /* see signal options below */ | |
419 | }; | |
420 | ||
421 | struct __user64_sigaction { | |
422 | union __user64_sigaction_u __sigaction_u; /* signal handler */ | |
423 | user64_addr_t sa_tramp; /* signal mask to apply */ | |
424 | sigset_t sa_mask; /* signal mask to apply */ | |
425 | int sa_flags; /* see signal options below */ | |
426 | }; | |
427 | ||
428 | union __kern_sigaction_u { | |
91447636 A |
429 | user_addr_t __sa_handler; |
430 | user_addr_t __sa_sigaction; | |
431 | }; | |
432 | ||
b0d623f7 A |
433 | struct kern_sigaction { |
434 | union __kern_sigaction_u __sigaction_u; /* signal handler */ | |
91447636 A |
435 | sigset_t sa_mask; /* signal mask to apply */ |
436 | int sa_flags; /* see signal options below */ | |
437 | }; | |
438 | ||
b0d623f7 A |
439 | struct __kern_sigaction { |
440 | union __kern_sigaction_u __sigaction_u; /* signal handler */ | |
91447636 A |
441 | user_addr_t sa_tramp; /* signal mask to apply */ |
442 | sigset_t sa_mask; /* signal mask to apply */ | |
443 | int sa_flags; /* see signal options below */ | |
444 | }; | |
445 | ||
91447636 A |
446 | #undef SIG_DFL |
447 | #undef SIG_IGN | |
448 | #undef SIG_ERR | |
449 | #define SIG_DFL ((user_addr_t)0LL) | |
450 | #define SIG_IGN ((user_addr_t)1LL) | |
451 | #define SIG_ERR ((user_addr_t)-1LL) | |
452 | ||
453 | #endif /* BSD_KERNEL_PRIVATE */ | |
454 | ||
455 | ||
9bccf70c A |
456 | /* if SA_SIGINFO is set, sa_sigaction is to be used instead of sa_handler. */ |
457 | #define sa_handler __sigaction_u.__sa_handler | |
458 | #define sa_sigaction __sigaction_u.__sa_sigaction | |
459 | ||
1c79356b A |
460 | #define SA_ONSTACK 0x0001 /* take signal on signal stack */ |
461 | #define SA_RESTART 0x0002 /* restart system on signal return */ | |
2d21ac55 A |
462 | #ifdef BSD_KERNEL_PRIVATE |
463 | #define SA_DISABLE 0x0004 /* disable taking signals on alternate stack - for user_sigaltstack.ss_flags only */ | |
464 | #endif /* BSD_KERNEL_PRIVATE */ | |
9bccf70c | 465 | #define SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */ |
91447636 | 466 | #define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */ |
9bccf70c A |
467 | #define SA_NODEFER 0x0010 /* don't mask the signal we're delivering */ |
468 | #define SA_NOCLDWAIT 0x0020 /* don't keep zombies around */ | |
469 | #define SA_SIGINFO 0x0040 /* signal handler with SA_SIGINFO args */ | |
2d21ac55 | 470 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b | 471 | #define SA_USERTRAMP 0x0100 /* do not bounce off kernel's sigtramp */ |
55e303ae A |
472 | /* This will provide 64bit register set in a 32bit user address space */ |
473 | #define SA_64REGSET 0x0200 /* signal handler with SA_SIGINFO args with 64bit regs information */ | |
2d21ac55 A |
474 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
475 | ||
476 | /* the following are the only bits we support from user space, the | |
477 | * rest are for kernel use only. | |
478 | */ | |
479 | #define SA_USERSPACE_MASK (SA_ONSTACK | SA_RESTART | SA_RESETHAND | SA_NOCLDSTOP | SA_NODEFER | SA_NOCLDWAIT | SA_SIGINFO) | |
1c79356b A |
480 | |
481 | /* | |
482 | * Flags for sigprocmask: | |
483 | */ | |
484 | #define SIG_BLOCK 1 /* block specified signal set */ | |
485 | #define SIG_UNBLOCK 2 /* unblock specified signal set */ | |
486 | #define SIG_SETMASK 3 /* set specified signal set */ | |
487 | ||
9bccf70c | 488 | /* POSIX 1003.1b required values. */ |
91447636 A |
489 | #define SI_USER 0x10001 /* [CX] signal from kill() */ |
490 | #define SI_QUEUE 0x10002 /* [CX] signal from sigqueue() */ | |
491 | #define SI_TIMER 0x10003 /* [CX] timer expiration */ | |
492 | #define SI_ASYNCIO 0x10004 /* [CX] aio request completion */ | |
493 | #define SI_MESGQ 0x10005 /* [CX] from message arrival on empty queue */ | |
494 | ||
2d21ac55 | 495 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
91447636 A |
496 | typedef void (*sig_t)(int); /* type of signal function */ |
497 | #endif | |
1c79356b A |
498 | |
499 | /* | |
500 | * Structure used in sigaltstack call. | |
501 | */ | |
91447636 A |
502 | #ifdef BSD_KERNEL_PRIVATE |
503 | ||
b0d623f7 A |
504 | struct user32_sigaltstack { |
505 | user32_addr_t ss_sp; /* signal stack base */ | |
506 | user32_size_t ss_size; /* signal stack length */ | |
507 | int ss_flags; /* SA_DISABLE and/or SA_ONSTACK */ | |
508 | }; | |
509 | ||
510 | struct user64_sigaltstack { | |
511 | user64_addr_t ss_sp; /* signal stack base */ | |
512 | user64_size_t ss_size; /* signal stack length */ | |
513 | int ss_flags; /* SA_DISABLE and/or SA_ONSTACK */ | |
514 | }; | |
515 | ||
516 | struct kern_sigaltstack { | |
91447636 A |
517 | user_addr_t ss_sp; /* signal stack base */ |
518 | user_size_t ss_size; /* signal stack length */ | |
b0d623f7 | 519 | int ss_flags; /* SA_DISABLE and/or SA_ONSTACK */ |
1c79356b | 520 | }; |
9bccf70c | 521 | |
91447636 A |
522 | #endif /* BSD_KERNEL_PRIVATE */ |
523 | ||
9bccf70c A |
524 | #define SS_ONSTACK 0x0001 /* take signal on signal stack */ |
525 | #define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */ | |
55e303ae A |
526 | #define MINSIGSTKSZ 32768 /* (32K)minimum allowable stack */ |
527 | #define SIGSTKSZ 131072 /* (128K)recommended stack size */ | |
1c79356b | 528 | |
2d21ac55 | 529 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b A |
530 | /* |
531 | * 4.3 compatibility: | |
532 | * Signal vector "template" used in sigvec call. | |
533 | */ | |
534 | struct sigvec { | |
9bccf70c | 535 | void (*sv_handler)(int); /* signal handler */ |
1c79356b A |
536 | int sv_mask; /* signal mask to apply */ |
537 | int sv_flags; /* see signal options below */ | |
538 | }; | |
539 | ||
540 | #define SV_ONSTACK SA_ONSTACK | |
541 | #define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */ | |
9bccf70c A |
542 | #define SV_RESETHAND SA_RESETHAND |
543 | #define SV_NODEFER SA_NODEFER | |
544 | #define SV_NOCLDSTOP SA_NOCLDSTOP | |
545 | #define SV_SIGINFO SA_SIGINFO | |
546 | ||
1c79356b | 547 | #define sv_onstack sv_flags /* isn't compatibility wonderful! */ |
2d21ac55 | 548 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b A |
549 | |
550 | /* | |
551 | * Structure used in sigstack call. | |
552 | */ | |
553 | struct sigstack { | |
554 | char *ss_sp; /* signal stack pointer */ | |
555 | int ss_onstack; /* current status */ | |
556 | }; | |
557 | ||
2d21ac55 | 558 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b A |
559 | /* |
560 | * Macro for converting signal number to a mask suitable for | |
561 | * sigblock(). | |
562 | */ | |
563 | #define sigmask(m) (1 << ((m)-1)) | |
564 | ||
39236c6e | 565 | #ifdef KERNEL_PRIVATE |
9bccf70c A |
566 | /* |
567 | * signals delivered on a per-thread basis. | |
568 | */ | |
569 | #define threadmask (sigmask(SIGILL)|sigmask(SIGTRAP)|\ | |
570 | sigmask(SIGIOT)|sigmask(SIGEMT)|\ | |
571 | sigmask(SIGFPE)|sigmask(SIGBUS)|\ | |
572 | sigmask(SIGSEGV)|sigmask(SIGSYS)|\ | |
15129b1c | 573 | sigmask(SIGPIPE)|sigmask(SIGKILL)) |
b0d623f7 A |
574 | |
575 | #define workq_threadmask (threadmask | sigcantmask) | |
576 | ||
577 | /* | |
578 | * Signals carried across exec. | |
579 | */ | |
580 | #define execmask (sigmask(SIGHUP)|sigmask(SIGINT)|\ | |
581 | sigmask(SIGQUIT)|sigmask(SIGKILL)|\ | |
582 | sigmask(SIGTERM)|sigmask(SIGSTOP)|\ | |
583 | sigmask(SIGTSTP)|sigmask(SIGCONT)|\ | |
584 | sigmask(SIGTTIN)|sigmask(SIGTTOU)|\ | |
585 | sigmask(SIGUSR1)|sigmask(SIGUSR2)) | |
586 | ||
39236c6e | 587 | #endif /* KERNEL_PRIVATE */ |
1c79356b A |
588 | |
589 | #define BADSIG SIG_ERR | |
590 | ||
2d21ac55 | 591 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b A |
592 | #endif /* !_ANSI_SOURCE */ |
593 | ||
594 | /* | |
595 | * For historical reasons; programs expect signal's return value to be | |
596 | * defined by <sys/signal.h>. | |
597 | */ | |
598 | __BEGIN_DECLS | |
91447636 | 599 | void (*signal(int, void (*)(int)))(int); |
1c79356b A |
600 | __END_DECLS |
601 | #endif /* !_SYS_SIGNAL_H_ */ |