1 /*	$NetBSD: linux_signal.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_SIGNAL_H
30 #define _AARCH64_LINUX_SIGNAL_H
31 
32 #define LINUX_SIGHUP		1
33 #define LINUX_SIGINT		2
34 #define LINUX_SIGQUIT		3
35 #define LINUX_SIGILL		4
36 #define LINUX_SIGTRAP		5
37 #define LINUX_SIGABRT		6
38 #define LINUX_SIGIOT		6
39 #define LINUX_SIGBUS		7
40 #define LINUX_SIGFPE		8
41 #define LINUX_SIGKILL		9
42 #define LINUX_SIGUSR1		10
43 #define LINUX_SIGSEGV		11
44 #define LINUX_SIGUSR2		12
45 #define LINUX_SIGPIPE		13
46 #define LINUX_SIGALRM		14
47 #define LINUX_SIGTERM		15
48 #define LINUX_SIGSTKFLT		16
49 #define LINUX_SIGCHLD		17
50 #define LINUX_SIGCONT		18
51 #define LINUX_SIGSTOP		19
52 #define LINUX_SIGTSTP		20
53 #define LINUX_SIGTTIN		21
54 #define LINUX_SIGTTOU		22
55 #define LINUX_SIGURG		23
56 #define LINUX_SIGXCPU		24
57 #define LINUX_SIGXFSZ		25
58 #define LINUX_SIGVTALRM		26
59 #define LINUX_SIGPROF		27
60 #define LINUX_SIGWINCH		28
61 #define LINUX_SIGIO		29
62 #define LINUX_SIGPWR		30
63 #define LINUX_SIGSYS		31
64 /* SIGCANCEL=32, SIGSETXID=33 */
65 #define LINUX_SIGRTMIN		34
66 #define LINUX_SIGRTMAX		64
67 
68 
69 #define LINUX_SS_ONSTACK	1
70 #define LINUX_SS_DISABLE	2
71 
72 #define LINUX_SA_NOCLDSTOP	0x00000001
73 #define LINUX_SA_NOCLDWAIT	0x00000002
74 #define LINUX_SA_SIGINFO	0x00000004
75 #define LINUX_SA_ONSTACK	0x08000000
76 #define LINUX_SA_RESTART	0x10000000
77 #define LINUX_SA_NOMASK		0x40000000
78 #define LINUX_SA_ONESHOT	0x80000000
79 #define LINUX_SA_ALLBITS	0xd8000007
80 
81 
82 #define LINUX_SIG_BLOCK		0
83 #define LINUX_SIG_UNBLOCK	1
84 #define LINUX_SIG_SETMASK	2
85 
86 #define LINUX__NSIG		(LINUX_SIGRTMAX + 1)
87 #define LINUX__NSIG_BPW		64
88 #define LINUX__NSIG_WORDS	(LINUX__NSIG / LINUX__NSIG_BPW)
89 
90 #define	LINUX_MINSIGSTKSZ	2048
91 
92 typedef struct {
93 	unsigned long sig[LINUX__NSIG_WORDS];
94 } linux_sigset_t;
95 
96 typedef void (*linux_handler_t)(int);
97 
98 struct linux_sigaction {
99 	linux_handler_t linux_sa_handler;
100 	unsigned long linux_sa_flags;
101 
102 	/*
103 	 * linux/arm64 doesn't use sa_restorer,
104 	 * but struct sigaction has it for compatibility.
105 	 */
106 	void (*linux_sa_restorer)(void);
107 
108 	linux_sigset_t linux_sa_mask;
109 };
110 
111 typedef struct linux_sigaltstack {
112 	void *ss_sp;
113 	int ss_flags;
114 	size_t ss_size;
115 } linux_stack_t;
116 
117 #endif /* !_AARCH64_LINUX_SIGNAL_H */
118