xref: /titanic_50/usr/src/lib/libbc/inc/include/sys/signal.h (revision 29e83d4b25fd82feb8e0e0fbe89f7e2a8438533d)
1 /*
2  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 1982 Regents of the University of California.
8  * All rights reserved.  The Berkeley software License Agreement
9  * specifies the terms and conditions for redistribution.
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 
29 #define	ILL_STACK		0x00	/* bad stack */
30 #define	ILL_ILLINSTR_FAULT	0x02	/* illegal instruction fault */
31 #define	ILL_PRIVINSTR_FAULT	0x03	/* privileged instruction fault */
32 /* codes from 0x80 to 0xff are software traps */
33 #define	ILL_TRAP_FAULT(n)	((n)+0x80) /* trap n fault */
34 
35 #define	SIGTRAP	5	/* trace trap (not reset when caught) */
36 #define	SIGIOT	6	/* IOT instruction */
37 #define	SIGABRT 6	/* used by abort, replace SIGIOT in the future */
38 #define	SIGEMT	7	/* EMT instruction */
39 
40 #define	EMT_TAG		0x0a	/* tag overflow */
41 
42 #define	SIGFPE	8	/* floating point exception */
43 
44 #define	FPE_INTOVF_TRAP	0x1	/* integer overflow */
45 #define	FPE_STARTSIG_TRAP	0x2	/* process using fp */
46 #define	FPE_INTDIV_TRAP	0x14	/* integer divide by zero */
47 #define	FPE_FLTINEX_TRAP	0xc4	/* [floating inexact result] */
48 #define	FPE_FLTDIV_TRAP	0xc8	/* [floating divide by zero] */
49 #define	FPE_FLTUND_TRAP	0xcc	/* [floating underflow] */
50 #define	FPE_FLTOPERR_TRAP	0xd0	/* [floating operand error] */
51 #define	FPE_FLTOVF_TRAP	0xd4	/* [floating overflow] */
52 
53 #define	SIGKILL	9	/* kill (cannot be caught or ignored) */
54 /*
55  * The codes for SIGBUS and SIGSEGV are described in <vm/faultcode.h>
56  */
57 #define	SIGBUS	10	/* bus error */
58 #define	BUS_HWERR	FC_HWERR	/* misc hardware error (e.g. timeout) */
59 #define	BUS_ALIGN	FC_ALIGN	/* hardware alignment error */
60 #define	BUS_OBJERR	FC_OBJERR	/* object returned errno value */
61 /*
62  * The BUS_CODE(code) will be one of the above.  In the BUS_OBJERR case,
63  * doing a BUS_ERRNO(code) gives an errno value reported by the underlying
64  * file object mapped at the fault address.  Note that this appears to be
65  * duplicated with the segmentation fault case below -- unfortunate, since
66  * the specification has always claimed that such errors produce SIGBUS.
67  * The segmentation cases are left defined as a transition aid.
68  */
69 #define	BUS_CODE(C)		FC_CODE(C)
70 #define	BUS_ERRNO(C)	FC_ERRNO(C)
71 #define	SIGSEGV	11	/* segmentation violation */
72 #define	SEGV_NOMAP	FC_NOMAP	/* no mapping at the fault address */
73 #define	SEGV_PROT	FC_PROT		/* access exceeded protections */
74 #define	SEGV_OBJERR	FC_OBJERR	/* object returned errno value */
75 /*
76  * The SEGV_CODE(code) will be SEGV_NOMAP, SEGV_PROT, or SEGV_OBJERR.
77  * In the SEGV_OBJERR case, doing a SEGV_ERRNO(code) gives an errno value
78  * reported by the underlying file object mapped at the fault address.
79  */
80 #define	SEGV_CODE(C)	FC_CODE(C)
81 #define	SEGV_ERRNO(C)	FC_ERRNO(C)
82 #define	SIGSYS	12	/* bad argument to system call */
83 #define	SIGPIPE	13	/* write on a pipe with no one to read it */
84 #define	SIGALRM	14	/* alarm clock */
85 #define	SIGTERM	15	/* software termination signal from kill */
86 #define	SIGURG	16	/* urgent condition on IO channel */
87 #define	SIGSTOP	17	/* sendable stop signal not from tty */
88 #define	SIGTSTP	18	/* stop signal from tty */
89 #define	SIGCONT	19	/* continue a stopped process */
90 #define	SIGCHLD	20	/* to parent on child stop or exit */
91 #define	SIGCLD	20	/* System V name for SIGCHLD */
92 #define	SIGTTIN	21	/* to readers pgrp upon background tty read */
93 #define	SIGTTOU	22	/* like TTIN for output if (tp->t_local&LTOSTOP) */
94 #define	SIGIO	23	/* input/output possible signal */
95 #define	SIGPOLL	SIGIO	/* System V name for SIGIO */
96 #define	SIGXCPU	24	/* exceeded CPU time limit */
97 #define	SIGXFSZ	25	/* exceeded file size limit */
98 #define	SIGVTALRM 26	/* virtual time alarm */
99 #define	SIGPROF	27	/* profiling time alarm */
100 #define	SIGWINCH 28	/* window changed */
101 #define	SIGLOST 29	/* resource lost (eg, record-lock lost) */
102 #define	SIGUSR1 30	/* user defined signal 1 */
103 #define	SIGUSR2 31	/* user defined signal 2 */
104 /*
105  * If addr cannot be computed it is set to SIG_NOADDR.
106  */
107 #define	SIG_NOADDR	((char *)~0)
108 
109 #if	!defined(KERNEL)  &&  !defined(LOCORE)
110 void	(*signal())();
111 /*
112  * Define BSD 4.1 reliable signals for SVID compatibility.
113  * These functions may go away in a future release.
114  */
115 void  (*sigset())();
116 int   sighold();
117 int   sigrelse();
118 int   sigignore();
119 #endif	/* !KERNEL  &&  !LOCORE */
120 
121 #ifndef	LOCORE
122 /*
123  * Signal vector "template" used in sigvec call.
124  */
125 struct	sigvec {
126 	void	(*sv_handler)();	/* signal handler */
127 	int	sv_mask;		/* signal mask to apply */
128 	int	sv_flags;		/* see signal options below */
129 };
130 #define	SV_ONSTACK	0x0001	/* take signal on signal stack */
131 #define	SV_INTERRUPT	0x0002	/* do not restart system on signal return */
132 #define	SV_RESETHAND	0x0004	/* reset signal handler to SIG_DFL when signal taken */
133 /*
134  * If any SA_NOCLDSTOP or SV_NOCLDSTOP is change, the same
135  * changes must be made in /usr/include/signal.h as well.
136  */
137 #define	SV_NOCLDSTOP	0x0008	/* don't send a SIGCHLD on child stop */
138 #define	SA_ONSTACK	SV_ONSTACK
139 #define	SA_INTERRUPT	SV_INTERRUPT
140 #define	SA_RESETHAND	SV_RESETHAND
141 
142 #define	SA_NOCLDSTOP	SV_NOCLDSTOP
143 #define	sv_onstack sv_flags	/* isn't compatibility wonderful! */
144 
145 /*
146  * Structure used in sigstack call.
147  */
148 struct	sigstack {
149 	char	*ss_sp;			/* signal stack pointer */
150 	int	ss_onstack;		/* current status */
151 };
152 
153 /*
154  * Information pushed on stack when a signal is delivered.
155  * This is used by the kernel to restore state following
156  * execution of the signal handler.  It is also made available
157  * to the handler to allow it to properly restore state if
158  * a non-standard exit is performed.
159  */
160 struct	sigcontext {
161 	int	sc_onstack;		/* sigstack state to restore */
162 	int	sc_mask;		/* signal mask to restore */
163 #define	SPARC_MAXREGWINDOW	31	/* max usable windows in sparc */
164 	int	sc_sp;			/* sp to restore */
165 	int	sc_pc;			/* pc to retore */
166 	int	sc_npc;			/* next pc to restore */
167 	int	sc_psr;			/* psr to restore */
168 	int	sc_g1;			/* register that must be restored */
169 	int	sc_o0;
170 	int	sc_wbcnt;		/* number of outstanding windows */
171 	char	*sc_spbuf[SPARC_MAXREGWINDOW]; /* sp's for each wbuf */
172 	int	sc_wbuf[SPARC_MAXREGWINDOW][16]; /* window save buf */
173 };
174 #endif	/* !LOCORE */
175 
176 #define	BADSIG		(void (*)())-1
177 
178 /*
179  * If SIG_ERR, SIG_DFL, SIG_IGN, or SIG_HOLD are changed, the same changes
180  * must be made in /usr/include/signal.h as well.
181  */
182 #define	SIG_ERR		(void (*)())-1
183 #define	SIG_DFL		(void (*)())0
184 #define	SIG_IGN		(void (*)())1
185 
186 #define	SIG_HOLD	(void (*)())3
187 
188 /*
189  * Macro for converting signal number to a mask suitable for sigblock().
190  */
191 #define	sigmask(m)	(1 << ((m)-1))
192 /*
193  * signals that can't caught, blocked, or ignored
194  */
195 
196 /*
197  * If SIG_BLOCK, SIG_UNBLOCK, or SIG_SETMASK are changed, the same changes
198  * must be made in /usr/include/signal.h as well.
199  */
200 #define	SIG_BLOCK		0x0001
201 #define	SIG_UNBLOCK		0x0002
202 #define	SIG_SETMASK		0x0004
203 
204 #if	!defined(LOCORE) && !defined(KERNEL)
205 
206 /*
207  * If changes are made to sigset_t or struct sigaction, the same changes
208  * must be made in /usr/include/signal.h as well.
209  */
210 #include <sys/stdtypes.h>
211 
212 struct	sigaction {
213 	void 		(*sa_handler)();
214 	sigset_t	sa_mask;
215 	int		sa_flags;
216 };
217 
218 /*
219  * If changes are made to the function prototypes, the same changes
220  * must be made in /usr/include/signal.h as well.
221  */
222 void	(*signal())();
223 int	kill(/* pid_t p, int sig */);
224 int	sigaction(/* int signo,
225 	    struct sigaction *act, struct sigaction *oldact */);
226 int	sigaddset(/* sigset_t *mask, int signo */);
227 int	sigdelset(/* sigset_t *mask, int signo */);
228 int	sigemptyset(/* sigset_t *mask */);
229 int	sigfillset(/* sigset_t *mask */);
230 int	sigismember(/* sigset_t *mask, int signo */);
231 int	sigpending(/* sigset_t *set */);
232 int	sigprocmask(/* int how, sigset_t *set, *oldset */);
233 int	sigsuspend(/* sigset_t *mask */);
234 
235 #endif	/* !LOCORE && !KERNEL */
236 #endif	/* !__sys_signal_h */
237