xref: /titanic_50/usr/src/ucbhead/sys/signal.h (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 /*
31  * University Copyright- Copyright (c) 1982, 1986, 1988
32  * The Regents of the University of California
33  * All Rights Reserved
34  *
35  * University Acknowledgment- Portions of this document are derived from
36  * software developed by the University of California, Berkeley, and its
37  * contributors.
38  */
39 
40 #ifndef _UCB_SYS_SIGNAL_H
41 #define	_UCB_SYS_SIGNAL_H
42 
43 #pragma ident	"%Z%%M%	%I%	%E% SMI"
44 
45 /*
46  * 4.3BSD signal compatibility header
47  *
48  * this file includes all standard SVR4 header info, plus the 4.3BSD
49  * structures  - 4.3BSD signal codes are translated to SVR4 generic
50  * signal codes where applicable
51  */
52 
53 #ifdef	__cplusplus
54 extern "C" {
55 #endif
56 
57 /*
58  * SysV <signal.h>
59  */
60 
61 /* ---- <signal.h> ---- */
62 
63 /*	Copyright (c) 1988 AT&T	*/
64 /*	  All Rights Reserved  	*/
65 
66 
67 #ifndef _SIGNAL_H
68 #define	_SIGNAL_H
69 
70 /* ---- <sys/signal.h> ---- */
71 
72 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
73 /*	  All Rights Reserved  	*/
74 
75 
76 #ifndef _SYS_SIGNAL_H
77 #define	_SYS_SIGNAL_H
78 
79 #define	SIGHUP	1	/* hangup */
80 #define	SIGINT	2	/* interrupt (rubout) */
81 #define	SIGQUIT	3	/* quit (ASCII FS) */
82 #define	SIGILL	4	/* illegal instruction (not reset when caught) */
83 #define	SIGTRAP	5	/* trace trap (not reset when caught) */
84 #define	SIGIOT	6	/* IOT instruction */
85 #define	SIGABRT 6	/* used by abort, replace SIGIOT in the future */
86 #define	SIGEMT	7	/* EMT instruction */
87 #define	SIGFPE	8	/* floating point exception */
88 #define	SIGKILL	9	/* kill (cannot be caught or ignored) */
89 #define	SIGBUS	10	/* bus error */
90 #define	SIGSEGV	11	/* segmentation violation */
91 #define	SIGSYS	12	/* bad argument to system call */
92 #define	SIGPIPE	13	/* write on a pipe with no one to read it */
93 #define	SIGALRM	14	/* alarm clock */
94 #define	SIGTERM	15	/* software termination signal from kill */
95 #define	SIGUSR1	16	/* user defined signal 1 */
96 #define	SIGUSR2	17	/* user defined signal 2 */
97 #define	SIGCLD	18	/* child status change */
98 #define	SIGCHLD	18	/* child status change alias (POSIX) */
99 #define	SIGPWR	19	/* power-fail restart */
100 #define	SIGWINCH 20	/* window size change */
101 #define	SIGURG	21	/* urgent socket condition */
102 #define	SIGPOLL 22	/* pollable event occured */
103 #define	SIGIO	SIGPOLL	/* socket I/O possible (SIGPOLL alias) */
104 #define	SIGSTOP 23	/* stop (cannot be caught or ignored) */
105 #define	SIGTSTP 24	/* user stop requested from tty */
106 #define	SIGCONT 25	/* stopped process has been continued */
107 #define	SIGTTIN 26	/* background tty read attempted */
108 #define	SIGTTOU 27	/* background tty write attempted */
109 #define	SIGVTALRM 28	/* virtual timer expired */
110 #define	SIGPROF 29	/* profiling timer expired */
111 #define	SIGXCPU 30	/* exceeded cpu limit */
112 #define	SIGXFSZ 31	/* exceeded file size limit */
113 #define	SIGWAITING 32	/* process's lwps are blocked */
114 #define	SIGLWP	33	/* special signal used by thread library */
115 
116 #if	defined(__cplusplus)
117 
118 typedef	void SIG_FUNC_TYP(int);
119 typedef	SIG_FUNC_TYP *SIG_TYP;
120 #define	SIG_PF SIG_TYP
121 
122 #define	SIG_DFL	(SIG_PF)0
123 #define	SIG_ERR (SIG_PF)-1
124 #define	SIG_IGN	(SIG_PF)1
125 #define	SIG_HOLD (SIG_PF)2
126 
127 #elif	defined(lint)
128 
129 #define	SIG_DFL	(void(*)(int))0
130 #define	SIG_ERR (void(*)(int))0
131 #define	SIG_IGN	(void (*)(int))0
132 #define	SIG_HOLD (void(*)(int))0
133 
134 #else
135 
136 #define	SIG_DFL	(void(*)())0
137 #define	SIG_ERR	(void(*)())-1
138 #define	SIG_IGN	(void (*)())1
139 #define	SIG_HOLD (void(*)())2
140 
141 #endif
142 
143 #define	SIG_BLOCK	1
144 #define	SIG_UNBLOCK	2
145 #define	SIG_SETMASK	3
146 
147 #define	SIGNO_MASK	0xFF
148 #define	SIGDEFER	0x100
149 #define	SIGHOLD		0x200
150 #define	SIGRELSE	0x400
151 #define	SIGIGNORE	0x800
152 #define	SIGPAUSE	0x1000
153 
154 #if !defined(_STRICT_STDC) || defined(_POSIX_SOURCE)
155 
156 #ifndef	_SIGSET_T
157 #define	_SIGSET_T
158 typedef struct {		/* signal set type */
159 	unsigned int	__sigbits[4];
160 } sigset_t;
161 #endif	/* _SIGSET_T */
162 
163 typedef	struct {
164 	unsigned int	__sigbits[2];
165 } k_sigset_t;
166 
167 struct sigaction {
168 	int sa_flags;
169 #if defined(__cplusplus)
170 	void (*sa_handler)(int);
171 #else
172 	void (*sa_handler)();
173 #endif
174 	sigset_t sa_mask;
175 	int sa_resv[2];
176 };
177 
178 /* this is only valid for SIGCLD */
179 #define	SA_NOCLDSTOP	0x00020000	/* don't send job control SIGCLD's */
180 #endif
181 
182 #if !defined(_STRICT_STDC) && !defined(_POSIX_SOURCE)
183 			/* non-comformant ANSI compilation	*/
184 
185 /* definitions for the sa_flags field */
186 #define	SA_ONSTACK	0x00000001
187 #define	SA_RESETHAND	0x00000002
188 #define	SA_RESTART	0x00000004
189 #define	SA_SIGINFO	0x00000008
190 #define	SA_NODEFER	0x00000010
191 
192 /* this is only valid for SIGCLD */
193 #define	SA_NOCLDWAIT	0x00010000	/* don't save zombie children	 */
194 
195 #define	NSIG	34	/* valid signals range from 1 to NSIG-1 */
196 #define	MAXSIG	33	/* size of u_signal[], NSIG-1 <= MAXSIG */
197 
198 #define	MINSIGSTKSZ	2048
199 #define	SIGSTKSZ	8192
200 
201 #define	SS_ONSTACK	0x00000001
202 #define	SS_DISABLE	0x00000002
203 
204 struct sigaltstack {
205 	char	*ss_sp;
206 	int	ss_size;
207 	int	ss_flags;
208 };
209 
210 typedef struct sigaltstack stack_t;
211 
212 #endif /* __STDC__ && !POSIX */
213 
214 
215 #endif /* _SYS_SIGNAL_H */
216 
217 /* ---- end of SysV <sys/signal.h> ---- */
218 
219 typedef int	sig_atomic_t;
220 
221 #if defined(__STDC__)
222 
223 extern const char *_sys_siglist[];
224 extern const int _sys_nsig;
225 
226 #ifdef __cplusplus
227 extern "C" SIG_PF signal(int, SIG_PF);
228 #else
229 extern void (*signal(int, void (*)(int)))(int);
230 #endif
231 extern int raise(int);
232 
233 #if !defined(_STRICT_STDC) || defined(_POSIX_SOURCE) || \
234 	defined(_XOPEN_SOURCE)
235 extern int kill(pid_t, int);
236 extern int sigaction(int, const struct sigaction *, struct sigaction *);
237 extern int sigaddset(sigset_t *, int);
238 extern int sigdelset(sigset_t *, int);
239 extern int sigemptyset(sigset_t *);
240 extern int sigfillset(sigset_t *);
241 extern int sigismember(const sigset_t *, int);
242 extern int sigpending(sigset_t *);
243 extern int sigprocmask(int, const sigset_t *, sigset_t *);
244 extern int sigsuspend(const sigset_t *);
245 #endif
246 
247 #if !defined(_STRICT_STDC) && !defined(_POSIX_SOURCE)
248 extern int gsignal(int);
249 extern void (*sigset(int, void (*)(int)))(int);
250 extern int sighold(int);
251 extern int sigrelse(int);
252 extern int sigignore(int);
253 extern int sigpause(int);
254 extern int (*ssignal(int, int (*)(int)))(int);
255 extern int sigaltstack(const stack_t *, stack_t *);
256 /* extern int sigsend(idtype_t, id_t, int); */
257 /* extern int sigsendset(const procset_t *, int); */
258 #endif
259 
260 #else
261 
262 extern char *_sys_siglist[];
263 extern int _sys_nsig;
264 
265 extern	void(*signal())();
266 extern  void(*sigset())();
267 
268 #endif	/* __STDC__ */
269 
270 #endif	/* _SIGNAL_H */
271 /* ---- end of SysV <signal.h> ---- */
272 
273 #define	sigmask(m)	(m > 32 ? 0 : (1 << ((m)-1)))
274 
275 /*
276  * 4.3BSD structure used in sigstack call.
277  */
278 
279 struct  sigstack {
280 	char	*ss_sp;			/* signal stack pointer */
281 	int	ss_onstack;		/* current status */
282 };
283 
284 #define	SV_ONSTACK	0x0001  /* take signal on signal stack */
285 #define	SV_INTERRUPT    0x0002  /* do not restart system on signal return */
286 #define	SV_RESETHAND    0x0004  /* reset handler to SIG_DFL when signal taken */
287 
288 #define	sv_onstack sv_flags
289 
290 struct  sigcontext {
291 	int	sc_onstack;		/* sigstack state to restore */
292 	int	sc_mask;		/* signal mask to restore */
293 #ifdef u3b2
294 	int	sc_sp;			/* sp to restore */
295 	int	sc_fp;			/* fp to restore */
296 	int	sc_ap;			/* ap to restore */
297 	int	sc_pc;			/* pc to restore */
298 	int	sc_ps;			/* psw to restore */
299 #endif
300 #ifdef vax
301 	int	sc_sp;			/* sp to restore */
302 	int	sc_fp;			/* fp to restore */
303 	int	sc_ap;			/* ap to restore */
304 	int	sc_pc;			/* pc to restore */
305 	int	sc_ps;			/* psl to restore */
306 #endif /* vax */
307 #ifdef mc68000
308 	int	sc_sp;			/* sp to restore */
309 	int	sc_pc;			/* pc to retore */
310 	int	sc_ps;			/* psl to restore */
311 #endif /* mc68000 */
312 #ifdef __sparc
313 #define	MAXWINDOW	31		/* max usable windows in sparc */
314 	long	sc_sp;			/* sp to restore */
315 	long	sc_pc;			/* pc to retore */
316 	long	sc_npc;			/* next pc to restore */
317 	long	sc_psr;			/* psr to restore */
318 					/* aliased to REG_CCR for sparcv9 */
319 	long	sc_g1;			/* register that must be restored */
320 	long	sc_o0;
321 	int	sc_wbcnt;		/* number of outstanding windows */
322 	char	*sc_spbuf[MAXWINDOW];	/* sp's for each wbuf */
323 	long	sc_wbuf[MAXWINDOW][16];	/* outstanding window save buffer */
324 #endif /* __sparc */
325 #if defined(__amd64)
326 	long	sc_sp;			/* sp to restore */
327 	long	sc_pc;			/* pc to retore */
328 	long	sc_ps;			/* psl to restore */
329 	long	sc_rax;			/* rax to restore */
330 	long	sc_rdx;			/* rdx to restore */
331 #define	sc_r0	sc_rax
332 #define	sc_r1	sc_rdx
333 #elif defined(__i386)
334 	int	sc_sp;			/* sp to restore */
335 	int	sc_pc;			/* pc to retore */
336 	int	sc_ps;			/* psl to restore */
337 	int	sc_eax;			/* eax to restore */
338 	int	sc_edx;			/* edx to restore */
339 #define	sc_r0	sc_eax
340 #define	sc_r1	sc_edx
341 #endif
342 };
343 
344 /*
345  * 4.3BSD signal vector structure used in sigvec call.
346  */
347 struct  sigvec {
348 #if defined(__cplusplus)
349 	void	(*sv_handler)(int, int, struct sigcontext *, char *);
350 #else
351 	void	(*sv_handler)();	/* signal handler */
352 #endif
353 	int	sv_mask;		/* signal mask to apply */
354 	int	sv_flags;		/* see signal options below */
355 };
356 
357 #if defined(__STDC__)
358 extern int sigvec(int, struct sigvec *, struct sigvec *);
359 extern int sigblock(int);
360 extern int sigsetmask(int);
361 #endif
362 
363 /*
364  * Signal codes taken verbatim from SunOS4.1
365  */
366 #ifdef	vax
367 #define	    ILL_RESAD_FAULT	0x0	/* reserved addressing fault */
368 #define	    ILL_PRIVIN_FAULT	0x1	/* privileged instruction fault */
369 #define	    ILL_RESOP_FAULT	0x2	/* reserved operand fault */
370 #endif	/* vax */
371 #ifdef	mc68000
372 #define	    ILL_ILLINSTR_FAULT	0x10	/* illegal instruction fault */
373 #define	    ILL_PRIVVIO_FAULT	0x20	/* privilege violation fault */
374 #define	    ILL_COPROCERR_FAULT	0x34	/* [coprocessor protocol error fault] */
375 #define	    ILL_TRAP1_FAULT	0x84	/* trap #1 fault */
376 #define	    ILL_TRAP2_FAULT	0x88	/* trap #2 fault */
377 #define	    ILL_TRAP3_FAULT	0x8c	/* trap #3 fault */
378 #define	    ILL_TRAP4_FAULT	0x90	/* trap #4 fault */
379 #define	    ILL_TRAP5_FAULT	0x94	/* trap #5 fault */
380 #define	    ILL_TRAP6_FAULT	0x98	/* trap #6 fault */
381 #define	    ILL_TRAP7_FAULT	0x9c	/* trap #7 fault */
382 #define	    ILL_TRAP8_FAULT	0xa0	/* trap #8 fault */
383 #define	    ILL_TRAP9_FAULT	0xa4	/* trap #9 fault */
384 #define	    ILL_TRAP10_FAULT	0xa8	/* trap #10 fault */
385 #define	    ILL_TRAP11_FAULT	0xac	/* trap #11 fault */
386 #define	    ILL_TRAP12_FAULT	0xb0	/* trap #12 fault */
387 #define	    ILL_TRAP13_FAULT	0xb4	/* trap #13 fault */
388 #define	    ILL_TRAP14_FAULT	0xb8	/* trap #14 fault */
389 #endif	/* mc68000 */
390 #ifdef	sparc
391 #define	    ILL_STACK		0x00	/* bad stack */
392 #define	    ILL_ILLINSTR_FAULT	0x02	/* illegal instruction fault */
393 #define	    ILL_PRIVINSTR_FAULT	0x03	/* privileged instruction fault */
394 /* codes from 0x80 to 0xff are software traps */
395 #define	    ILL_TRAP_FAULT(n)	((n)+0x80) /* trap n fault */
396 #endif	/* sparc */
397 #if defined(__i386) || defined(__amd64)
398 #define	    ILL_ILLINSTR_FAULT	0x02	/* illegal instruction fault */
399 #endif
400 
401 #ifdef	mc68000
402 #define	    EMT_EMU1010		0x28	/* line 1010 emulator trap */
403 #define	    EMT_EMU1111		0x2c	/* line 1111 emulator trap */
404 #endif	/* mc68000 */
405 #ifdef	sparc
406 #define	    EMT_TAG		0x0a	/* tag overflow */
407 #endif	/* sparc */
408 
409 #ifdef	vax
410 #define	    FPE_INTOVF_TRAP	0x1	/* integer overflow */
411 #define	    FPE_INTDIV_TRAP	0x2	/* integer divide by zero */
412 #define	    FPE_FLTOVF_TRAP	0x3	/* floating overflow */
413 #define	    FPE_FLTDIV_TRAP	0x4	/* floating/decimal divide by zero */
414 #define	    FPE_FLTUND_TRAP	0x5	/* floating underflow */
415 #define	    FPE_DECOVF_TRAP	0x6	/* decimal overflow */
416 #define	    FPE_SUBRNG_TRAP	0x7	/* subscript out of range */
417 #define	    FPE_FLTOVF_FAULT	0x8	/* floating overflow fault */
418 #define	    FPE_FLTDIV_FAULT	0x9	/* divide by zero floating fault */
419 #define	    FPE_FLTUND_FAULT	0xa	/* floating underflow fault */
420 #endif	/* vax */
421 #ifdef	mc68000
422 #define	    FPE_INTDIV_TRAP	0x14	/* integer divide by zero */
423 #define	    FPE_CHKINST_TRAP	0x18	/* CHK [CHK2] instruction */
424 #define	    FPE_TRAPV_TRAP	0x1c	/* TRAPV [cpTRAPcc TRAPcc] instr */
425 #define	    FPE_FLTBSUN_TRAP	0xc0	/* [branch or set on unordered cond] */
426 #define	    FPE_FLTINEX_TRAP	0xc4	/* [floating inexact result] */
427 #define	    FPE_FLTDIV_TRAP	0xc8	/* [floating divide by zero] */
428 #define	    FPE_FLTUND_TRAP	0xcc	/* [floating underflow] */
429 #define	    FPE_FLTOPERR_TRAP	0xd0	/* [floating operand error] */
430 #define	    FPE_FLTOVF_TRAP	0xd4	/* [floating overflow] */
431 #define	    FPE_FLTNAN_TRAP	0xd8	/* [floating Not-A-Number] */
432 #ifdef	sun
433 #define	    FPE_FPA_ENABLE	0x400	/* [FPA not enabled] */
434 #define	    FPE_FPA_ERROR	0x404	/* [FPA arithmetic exception] */
435 #endif	/* sun */
436 #endif	/* mc68000 */
437 #ifdef	sparc
438 #define	    FPE_INTOVF_TRAP	0x1	/* integer overflow */
439 #define	    FPE_STARTSIG_TRAP	0x2	/* process using fp */
440 #define	    FPE_INTDIV_TRAP	0x14	/* integer divide by zero */
441 #define	    FPE_FLTINEX_TRAP	0xc4	/* [floating inexact result] */
442 #define	    FPE_FLTDIV_TRAP	0xc8	/* [floating divide by zero] */
443 #define	    FPE_FLTUND_TRAP	0xcc	/* [floating underflow] */
444 #define	    FPE_FLTOPERR_TRAP	0xd0	/* [floating operand error] */
445 #define	    FPE_FLTOVF_TRAP	0xd4	/* [floating overflow] */
446 #endif	/* sparc */
447 
448 /*
449  * The codes for SIGBUS and SIGSEGV are described in <vm/faultcode.h>
450  * These are the same between SunOS4.1 and SunOS5.0
451  */
452 
453 #include <vm/faultcode.h>
454 
455 #define	    BUS_HWERR	FC_HWERR	/* misc hardware error (e.g. timeout) */
456 #define	    BUS_ALIGN	FC_ALIGN	/* hardware alignment error */
457 #ifdef	BUS_OBJERR	/* namespace conflict with SysV */
458 #undef	BUS_OBJERR
459 #endif
460 #define	    BUS_OBJERR	FC_OBJERR	/* object returned errno value */
461 /*
462  * The BUS_CODE(code) will be one of the above.  In the BUS_OBJERR case,
463  * doing a BUS_ERRNO(code) gives an errno value reported by the underlying
464  * file object mapped at the fault address.  Note that this appears to be
465  * duplicated with the segmentation fault case below -- unfortunate, since
466  * the specification has always claimed that such errors produce SIGBUS.
467  * The segmentation cases are left defined as a transition aid.
468  */
469 #define	    BUS_CODE(C)		FC_CODE(C)
470 #define	    BUS_ERRNO(C)	FC_ERRNO(C)
471 
472 #define	    SEGV_NOMAP	FC_NOMAP	/* no mapping at the fault address */
473 #define	    SEGV_PROT	FC_PROT		/* access exceeded protections */
474 #define	    SEGV_OBJERR	FC_OBJERR	/* object returned errno value */
475 /*
476  * The SEGV_CODE(code) will be SEGV_NOMAP, SEGV_PROT, or SEGV_OBJERR.
477  * In the SEGV_OBJERR case, doing a SEGV_ERRNO(code) gives an errno value
478  * reported by the underlying file object mapped at the fault address.
479  */
480 #define	    SEGV_CODE(C)	FC_CODE(C)
481 #define	    SEGV_ERRNO(C)	FC_ERRNO(C)
482 #define	    SEGV_MAKE_ERR(e)	FC_MAKE_ERR(e)
483 
484 #define	SIG_NOADDR	((char *)~0)
485 
486 #if defined(lint)
487 #define	BADSIG (void(*)())0
488 #else
489 #define	BADSIG (void(*)())-1
490 #endif
491 
492 #ifdef	__cplusplus
493 }
494 #endif
495 
496 #endif /* _UCB_SYS_SIGNAL_H */
497