xref: /dragonfly/sys/sys/_siginfo.h (revision 33346040)
1 /*-
2  * Copyright (c) 2019 The DragonFly Project.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *    the documentation and/or other materials provided with the
13  *    distribution.
14  * 3. Neither the name of The DragonFly Project nor the names of its
15  *    contributors may be used to endorse or promote products derived
16  *    from this software without specific, prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
22  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
24  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
28  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31 
32 #ifndef _SYS__SIGINFO_H_
33 #define	_SYS__SIGINFO_H_
34 
35 #include <sys/cdefs.h>
36 #include <machine/stdint.h>
37 
38 #ifndef _PID_T_DECLARED
39 typedef	__pid_t		pid_t;
40 #define	_PID_T_DECLARED
41 #endif
42 
43 #ifndef _UID_T_DECLARED
44 typedef	__uint32_t	uid_t;		/* user id */
45 #define	_UID_T_DECLARED
46 #endif
47 
48 #if __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE >= 500
49 union sigval {
50 	int	sival_int;
51 	void	*sival_ptr;
52 };
53 #endif
54 
55 #if __POSIX_VISIBLE
56 /** si_code */
57 #define	SI_USER		0	/* Sent by kill(2)			*/
58 #define	SI_QUEUE	-1	/* Sent by the sigqueue(2)		*/
59 #define	SI_TIMER	-2	/* Generated by expiration of a timer	*/
60 				/* set by timer_settime(2)		*/
61 #define	SI_ASYNCIO	-3	/* Generated by completion of an	*/
62 				/* asynchronous I/O signal		*/
63 #define	SI_MESGQ	-4	/* Generated by arrival of a message on	*/
64 				/* an empty message queue		*/
65 #endif
66 
67 #if __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE
68 /*
69  * si_code stuff
70  */
71 /* SIGILL */
72 #define	ILL_ILLOPC	1	/* Illegal opcode			*/
73 #define	ILL_ILLOPN	2	/* Illegal operand			*/
74 #define	ILL_ILLADR	3	/* Illegal addressing mode		*/
75 #define	ILL_ILLTRP	4	/* Illegal trap				*/
76 #define	ILL_PRVOPC	5	/* Privileged opcode			*/
77 #define	ILL_PRVREG	6	/* Privileged register			*/
78 #define	ILL_COPROC	7	/* Coprocessor error			*/
79 #define	ILL_BADSTK	8	/* Internal stack error			*/
80 
81 /* SIGFPE */
82 #define	FPE_INTOVF	1	/* Integer overflow			*/
83 #define	FPE_INTDIV	2	/* Integer divide by zero		*/
84 #define	FPE_FLTDIV	3	/* Floating point divide by zero	*/
85 #define	FPE_FLTOVF	4	/* Floating point overflow		*/
86 #define	FPE_FLTUND	5	/* Floating point underflow		*/
87 #define	FPE_FLTRES	6	/* Floating point inexact result	*/
88 #define	FPE_FLTINV	7	/* Invalid Floating point operation	*/
89 #define	FPE_FLTSUB	8	/* Subscript out of range		*/
90 
91 /* SIGSEGV */
92 #define	SEGV_MAPERR	1	/* Address not mapped to object		*/
93 #define	SEGV_ACCERR	2	/* Invalid permissions for mapped object*/
94 
95 /* SIGBUS */
96 #define	BUS_ADRALN	1	/* Invalid address alignment		*/
97 #define	BUS_ADRERR	2	/* Non-existent physical address	*/
98 #define	BUS_OBJERR	3	/* Object specific hardware error	*/
99 
100 /* SIGTRAP */
101 #define	TRAP_BRKPT	1	/* Process breakpoint			*/
102 #define	TRAP_TRACE	2	/* Process trace trap			*/
103 
104 /* SIGCHLD */
105 #define	CLD_EXITED	1	/* Child has exited			*/
106 #define	CLD_KILLED	2	/* Child has terminated abnormally but	*/
107 				/* did not create a core file		*/
108 #define	CLD_DUMPED	3	/* Child has terminated abnormally and	*/
109 				/* created a core file			*/
110 #define	CLD_TRAPPED	4	/* Traced child has trapped		*/
111 #define	CLD_STOPPED	5	/* Child has stopped			*/
112 #define	CLD_CONTINUED	6	/* Stopped child has continued		*/
113 
114 /* SIGPOLL */
115 #define	POLL_IN		1	/* Data input available			*/
116 #define	POLL_OUT	2	/* Output buffers available		*/
117 #define	POLL_MSG	3	/* Input message available		*/
118 #define	POLL_ERR	4	/* I/O Error				*/
119 #define	POLL_PRI	5	/* High priority input available	*/
120 #define	POLL_HUP	6	/* Device disconnected			*/
121 
122 typedef	struct __siginfo {
123 	int	si_signo;		/* signal number */
124 	int	si_errno;		/* errno association */
125 	/*
126 	 * Cause of signal, one of the SI_ macros or signal-specific
127 	 * values, i.e. one of the FPE_... values for SIGFPE. This
128 	 * value is equivalent to the second argument to an old-style
129 	 * FreeBSD signal handler.
130 	 */
131 	int	si_code;		/* signal code */
132 	pid_t	si_pid;			/* sending process */
133 	uid_t	si_uid;			/* sender's ruid */
134 	int	si_status;		/* exit value */
135 	void	*si_addr;		/* faulting instruction */
136 	union sigval si_value;		/* signal value */
137 	long	si_band;		/* band event for SIGPOLL */
138 	int	__spare__[7];		/* gimme some slack */
139 } siginfo_t;
140 #endif /* __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE */
141 
142 #endif /* !_SYS__SIGINFO_H_ */
143