xref: /onnv-gate/usr/src/lib/libbc/inc/include/sys/signal.h (revision 722:636b850d4ee9)
1*722Smuffin /*
2*722Smuffin  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3*722Smuffin  * Use is subject to license terms.
4*722Smuffin  */
5*722Smuffin 
60Sstevel@tonic-gate /*
70Sstevel@tonic-gate  * Copyright (c) 1982 Regents of the University of California.
80Sstevel@tonic-gate  * All rights reserved.  The Berkeley software License Agreement
90Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
100Sstevel@tonic-gate  */
110Sstevel@tonic-gate 
120Sstevel@tonic-gate #ifndef	__sys_signal_h
130Sstevel@tonic-gate #define	__sys_signal_h
140Sstevel@tonic-gate 
150Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
160Sstevel@tonic-gate 
170Sstevel@tonic-gate #include <vm/faultcode.h>
180Sstevel@tonic-gate #define	NSIG	32
190Sstevel@tonic-gate 
200Sstevel@tonic-gate /*
210Sstevel@tonic-gate  * If any signal defines (SIG*) are added, deleted, or changed, the same
220Sstevel@tonic-gate  * changes must be made in /usr/include/signal.h as well.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate #define	SIGHUP	1	/* hangup */
250Sstevel@tonic-gate #define	SIGINT	2	/* interrupt */
260Sstevel@tonic-gate #define	SIGQUIT	3	/* quit */
270Sstevel@tonic-gate #define	SIGILL	4	/* illegal instruction (not reset when caught) */
28*722Smuffin 
29*722Smuffin #define	ILL_STACK		0x00	/* bad stack */
30*722Smuffin #define	ILL_ILLINSTR_FAULT	0x02	/* illegal instruction fault */
31*722Smuffin #define	ILL_PRIVINSTR_FAULT	0x03	/* privileged instruction fault */
320Sstevel@tonic-gate /* codes from 0x80 to 0xff are software traps */
33*722Smuffin #define	ILL_TRAP_FAULT(n)	((n)+0x80) /* trap n fault */
34*722Smuffin 
350Sstevel@tonic-gate #define	SIGTRAP	5	/* trace trap (not reset when caught) */
360Sstevel@tonic-gate #define	SIGIOT	6	/* IOT instruction */
370Sstevel@tonic-gate #define	SIGABRT 6	/* used by abort, replace SIGIOT in the future */
380Sstevel@tonic-gate #define	SIGEMT	7	/* EMT instruction */
39*722Smuffin 
40*722Smuffin #define	EMT_TAG		0x0a	/* tag overflow */
41*722Smuffin 
420Sstevel@tonic-gate #define	SIGFPE	8	/* floating point exception */
43*722Smuffin 
44*722Smuffin #define	FPE_INTOVF_TRAP	0x1	/* integer overflow */
45*722Smuffin #define	FPE_STARTSIG_TRAP	0x2	/* process using fp */
46*722Smuffin #define	FPE_INTDIV_TRAP	0x14	/* integer divide by zero */
47*722Smuffin #define	FPE_FLTINEX_TRAP	0xc4	/* [floating inexact result] */
48*722Smuffin #define	FPE_FLTDIV_TRAP	0xc8	/* [floating divide by zero] */
49*722Smuffin #define	FPE_FLTUND_TRAP	0xcc	/* [floating underflow] */
50*722Smuffin #define	FPE_FLTOPERR_TRAP	0xd0	/* [floating operand error] */
51*722Smuffin #define	FPE_FLTOVF_TRAP	0xd4	/* [floating overflow] */
52*722Smuffin 
530Sstevel@tonic-gate #define	SIGKILL	9	/* kill (cannot be caught or ignored) */
540Sstevel@tonic-gate /*
550Sstevel@tonic-gate  * The codes for SIGBUS and SIGSEGV are described in <vm/faultcode.h>
560Sstevel@tonic-gate  */
570Sstevel@tonic-gate #define	SIGBUS	10	/* bus error */
58*722Smuffin #define	BUS_HWERR	FC_HWERR	/* misc hardware error (e.g. timeout) */
59*722Smuffin #define	BUS_ALIGN	FC_ALIGN	/* hardware alignment error */
60*722Smuffin #define	BUS_OBJERR	FC_OBJERR	/* object returned errno value */
610Sstevel@tonic-gate /*
620Sstevel@tonic-gate  * The BUS_CODE(code) will be one of the above.  In the BUS_OBJERR case,
630Sstevel@tonic-gate  * doing a BUS_ERRNO(code) gives an errno value reported by the underlying
640Sstevel@tonic-gate  * file object mapped at the fault address.  Note that this appears to be
650Sstevel@tonic-gate  * duplicated with the segmentation fault case below -- unfortunate, since
660Sstevel@tonic-gate  * the specification has always claimed that such errors produce SIGBUS.
670Sstevel@tonic-gate  * The segmentation cases are left defined as a transition aid.
680Sstevel@tonic-gate  */
69*722Smuffin #define	BUS_CODE(C)		FC_CODE(C)
70*722Smuffin #define	BUS_ERRNO(C)	FC_ERRNO(C)
710Sstevel@tonic-gate #define	SIGSEGV	11	/* segmentation violation */
72*722Smuffin #define	SEGV_NOMAP	FC_NOMAP	/* no mapping at the fault address */
73*722Smuffin #define	SEGV_PROT	FC_PROT		/* access exceeded protections */
74*722Smuffin #define	SEGV_OBJERR	FC_OBJERR	/* object returned errno value */
750Sstevel@tonic-gate /*
760Sstevel@tonic-gate  * The SEGV_CODE(code) will be SEGV_NOMAP, SEGV_PROT, or SEGV_OBJERR.
770Sstevel@tonic-gate  * In the SEGV_OBJERR case, doing a SEGV_ERRNO(code) gives an errno value
780Sstevel@tonic-gate  * reported by the underlying file object mapped at the fault address.
790Sstevel@tonic-gate  */
80*722Smuffin #define	SEGV_CODE(C)	FC_CODE(C)
81*722Smuffin #define	SEGV_ERRNO(C)	FC_ERRNO(C)
820Sstevel@tonic-gate #define	SIGSYS	12	/* bad argument to system call */
830Sstevel@tonic-gate #define	SIGPIPE	13	/* write on a pipe with no one to read it */
840Sstevel@tonic-gate #define	SIGALRM	14	/* alarm clock */
850Sstevel@tonic-gate #define	SIGTERM	15	/* software termination signal from kill */
860Sstevel@tonic-gate #define	SIGURG	16	/* urgent condition on IO channel */
870Sstevel@tonic-gate #define	SIGSTOP	17	/* sendable stop signal not from tty */
880Sstevel@tonic-gate #define	SIGTSTP	18	/* stop signal from tty */
890Sstevel@tonic-gate #define	SIGCONT	19	/* continue a stopped process */
900Sstevel@tonic-gate #define	SIGCHLD	20	/* to parent on child stop or exit */
910Sstevel@tonic-gate #define	SIGCLD	20	/* System V name for SIGCHLD */
920Sstevel@tonic-gate #define	SIGTTIN	21	/* to readers pgrp upon background tty read */
930Sstevel@tonic-gate #define	SIGTTOU	22	/* like TTIN for output if (tp->t_local&LTOSTOP) */
940Sstevel@tonic-gate #define	SIGIO	23	/* input/output possible signal */
950Sstevel@tonic-gate #define	SIGPOLL	SIGIO	/* System V name for SIGIO */
960Sstevel@tonic-gate #define	SIGXCPU	24	/* exceeded CPU time limit */
970Sstevel@tonic-gate #define	SIGXFSZ	25	/* exceeded file size limit */
980Sstevel@tonic-gate #define	SIGVTALRM 26	/* virtual time alarm */
990Sstevel@tonic-gate #define	SIGPROF	27	/* profiling time alarm */
1000Sstevel@tonic-gate #define	SIGWINCH 28	/* window changed */
1010Sstevel@tonic-gate #define	SIGLOST 29	/* resource lost (eg, record-lock lost) */
1020Sstevel@tonic-gate #define	SIGUSR1 30	/* user defined signal 1 */
1030Sstevel@tonic-gate #define	SIGUSR2 31	/* user defined signal 2 */
1040Sstevel@tonic-gate /*
1050Sstevel@tonic-gate  * If addr cannot be computed it is set to SIG_NOADDR.
1060Sstevel@tonic-gate  */
1070Sstevel@tonic-gate #define	SIG_NOADDR	((char *)~0)
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate #if	!defined(KERNEL)  &&  !defined(LOCORE)
1100Sstevel@tonic-gate void	(*signal())();
1110Sstevel@tonic-gate /*
1120Sstevel@tonic-gate  * Define BSD 4.1 reliable signals for SVID compatibility.
1130Sstevel@tonic-gate  * These functions may go away in a future release.
1140Sstevel@tonic-gate  */
1150Sstevel@tonic-gate void  (*sigset())();
1160Sstevel@tonic-gate int   sighold();
1170Sstevel@tonic-gate int   sigrelse();
1180Sstevel@tonic-gate int   sigignore();
119*722Smuffin #endif	/* !KERNEL  &&  !LOCORE */
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate #ifndef	LOCORE
1220Sstevel@tonic-gate /*
1230Sstevel@tonic-gate  * Signal vector "template" used in sigvec call.
1240Sstevel@tonic-gate  */
1250Sstevel@tonic-gate struct	sigvec {
1260Sstevel@tonic-gate 	void	(*sv_handler)();	/* signal handler */
1270Sstevel@tonic-gate 	int	sv_mask;		/* signal mask to apply */
1280Sstevel@tonic-gate 	int	sv_flags;		/* see signal options below */
1290Sstevel@tonic-gate };
1300Sstevel@tonic-gate #define	SV_ONSTACK	0x0001	/* take signal on signal stack */
1310Sstevel@tonic-gate #define	SV_INTERRUPT	0x0002	/* do not restart system on signal return */
1320Sstevel@tonic-gate #define	SV_RESETHAND	0x0004	/* reset signal handler to SIG_DFL when signal taken */
1330Sstevel@tonic-gate /*
1340Sstevel@tonic-gate  * If any SA_NOCLDSTOP or SV_NOCLDSTOP is change, the same
1350Sstevel@tonic-gate  * changes must be made in /usr/include/signal.h as well.
1360Sstevel@tonic-gate  */
1370Sstevel@tonic-gate #define	SV_NOCLDSTOP	0x0008	/* don't send a SIGCHLD on child stop */
1380Sstevel@tonic-gate #define	SA_ONSTACK	SV_ONSTACK
1390Sstevel@tonic-gate #define	SA_INTERRUPT	SV_INTERRUPT
1400Sstevel@tonic-gate #define	SA_RESETHAND	SV_RESETHAND
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate #define	SA_NOCLDSTOP	SV_NOCLDSTOP
1430Sstevel@tonic-gate #define	sv_onstack sv_flags	/* isn't compatibility wonderful! */
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate /*
1460Sstevel@tonic-gate  * Structure used in sigstack call.
1470Sstevel@tonic-gate  */
1480Sstevel@tonic-gate struct	sigstack {
1490Sstevel@tonic-gate 	char	*ss_sp;			/* signal stack pointer */
1500Sstevel@tonic-gate 	int	ss_onstack;		/* current status */
1510Sstevel@tonic-gate };
1520Sstevel@tonic-gate 
1530Sstevel@tonic-gate /*
1540Sstevel@tonic-gate  * Information pushed on stack when a signal is delivered.
1550Sstevel@tonic-gate  * This is used by the kernel to restore state following
1560Sstevel@tonic-gate  * execution of the signal handler.  It is also made available
1570Sstevel@tonic-gate  * to the handler to allow it to properly restore state if
1580Sstevel@tonic-gate  * a non-standard exit is performed.
1590Sstevel@tonic-gate  */
1600Sstevel@tonic-gate struct	sigcontext {
1610Sstevel@tonic-gate 	int	sc_onstack;		/* sigstack state to restore */
1620Sstevel@tonic-gate 	int	sc_mask;		/* signal mask to restore */
1630Sstevel@tonic-gate #define	SPARC_MAXREGWINDOW	31	/* max usable windows in sparc */
1640Sstevel@tonic-gate 	int	sc_sp;			/* sp to restore */
1650Sstevel@tonic-gate 	int	sc_pc;			/* pc to retore */
1660Sstevel@tonic-gate 	int	sc_npc;			/* next pc to restore */
1670Sstevel@tonic-gate 	int	sc_psr;			/* psr to restore */
1680Sstevel@tonic-gate 	int	sc_g1;			/* register that must be restored */
1690Sstevel@tonic-gate 	int	sc_o0;
1700Sstevel@tonic-gate 	int	sc_wbcnt;		/* number of outstanding windows */
1710Sstevel@tonic-gate 	char	*sc_spbuf[SPARC_MAXREGWINDOW]; /* sp's for each wbuf */
1720Sstevel@tonic-gate 	int	sc_wbuf[SPARC_MAXREGWINDOW][16]; /* window save buf */
1730Sstevel@tonic-gate };
174*722Smuffin #endif	/* !LOCORE */
1750Sstevel@tonic-gate 
1760Sstevel@tonic-gate #define	BADSIG		(void (*)())-1
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate /*
1790Sstevel@tonic-gate  * If SIG_ERR, SIG_DFL, SIG_IGN, or SIG_HOLD are changed, the same changes
1800Sstevel@tonic-gate  * must be made in /usr/include/signal.h as well.
1810Sstevel@tonic-gate  */
1820Sstevel@tonic-gate #define	SIG_ERR		(void (*)())-1
1830Sstevel@tonic-gate #define	SIG_DFL		(void (*)())0
1840Sstevel@tonic-gate #define	SIG_IGN		(void (*)())1
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate #define	SIG_HOLD	(void (*)())3
1870Sstevel@tonic-gate 
1880Sstevel@tonic-gate /*
1890Sstevel@tonic-gate  * Macro for converting signal number to a mask suitable for sigblock().
1900Sstevel@tonic-gate  */
1910Sstevel@tonic-gate #define	sigmask(m)	(1 << ((m)-1))
1920Sstevel@tonic-gate /*
1930Sstevel@tonic-gate  * signals that can't caught, blocked, or ignored
1940Sstevel@tonic-gate  */
1950Sstevel@tonic-gate 
1960Sstevel@tonic-gate /*
1970Sstevel@tonic-gate  * If SIG_BLOCK, SIG_UNBLOCK, or SIG_SETMASK are changed, the same changes
1980Sstevel@tonic-gate  * must be made in /usr/include/signal.h as well.
1990Sstevel@tonic-gate  */
2000Sstevel@tonic-gate #define	SIG_BLOCK		0x0001
2010Sstevel@tonic-gate #define	SIG_UNBLOCK		0x0002
2020Sstevel@tonic-gate #define	SIG_SETMASK		0x0004
2030Sstevel@tonic-gate 
2040Sstevel@tonic-gate #if	!defined(LOCORE) && !defined(KERNEL)
2050Sstevel@tonic-gate 
2060Sstevel@tonic-gate /*
2070Sstevel@tonic-gate  * If changes are made to sigset_t or struct sigaction, the same changes
2080Sstevel@tonic-gate  * must be made in /usr/include/signal.h as well.
2090Sstevel@tonic-gate  */
2100Sstevel@tonic-gate #include <sys/stdtypes.h>
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate struct	sigaction {
2130Sstevel@tonic-gate 	void 		(*sa_handler)();
2140Sstevel@tonic-gate 	sigset_t	sa_mask;
2150Sstevel@tonic-gate 	int		sa_flags;
2160Sstevel@tonic-gate };
2170Sstevel@tonic-gate 
2180Sstevel@tonic-gate /*
2190Sstevel@tonic-gate  * If changes are made to the function prototypes, the same changes
2200Sstevel@tonic-gate  * must be made in /usr/include/signal.h as well.
2210Sstevel@tonic-gate  */
2220Sstevel@tonic-gate void	(*signal())();
2230Sstevel@tonic-gate int	kill(/* pid_t p, int sig */);
2240Sstevel@tonic-gate int	sigaction(/* int signo,
2250Sstevel@tonic-gate 	    struct sigaction *act, struct sigaction *oldact */);
2260Sstevel@tonic-gate int	sigaddset(/* sigset_t *mask, int signo */);
2270Sstevel@tonic-gate int	sigdelset(/* sigset_t *mask, int signo */);
2280Sstevel@tonic-gate int	sigemptyset(/* sigset_t *mask */);
2290Sstevel@tonic-gate int	sigfillset(/* sigset_t *mask */);
2300Sstevel@tonic-gate int	sigismember(/* sigset_t *mask, int signo */);
2310Sstevel@tonic-gate int	sigpending(/* sigset_t *set */);
2320Sstevel@tonic-gate int	sigprocmask(/* int how, sigset_t *set, *oldset */);
2330Sstevel@tonic-gate int	sigsuspend(/* sigset_t *mask */);
2340Sstevel@tonic-gate 
2350Sstevel@tonic-gate #endif	/* !LOCORE && !KERNEL */
2360Sstevel@tonic-gate #endif	/* !__sys_signal_h */
237