xref: /freebsd/sys/compat/linux/linux_siginfo.h (revision f5024381ac16ba43d37a8bd32d54c27f6a6afa66)
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (c) 2004 Tim J. Robbins
5  * Copyright (c) 2001 Doug Rabson
6  * Copyright (c) 1994-1996 Søren Schmidt
7  * All rights reserved.
8  * Copyright (c) 2022 Dmitry Chagin <dchagin@FreeBSD.org>
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  *    in this position and unchanged.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * $FreeBSD$
34  */
35 
36 #ifndef _LINUX_SIGINFO_H_
37 #define _LINUX_SIGINFO_H_
38 
39 typedef union l_sigval {
40 	l_int		sival_int;
41 	l_uintptr_t	sival_ptr;
42 } l_sigval_t;
43 
44 #define	LINUX_SI_MAX_SIZE		128
45 
46 union __sifields {
47 	struct {
48 		l_pid_t		_pid;
49 		l_uid_t		_uid;
50 	} _kill;
51 
52 	struct {
53 		l_timer_t	_tid;
54 		l_int		_overrun;
55 		char		_pad[sizeof(l_uid_t) - sizeof(int)];
56 		union l_sigval	_sigval;
57 		l_uint		_sys_private;
58 	} _timer;
59 
60 	struct {
61 		l_pid_t		_pid;		/* sender's pid */
62 		l_uid_t		_uid;		/* sender's uid */
63 		union l_sigval	_sigval;
64 	} _rt;
65 
66 	struct {
67 		l_pid_t		_pid;		/* which child */
68 		l_uid_t		_uid;		/* sender's uid */
69 		l_int		_status;	/* exit code */
70 		l_clock_t	_utime;
71 		l_clock_t	_stime;
72 	} _sigchld;
73 
74 	struct {
75 		l_uintptr_t	_addr;	/* Faulting insn/memory ref. */
76 	} _sigfault;
77 
78 	struct {
79 		l_long		_band;	/* POLL_IN,POLL_OUT,POLL_MSG */
80 		l_int		_fd;
81 	} _sigpoll;
82 };
83 
84 typedef struct l_siginfo {
85 	union {
86 		struct {
87 			l_int		lsi_signo;
88 			l_int		lsi_errno;
89 			l_int		lsi_code;
90 			union __sifields _sifields;
91 		};
92 		l_int	_pad[LINUX_SI_MAX_SIZE/sizeof(l_int)];
93 	};
94 } l_siginfo_t;
95 
96 _Static_assert(sizeof(l_siginfo_t) == LINUX_SI_MAX_SIZE, "l_siginfo_t size");
97 
98 #define	lsi_pid		_sifields._kill._pid
99 #define	lsi_uid		_sifields._kill._uid
100 #define	lsi_tid		_sifields._timer._tid
101 #define	lsi_overrun	_sifields._timer._overrun
102 #define	lsi_sys_private	_sifields._timer._sys_private
103 #define	lsi_status	_sifields._sigchld._status
104 #define	lsi_utime	_sifields._sigchld._utime
105 #define	lsi_stime	_sifields._sigchld._stime
106 #define	lsi_value	_sifields._rt._sigval
107 #define	lsi_int		_sifields._rt._sigval.sival_int
108 #define	lsi_ptr		_sifields._rt._sigval.sival_ptr
109 #define	lsi_addr	_sifields._sigfault._addr
110 #define	lsi_band	_sifields._sigpoll._band
111 #define	lsi_fd		_sifields._sigpoll._fd
112 
113 #endif /* _LINUX_SIGINFO_H_ */
114