xref: /netbsd/sys/sys/siginfo.h (revision c4a72b64)
1 /*	$NetBSD: siginfo.h,v 1.1 2002/11/26 19:06:38 christos Exp $	 */
2 
3 /*-
4  * Copyright (c) 2002 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Christos Zoulas.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #ifndef	_SYS_SIGINFO_H_
40 #define	_SYS_SIGINFO_H_
41 
42 typedef union sigval {
43 	int	sival_int;
44 	void	*sival_ptr;
45 } sigval_t;
46 
47 typedef union siginfo {
48 	char	si_pad[128];	/* Total size; for future expansion */
49 	struct {
50 		int	_signo;
51 		int	_code;
52 		int	_errno;
53 #ifdef _LP64
54 		/* In _LP64 the union starts on an 8-byte boundary. */
55 		int	_pad;
56 #endif
57 		union {
58 			struct {
59 				pid_t	_pid;
60 				uid_t	_uid;
61 				sigval_t	_sigval;
62 			} _rt;
63 
64 			struct {
65 				pid_t	_pid;
66 				uid_t	_uid;
67 				int	_status;
68 				clock_t	_utime;
69 				clock_t	_stime;
70 			} _child;
71 
72 			struct {
73 				void   *_addr;
74 				int	_trap;
75 			} _fault;
76 
77 			struct {
78 				long	_band;
79 				int	_fd;
80 			} _poll;
81 		} _reason;
82 	} _info;
83 } siginfo_t;
84 
85 /** Field access macros */
86 #define	si_signo	_info._signo
87 #define	si_code		_info._code
88 #define	si_errno	_info._errno
89 
90 #define	si_sigval	_info._reason._rt._sigval
91 #define	si_pid		_info._reason._child._pid
92 #define	si_uid		_info._reason._child._uid
93 #define	si_status	_info._reason._child._status
94 #define	si_utime	_info._reason._child._utime
95 #define	si_stime	_info._reason._child._stime
96 
97 #define	si_addr		_info._reason._fault._addr
98 #define	si_trap		_info._reason._fault._trap
99 
100 #define	si_band		_info._reason._poll._band
101 #define	si_fd		_info._reason._poll._fd
102 
103 /** si_code */
104 /* SIGILL */
105 #define	ILL_ILLOPC	1	/* Illegal opcode			*/
106 #define	ILL_ILLOPN	2	/* Illegal operand			*/
107 #define	ILL_ILLADR	3	/* Illegal addressing mode		*/
108 #define	ILL_ILLTRP	4	/* Illegal trap				*/
109 #define	ILL_PRVOPC	5	/* Privileged opcode			*/
110 #define	ILL_PRVREG	6	/* Privileged register			*/
111 #define	ILL_COPROC	7	/* Coprocessor error			*/
112 #define	ILL_BADSTK	8	/* Internal stack error			*/
113 
114 /* SIGFPE */
115 #define	FPE_INTDIV	1	/* Integer divide by zero		*/
116 #define	FPE_INTOVF	2	/* Integer overflow			*/
117 #define	FPE_FLTDIV	3	/* Floating point divide by zero	*/
118 #define	FPE_FLTOVF	4	/* Floating point overflow		*/
119 #define	FPE_FLTUND	5	/* Floating point underflow		*/
120 #define	FPE_FLTRES	6	/* Floating poing inexact result	*/
121 #define	FPE_FLTINV	7	/* Invalid Floating poing operation	*/
122 #define	FPE_FLTSUB	8	/* Subscript out of range		*/
123 
124 /* SIGSEGV */
125 #define	SEGV_MAPERR	1	/* Address not mapped to object		*/
126 #define	SEGV_ACCERR	2	/* Invalid permissions for mapped object*/
127 
128 /* SIGBUS */
129 #define	BUS_ADRALN	1	/* Invalid address alignment		*/
130 #define	BUS_ADRERR	2	/* Non-existant physical address	*/
131 #define	BUS_OBJERR	3	/* Object specific hardware error	*/
132 
133 /* SIGTRAP */
134 #define	TRAP_BRKPT	1	/* Process breakpoint			*/
135 #define	TRAP_TRACE	2	/* Process trace trap			*/
136 
137 /* SIGCHLD */
138 #define	CLD_EXITED	1	/* Child has exited			*/
139 #define	CLD_KILLED	2	/* Child has terminated abnormally but	*/
140 				/* did not create a core file		*/
141 #define	CLD_DUMPED	3	/* Child has terminated abnormally and	*/
142 				/* created a core file			*/
143 #define	CLD_TRAPPED	4	/* Traced child has trapped		*/
144 #define	CLD_STOPPED	5	/* Child has stopped			*/
145 #define	CLD_CONTINUED	6	/* Stopped child has continued		*/
146 
147 /* SIGPOLL */
148 #define	POLL_IN		1	/* Data input available			*/
149 #define	POLL_OUT	2	/* Output buffers available		*/
150 #define	POLL_MSG	3	/* Input message available		*/
151 #define	POLL_ERR	4	/* I/O Error				*/
152 #define	POLL_PRI	5	/* High priority input available	*/
153 #define	POLL_HUP	4	/* Device disconnected			*/
154 
155 
156 /** si_code */
157 #define	SI_USER		0	/* Sent by kill(2)			*/
158 #define	SI_QUEUE	-1	/* Sent by the sigqueue(2)		*/
159 #define	SI_TIMER	-2	/* Generated by expiration of a timer 	*/
160 				/* set by timer_settime(2)		*/
161 #define	SI_ASYNCIO	-3	/* Generated by completion of an	*/
162 				/* asynchronous I/O signal		*/
163 #define	SI_MESGQ	-4	/* Generated by arrival of a message on	*/
164 				/* an empty message queue		*/
165 
166 #endif /* !_SYS_SIGINFO_H_ */
167