1 /*	$NetBSD: svr4_signal.h,v 1.32 2013/01/02 18:50:08 dsl Exp $	 */
2 
3 /*-
4  * Copyright (c) 1994 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  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef	_SVR4_SIGNAL_H_
33 #define	_SVR4_SIGNAL_H_
34 
35 #include <compat/svr4/svr4_siginfo.h>
36 
37 #define	SVR4_SIGHUP	 1
38 #define	SVR4_SIGINT	 2
39 #define	SVR4_SIGQUIT	 3
40 #define	SVR4_SIGILL	 4
41 #define	SVR4_SIGTRAP	 5
42 #define	SVR4_SIGIOT	 6
43 #define	SVR4_SIGABRT	 6
44 #define	SVR4_SIGEMT	 7
45 #define	SVR4_SIGFPE	 8
46 #define	SVR4_SIGKILL	 9
47 #define	SVR4_SIGBUS	10
48 #define	SVR4_SIGSEGV	11
49 #define	SVR4_SIGSYS	12
50 #define	SVR4_SIGPIPE	13
51 #define	SVR4_SIGALRM	14
52 #define	SVR4_SIGTERM	15
53 #define	SVR4_SIGUSR1	16
54 #define	SVR4_SIGUSR2	17
55 #define	SVR4_SIGCLD	18
56 #define	SVR4_SIGCHLD	18
57 #define	SVR4_SIGPWR	19
58 #define	SVR4_SIGWINCH	20
59 #define	SVR4_SIGURG	21
60 #define	SVR4_SIGPOLL	22
61 #define	SVR4_SIGIO	22
62 #define	SVR4_SIGSTOP	23
63 #define	SVR4_SIGTSTP	24
64 #define	SVR4_SIGCONT	25
65 #define	SVR4_SIGTTIN	26
66 #define	SVR4_SIGTTOU	27
67 #define	SVR4_SIGVTALRM	28
68 #define	SVR4_SIGPROF	29
69 #define	SVR4_SIGXCPU	30
70 #define	SVR4_SIGXFSZ	31
71 
72 #define SVR4_SIGRTMIN	32
73 #define SVR4_SIGRTMAX	63
74 #define SVR4_NSIG	64
75 
76 #define	SVR4_SIGNO_MASK		0x00FF
77 #define	SVR4_SIGNAL_MASK	0x0000
78 #define	SVR4_SIGDEFER_MASK	0x0100
79 #define	SVR4_SIGHOLD_MASK	0x0200
80 #define	SVR4_SIGRELSE_MASK	0x0400
81 #define	SVR4_SIGIGNORE_MASK	0x0800
82 #define	SVR4_SIGPAUSE_MASK	0x1000
83 
84 typedef void (*svr4_sig_t)(int, svr4_siginfo_t *, void *);
85 #define	SVR4_SIG_DFL	(svr4_sig_t)	 0
86 #define	SVR4_SIG_ERR	(svr4_sig_t)	-1
87 #define	SVR4_SIG_IGN	(svr4_sig_t)	 1
88 #define	SVR4_SIG_HOLD	(svr4_sig_t)	 2
89 
90 #define SVR4_SIGNO(a)	((a) & SVR4_SIGNO_MASK)
91 #define SVR4_SIGCALL(a) ((a) & ~SVR4_SIGNO_MASK)
92 
93 #define SVR4_SIG_BLOCK		1
94 #define SVR4_SIG_UNBLOCK	2
95 #define SVR4_SIG_SETMASK	3
96 
97 typedef struct {
98         u_long bits[4];
99 } svr4_sigset_t;
100 
101 struct svr4_sigaction {
102 	int		svr4_sa_flags;
103 	svr4_sig_t	svr4_sa_handler;
104 	svr4_sigset_t	svr4_sa_mask;
105 	int 		svr4_sa_reserved[2];
106 };
107 
108 /* sa_flags */
109 #define SVR4_SA_ONSTACK		0x00000001
110 #define SVR4_SA_RESETHAND	0x00000002
111 #define SVR4_SA_RESTART		0x00000004
112 #define SVR4_SA_SIGINFO		0x00000008
113 #define SVR4_SA_NODEFER		0x00000010
114 #define SVR4_SA_NOCLDWAIT	0x00010000	/* No zombies 	*/
115 #define SVR4_SA_NOCLDSTOP	0x00020000	/* No jcl	*/
116 #define	SVR4_SA_ALLBITS		0x0003001f
117 
118 struct svr4_sigaltstack {
119 	char		*ss_sp;
120 	int		ss_size;
121 	int		ss_flags;
122 };
123 
124 /* ss_flags */
125 #define SVR4_SS_ONSTACK		0x00000001
126 #define SVR4_SS_DISABLE		0x00000002
127 #define SVR4_SS_ALLBITS		0x00000003
128 
129 #ifdef _KERNEL
130 extern const int native_to_svr4_signo[];
131 extern const int svr4_to_native_signo[];
132 void native_to_svr4_sigset(const sigset_t *, svr4_sigset_t *);
133 void svr4_to_native_sigset(const svr4_sigset_t *, sigset_t *);
134 void native_to_svr4_sigaltstack(const struct sigaltstack *, struct svr4_sigaltstack *);
135 void svr4_to_native_sigaltstack(const struct svr4_sigaltstack *, struct sigaltstack *);
136 void svr4_sendsig(const struct ksiginfo *, const sigset_t *);
137 #endif
138 
139 /* sys_context() function codes */
140 #define	SVR4_GETCONTEXT		0
141 #define	SVR4_SETCONTEXT		1
142 
143 #endif /* !_SVR4_SIGNAL_H_ */
144