xref: /netbsd-src/sys/compat/linux/arch/i386/linux_siginfo.h (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1 /*	$NetBSD: linux_siginfo.h,v 1.2 2003/07/03 21:24:29 christos Exp $	*/
2 
3 /*-
4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Eric Haszlakiewicz.
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 _I386_LINUX_SIGINFO_H
40 #define _I386_LINUX_SIGINFO_H
41 
42 typedef union linux_sigval {
43 	int	sival_int;
44 	void	*sival_ptr;
45 } linux_sigval_t;
46 
47 #define SI_MAX_SIZE	128
48 #define SI_PAD_SIZE	((SI_MAX_SIZE/sizeof(int)) - 3)
49 
50 typedef struct linux_siginfo {
51 	int	lsi_signo;
52 	int	lsi_errno;
53 	int	lsi_code;
54 	union {
55 		int _pad[SI_PAD_SIZE];
56 
57 		/* kill() */
58 		struct {
59 			linux_pid_t	_pid;
60 			linux_uid_t	_uid;
61 		} _kill;
62 
63 		/* POSIX.1b signals */
64 		struct {
65 			linux_pid_t	_pid;
66 			linux_uid_t	_uid;
67 			linux_sigval_t	_sigval;
68 		} _rt;
69 
70 		/* POSIX.1b timers */
71 		struct {
72 			unsigned int	_timer1;
73 			unsigned int	_timer2;
74 		} _timer;
75 
76 		/* SIGCHLD */
77 		struct {
78 			linux_pid_t	_pid;
79 			linux_uid_t	_uid;
80 			int		_status;
81 			linux_clock_t	_utime;
82 			linux_clock_t	_stime;
83 		} _sigchld;
84 
85 		/* SIGPOLL */
86 		struct {
87 			int _band;
88 			int _fd;
89 		} _sigpoll;
90 
91 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
92 		struct {
93 			void *_addr;
94 		} _sigfault;
95 	} _sidata;
96 } linux_siginfo_t;
97 
98 #define lsi_pid		_sidata._kill._pid
99 #define lsi_uid		_sidata._kill._uid
100 #define lsi_status      _sidata._sigchld._status
101 #define lsi_utime       _sidata._sigchld._utime
102 #define lsi_stime       _sidata._sigchld._stime
103 #define lsi_value       _sidata._rt._sigval
104 #define lsi_int         _sidata._rt._sigval.sival_int
105 #define lsi_ptr         _sidata._rt._sigval.sival_ptr
106 #define lsi_addr        _sidata._sigfault._addr
107 #define lsi_band        _sidata._sigpoll._band
108 #define lsi_fd          _sidata._sigpoll._fd
109 
110 /*
111  * si_code values for non-signals
112  */
113 #define LINUX_SI_USER		0
114 #define	LINUX_SI_KERNEL		0x80
115 #define LINUX_SI_QUEUE		-1
116 #define LINUX_SI_TIMER		-2
117 #define LINUX_SI_MESGQ		-3
118 #define LINUX_SI_ASYNCIO	-4
119 #define LINUX_SI_SIGIO		-5
120 #define LINUX_SI_SIGNL		-6
121 
122 /* si_code values for SIGILL */
123 #define	LINUX_ILL_ILLOPC	1
124 #define	LINUX_ILL_ILLOPN	2
125 #define	LINUX_ILL_ILLADR	3
126 #define	LINUX_ILL_ILLTRP	4
127 #define	LINUX_ILL_PRVOPC	5
128 #define	LINUX_ILL_PRVREG	6
129 #define	LINUX_ILL_COPROC	7
130 #define	LINUX_ILL_BADSTK	8
131 
132 /* si_code values for SIGFPE */
133 #define	LINUX_FPE_INTDIV 	1
134 #define	LINUX_FPE_INTOVF	2
135 #define	LINUX_FPE_FLTDIV	3
136 #define	LINUX_FPE_FLTOVF	4
137 #define	LINUX_FPE_FLTUND	5
138 #define	LINUX_FPE_FLTRES	6
139 #define	LINUX_FPE_FLTINV	7
140 #define	LINUX_FPE_FLTSUB	8
141 
142 /* si_code values for SIGSEGV */
143 #define	LINUX_SEGV_MAPERR	1
144 #define	LINUX_SEGV_ACCERR	2
145 
146 /* si_code values for SIGBUS */
147 #define	LINUX_BUS_ADRALN	1
148 #define	LINUX_BUS_ADRERR	2
149 #define	LINUX_BUS_OBJERR	3
150 
151 /* si_code values for SIGTRAP */
152 #define	LINUX_TRAP_BRKPT	1
153 #define	LINUX_TRAP_TRACE	2
154 
155 /* si_code values for SIGCHLD */
156 #define	LINUX_CLD_EXITED	1
157 #define	LINUX_CLD_KILLED	2
158 #define	LINUX_CLD_DUMPED	3
159 #define	LINUX_CLD_TRAPPED	4
160 #define	LINUX_CLD_STOPPED	5
161 #define	LINUX_CLD_CONTINUED	6
162 
163 /* si_code values for SIGPOLL */
164 #define	LINUX_POLL_IN		1
165 #define	LINUX_POLL_OUT		2
166 #define	LINUX_POLL_MSG		3
167 #define	LINUX_POLL_ERR		4
168 #define	LINUX_POLL_PRI		5
169 #define	LINUX_POLL_HUP		6
170 
171 #define LINUX_SI_FROMUSER(sp)	((sp)->si_code <= 0)
172 #define LINUX_SI_FROMKERNEL(sp)	((sp)->si_code > 0)
173 
174 #endif /* !_I386_LINUX_SIGINFO_H */
175