1/*	$NetBSD: linux_siginfo.h,v 1.1 2021/09/23 06:56:27 ryo Exp $	*/
2
3/*-
4 * Copyright (c) 2021 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef _AARCH64_LINUX_SIGINFO_H
30#define _AARCH64_LINUX_SIGINFO_H
31
32#define LINUX___ARCH_SI_PREAMBLE_SIZE	(4 * sizeof(int))
33#define LINUX_SI_MAX_SIZE		128
34#define LINUX_SI_PAD_SIZE		\
35	((LINUX_SI_MAX_SIZE - LINUX___ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
36
37typedef union linux_sigval {
38	int sival_int;
39	void *sival_ptr;
40} linux_sigval_t;
41
42typedef struct linux_siginfo {
43	int lsi_signo;
44	int lsi_errno;
45	int lsi_code;
46	union {
47		int _pad[LINUX_SI_PAD_SIZE];
48
49		/* kill() */
50		struct {
51			linux_pid_t _pid;
52			linux_uid_t _uid;
53		} _kill;
54
55		/* POSIX.1b signals */
56		struct {
57			linux_pid_t _pid;
58			linux_uid_t _uid;
59			linux_sigval_t _sigval;
60		} _rt;
61
62		/* POSIX.1b timers */
63		struct {
64			linux_timer_t _tid;
65			int _overrun;
66			char _pad[sizeof(linux_uid_t) - sizeof(int)];
67			linux_sigval_t _sigval;
68			int _sys_private;
69		} _timer;
70
71		/* SIGCHLD */
72		struct {
73			linux_pid_t _pid;
74			linux_uid_t _uid;
75			int _status;
76			linux_clock_t _utime;
77			linux_clock_t _stime;
78		} _sigchld;
79
80		/* SIGPOLL */
81		struct {
82			long _band;
83			int _fd;
84		} _sigpoll;
85
86		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
87		struct {
88			void *_addr;
89#define __ADDR_BND_PKEY_PAD	\
90    (__alignof__(void *) < sizeof(short) ? sizeof(short) : __alignof__(void *))
91			union {
92				short _addr_lsb;
93				struct {
94					char _dummy_bnd[__ADDR_BND_PKEY_PAD];
95					void *_lower;
96					void *_upper;
97				} _addr_bnd;
98				struct {
99					char _dummy_pkey[__ADDR_BND_PKEY_PAD];
100					uint32_t _pkey;
101				} _addr_pkey;
102			};
103		} _sigfault;
104	} _sidata;
105} linux_siginfo_t;
106
107#endif /* !_AARCH64_LINUX_SIGINFO_H */
108