xref: /titanic_52/usr/src/lib/libbc/inc/include/sys/signal.h (revision bdfc6d18da790deeec2e0eb09c625902defe2498)
1 /*
2  * Copyright (c) 1982 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  */
6 
7 /*
8  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
9  * Use is subject to license terms.
10  */
11 
12 #ifndef	__sys_signal_h
13 #define	__sys_signal_h
14 
15 #pragma ident	"%Z%%M%	%I%	%E% SMI"
16 
17 #include <vm/faultcode.h>
18 #define	NSIG	32
19 
20 /*
21  * If any signal defines (SIG*) are added, deleted, or changed, the same
22  * changes must be made in /usr/include/signal.h as well.
23  */
24 #define	SIGHUP	1	/* hangup */
25 #define	SIGINT	2	/* interrupt */
26 #define	SIGQUIT	3	/* quit */
27 #define	SIGILL	4	/* illegal instruction (not reset when caught) */
28 #ifdef	vax
29 #define	    ILL_RESAD_FAULT	0x0	/* reserved addressing fault */
30 #define	    ILL_PRIVIN_FAULT	0x1	/* privileged instruction fault */
31 #define	    ILL_RESOP_FAULT	0x2	/* reserved operand fault */
32 /* CHME, CHMS, CHMU are not yet given back to users reasonably */
33 #endif	vax
34 #ifdef	mc68000
35 #define	    ILL_ILLINSTR_FAULT	0x10	/* illegal instruction fault */
36 #define	    ILL_PRIVVIO_FAULT	0x20	/* privilege violation fault */
37 #define	    ILL_COPROCERR_FAULT	0x34	/* [coprocessor protocol error fault] */
38 #define	    ILL_TRAP1_FAULT	0x84	/* trap #1 fault */
39 #define	    ILL_TRAP2_FAULT	0x88	/* trap #2 fault */
40 #define	    ILL_TRAP3_FAULT	0x8c	/* trap #3 fault */
41 #define	    ILL_TRAP4_FAULT	0x90	/* trap #4 fault */
42 #define	    ILL_TRAP5_FAULT	0x94	/* trap #5 fault */
43 #define	    ILL_TRAP6_FAULT	0x98	/* trap #6 fault */
44 #define	    ILL_TRAP7_FAULT	0x9c	/* trap #7 fault */
45 #define	    ILL_TRAP8_FAULT	0xa0	/* trap #8 fault */
46 #define	    ILL_TRAP9_FAULT	0xa4	/* trap #9 fault */
47 #define	    ILL_TRAP10_FAULT	0xa8	/* trap #10 fault */
48 #define	    ILL_TRAP11_FAULT	0xac	/* trap #11 fault */
49 #define	    ILL_TRAP12_FAULT	0xb0	/* trap #12 fault */
50 #define	    ILL_TRAP13_FAULT	0xb4	/* trap #13 fault */
51 #define	    ILL_TRAP14_FAULT	0xb8	/* trap #14 fault */
52 #endif	mc68000
53 #ifdef	sparc
54 #define	    ILL_STACK		0x00	/* bad stack */
55 #define	    ILL_ILLINSTR_FAULT	0x02	/* illegal instruction fault */
56 #define	    ILL_PRIVINSTR_FAULT	0x03	/* privileged instruction fault */
57 /* codes from 0x80 to 0xff are software traps */
58 #define	    ILL_TRAP_FAULT(n)	((n)+0x80) /* trap n fault */
59 #endif	sparc
60 #if defined(__i386) || defined(__amd64)
61 #define	    ILL_ILLINSTR_FAULT	0x02	/* illegal instruction fault */
62 #endif
63 #define	SIGTRAP	5	/* trace trap (not reset when caught) */
64 #define	SIGIOT	6	/* IOT instruction */
65 #define	SIGABRT 6	/* used by abort, replace SIGIOT in the future */
66 #define	SIGEMT	7	/* EMT instruction */
67 #ifdef	mc68000
68 #define	    EMT_EMU1010		0x28	/* line 1010 emulator trap */
69 #define	    EMT_EMU1111		0x2c	/* line 1111 emulator trap */
70 #endif	mc68000
71 #ifdef	sparc
72 #define	    EMT_TAG		0x0a	/* tag overflow */
73 #endif	sparc
74 #define	SIGFPE	8	/* floating point exception */
75 #ifdef	vax
76 #define	    FPE_INTOVF_TRAP	0x1	/* integer overflow */
77 #define	    FPE_INTDIV_TRAP	0x2	/* integer divide by zero */
78 #define	    FPE_FLTOVF_TRAP	0x3	/* floating overflow */
79 #define	    FPE_FLTDIV_TRAP	0x4	/* floating/decimal divide by zero */
80 #define	    FPE_FLTUND_TRAP	0x5	/* floating underflow */
81 #define	    FPE_DECOVF_TRAP	0x6	/* decimal overflow */
82 #define	    FPE_SUBRNG_TRAP	0x7	/* subscript out of range */
83 #define	    FPE_FLTOVF_FAULT	0x8	/* floating overflow fault */
84 #define	    FPE_FLTDIV_FAULT	0x9	/* divide by zero floating fault */
85 #define	    FPE_FLTUND_FAULT	0xa	/* floating underflow fault */
86 #endif	vax
87 #ifdef	mc68000
88 #define	    FPE_INTDIV_TRAP	0x14	/* integer divide by zero */
89 #define	    FPE_CHKINST_TRAP	0x18	/* CHK [CHK2] instruction */
90 #define	    FPE_TRAPV_TRAP	0x1c	/* TRAPV [cpTRAPcc TRAPcc] instr */
91 #define	    FPE_FLTBSUN_TRAP	0xc0	/* [branch or set on unordered cond] */
92 #define	    FPE_FLTINEX_TRAP	0xc4	/* [floating inexact result] */
93 #define	    FPE_FLTDIV_TRAP	0xc8	/* [floating divide by zero] */
94 #define	    FPE_FLTUND_TRAP	0xcc	/* [floating underflow] */
95 #define	    FPE_FLTOPERR_TRAP	0xd0	/* [floating operand error] */
96 #define	    FPE_FLTOVF_TRAP	0xd4	/* [floating overflow] */
97 #define	    FPE_FLTNAN_TRAP	0xd8	/* [floating Not-A-Number] */
98 #ifdef	sun
99 #define	    FPE_FPA_ENABLE	0x400	/* [FPA not enabled] */
100 #define	    FPE_FPA_ERROR	0x404	/* [FPA arithmetic exception] */
101 #endif	sun
102 #endif	mc68000
103 #ifdef	sparc
104 #define	    FPE_INTOVF_TRAP	0x1	/* integer overflow */
105 #define	    FPE_STARTSIG_TRAP	0x2	/* process using fp */
106 #define	    FPE_INTDIV_TRAP	0x14	/* integer divide by zero */
107 #define	    FPE_FLTINEX_TRAP	0xc4	/* [floating inexact result] */
108 #define	    FPE_FLTDIV_TRAP	0xc8	/* [floating divide by zero] */
109 #define	    FPE_FLTUND_TRAP	0xcc	/* [floating underflow] */
110 #define	    FPE_FLTOPERR_TRAP	0xd0	/* [floating operand error] */
111 #define	    FPE_FLTOVF_TRAP	0xd4	/* [floating overflow] */
112 #endif	sparc
113 #define	SIGKILL	9	/* kill (cannot be caught or ignored) */
114 /*
115  * The codes for SIGBUS and SIGSEGV are described in <vm/faultcode.h>
116  */
117 #define	SIGBUS	10	/* bus error */
118 #define	    BUS_HWERR	FC_HWERR	/* misc hardware error (e.g. timeout) */
119 #define	    BUS_ALIGN	FC_ALIGN	/* hardware alignment error */
120 #define	    BUS_OBJERR	FC_OBJERR	/* object returned errno value */
121 /*
122  * The BUS_CODE(code) will be one of the above.  In the BUS_OBJERR case,
123  * doing a BUS_ERRNO(code) gives an errno value reported by the underlying
124  * file object mapped at the fault address.  Note that this appears to be
125  * duplicated with the segmentation fault case below -- unfortunate, since
126  * the specification has always claimed that such errors produce SIGBUS.
127  * The segmentation cases are left defined as a transition aid.
128  */
129 #define	    BUS_CODE(C)		FC_CODE(C)
130 #define	    BUS_ERRNO(C)	FC_ERRNO(C)
131 #define	SIGSEGV	11	/* segmentation violation */
132 #define	    SEGV_NOMAP	FC_NOMAP	/* no mapping at the fault address */
133 #define	    SEGV_PROT	FC_PROT		/* access exceeded protections */
134 #define	    SEGV_OBJERR	FC_OBJERR	/* object returned errno value */
135 /*
136  * The SEGV_CODE(code) will be SEGV_NOMAP, SEGV_PROT, or SEGV_OBJERR.
137  * In the SEGV_OBJERR case, doing a SEGV_ERRNO(code) gives an errno value
138  * reported by the underlying file object mapped at the fault address.
139  */
140 #define	    SEGV_CODE(C)	FC_CODE(C)
141 #define	    SEGV_ERRNO(C)	FC_ERRNO(C)
142 #define	SIGSYS	12	/* bad argument to system call */
143 #define	SIGPIPE	13	/* write on a pipe with no one to read it */
144 #define	SIGALRM	14	/* alarm clock */
145 #define	SIGTERM	15	/* software termination signal from kill */
146 #define	SIGURG	16	/* urgent condition on IO channel */
147 #define	SIGSTOP	17	/* sendable stop signal not from tty */
148 #define	SIGTSTP	18	/* stop signal from tty */
149 #define	SIGCONT	19	/* continue a stopped process */
150 #define	SIGCHLD	20	/* to parent on child stop or exit */
151 #define	SIGCLD	20	/* System V name for SIGCHLD */
152 #define	SIGTTIN	21	/* to readers pgrp upon background tty read */
153 #define	SIGTTOU	22	/* like TTIN for output if (tp->t_local&LTOSTOP) */
154 #define	SIGIO	23	/* input/output possible signal */
155 #define	SIGPOLL	SIGIO	/* System V name for SIGIO */
156 #define	SIGXCPU	24	/* exceeded CPU time limit */
157 #define	SIGXFSZ	25	/* exceeded file size limit */
158 #define	SIGVTALRM 26	/* virtual time alarm */
159 #define	SIGPROF	27	/* profiling time alarm */
160 #define	SIGWINCH 28	/* window changed */
161 #define	SIGLOST 29	/* resource lost (eg, record-lock lost) */
162 #define	SIGUSR1 30	/* user defined signal 1 */
163 #define	SIGUSR2 31	/* user defined signal 2 */
164 /*
165  * If addr cannot be computed it is set to SIG_NOADDR.
166  */
167 #define	SIG_NOADDR	((char *)~0)
168 
169 #if	!defined(KERNEL)  &&  !defined(LOCORE)
170 void	(*signal())();
171 /*
172  * Define BSD 4.1 reliable signals for SVID compatibility.
173  * These functions may go away in a future release.
174  */
175 void  (*sigset())();
176 int   sighold();
177 int   sigrelse();
178 int   sigignore();
179 #endif	!KERNEL  &&  !LOCORE
180 
181 #ifndef	LOCORE
182 /*
183  * Signal vector "template" used in sigvec call.
184  */
185 struct	sigvec {
186 	void	(*sv_handler)();	/* signal handler */
187 	int	sv_mask;		/* signal mask to apply */
188 	int	sv_flags;		/* see signal options below */
189 };
190 #define	SV_ONSTACK	0x0001	/* take signal on signal stack */
191 #define	SV_INTERRUPT	0x0002	/* do not restart system on signal return */
192 #define	SV_RESETHAND	0x0004	/* reset signal handler to SIG_DFL when signal taken */
193 /*
194  * If any SA_NOCLDSTOP or SV_NOCLDSTOP is change, the same
195  * changes must be made in /usr/include/signal.h as well.
196  */
197 #define	SV_NOCLDSTOP	0x0008	/* don't send a SIGCHLD on child stop */
198 #define	SA_ONSTACK	SV_ONSTACK
199 #define	SA_INTERRUPT	SV_INTERRUPT
200 #define	SA_RESETHAND	SV_RESETHAND
201 
202 #define	SA_NOCLDSTOP	SV_NOCLDSTOP
203 #define	sv_onstack sv_flags	/* isn't compatibility wonderful! */
204 
205 /*
206  * Structure used in sigstack call.
207  */
208 struct	sigstack {
209 	char	*ss_sp;			/* signal stack pointer */
210 	int	ss_onstack;		/* current status */
211 };
212 
213 /*
214  * Information pushed on stack when a signal is delivered.
215  * This is used by the kernel to restore state following
216  * execution of the signal handler.  It is also made available
217  * to the handler to allow it to properly restore state if
218  * a non-standard exit is performed.
219  */
220 struct	sigcontext {
221 	int	sc_onstack;		/* sigstack state to restore */
222 	int	sc_mask;		/* signal mask to restore */
223 #ifdef	vax
224 	int	sc_sp;			/* sp to restore */
225 	int	sc_fp;			/* fp to restore */
226 	int	sc_ap;			/* ap to restore */
227 	int	sc_pc;			/* pc to restore */
228 	int	sc_ps;			/* psl to restore */
229 #endif	vax
230 #ifdef	mc68000
231 	int	sc_sp;			/* sp to restore */
232 	int	sc_pc;			/* pc to retore */
233 	int	sc_ps;			/* psl to restore */
234 #endif	mc68000
235 #ifdef	sparc
236 #define	SPARC_MAXREGWINDOW	31	/* max usable windows in sparc */
237 	int	sc_sp;			/* sp to restore */
238 	int	sc_pc;			/* pc to retore */
239 	int	sc_npc;			/* next pc to restore */
240 	int	sc_psr;			/* psr to restore */
241 	int	sc_g1;			/* register that must be restored */
242 	int	sc_o0;
243 	int	sc_wbcnt;		/* number of outstanding windows */
244 	char	*sc_spbuf[SPARC_MAXREGWINDOW]; /* sp's for each wbuf */
245 	int	sc_wbuf[SPARC_MAXREGWINDOW][16]; /* window save buf */
246 #endif	sparc
247 #ifdef	sun386
248 	int	sc_sp;			/* sp to restore */
249 	int	sc_pc;			/* pc to retore */
250 	int	sc_ps;			/* psl to restore */
251 	int	sc_eax;			/* eax to restore */
252 	int	sc_edx;			/* edx to restore */
253 #endif
254 };
255 #endif	!LOCORE
256 
257 #define	BADSIG		(void (*)())-1
258 
259 /*
260  * If SIG_ERR, SIG_DFL, SIG_IGN, or SIG_HOLD are changed, the same changes
261  * must be made in /usr/include/signal.h as well.
262  */
263 #define	SIG_ERR		(void (*)())-1
264 #define	SIG_DFL		(void (*)())0
265 #define	SIG_IGN		(void (*)())1
266 
267 #ifdef	KERNEL
268 #define	SIG_CATCH	(void (*)())2
269 #endif	KERNEL
270 #define	SIG_HOLD	(void (*)())3
271 
272 /*
273  * Macro for converting signal number to a mask suitable for sigblock().
274  */
275 #define	sigmask(m)	(1 << ((m)-1))
276 /*
277  * signals that can't caught, blocked, or ignored
278  */
279 #ifdef	KERNEL
280 #define	cantmask		(sigmask(SIGKILL)|sigmask(SIGSTOP))
281 #endif
282 
283 
284 /*
285  * If SIG_BLOCK, SIG_UNBLOCK, or SIG_SETMASK are changed, the same changes
286  * must be made in /usr/include/signal.h as well.
287  */
288 #define	SIG_BLOCK		0x0001
289 #define	SIG_UNBLOCK		0x0002
290 #define	SIG_SETMASK		0x0004
291 
292 #if	!defined(LOCORE) && !defined(KERNEL)
293 
294 /*
295  * If changes are made to sigset_t or struct sigaction, the same changes
296  * must be made in /usr/include/signal.h as well.
297  */
298 #include <sys/stdtypes.h>
299 
300 struct	sigaction {
301 	void 		(*sa_handler)();
302 	sigset_t	sa_mask;
303 	int		sa_flags;
304 };
305 
306 /*
307  * If changes are made to the function prototypes, the same changes
308  * must be made in /usr/include/signal.h as well.
309  */
310 void	(*signal())();
311 int	kill(/* pid_t p, int sig */);
312 int	sigaction(/* int signo,
313 	    struct sigaction *act, struct sigaction *oldact */);
314 int	sigaddset(/* sigset_t *mask, int signo */);
315 int	sigdelset(/* sigset_t *mask, int signo */);
316 int	sigemptyset(/* sigset_t *mask */);
317 int	sigfillset(/* sigset_t *mask */);
318 int	sigismember(/* sigset_t *mask, int signo */);
319 int	sigpending(/* sigset_t *set */);
320 int	sigprocmask(/* int how, sigset_t *set, *oldset */);
321 int	sigsuspend(/* sigset_t *mask */);
322 
323 #endif	/* !LOCORE && !KERNEL */
324 #endif	/* !__sys_signal_h */
325