| @@ -1,674 +1,674 @@ | | | @@ -1,674 +1,674 @@ |
1 | /* $NetBSD: svr4_32_signal.c,v 1.26.40.1 2017/08/19 03:40:50 snj Exp $ */ | | 1 | /* $NetBSD: svr4_32_signal.c,v 1.26.40.2 2017/08/19 04:02:49 snj Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1994, 1998 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1994, 1998 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Christos Zoulas and by Charles M. Hannum. | | 8 | * by Christos Zoulas and by Charles M. Hannum. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * | | 18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 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 | | 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 | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 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 | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 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 | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: svr4_32_signal.c,v 1.26.40.1 2017/08/19 03:40:50 snj Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: svr4_32_signal.c,v 1.26.40.2 2017/08/19 04:02:49 snj Exp $"); |
34 | | | 34 | |
35 | #if defined(_KERNEL_OPT) | | 35 | #if defined(_KERNEL_OPT) |
36 | #include "opt_compat_svr4.h" | | 36 | #include "opt_compat_svr4.h" |
37 | #endif | | 37 | #endif |
38 | | | 38 | |
39 | #include <sys/param.h> | | 39 | #include <sys/param.h> |
40 | #include <sys/systm.h> | | 40 | #include <sys/systm.h> |
41 | #include <sys/namei.h> | | 41 | #include <sys/namei.h> |
42 | #include <sys/proc.h> | | 42 | #include <sys/proc.h> |
43 | #include <sys/filedesc.h> | | 43 | #include <sys/filedesc.h> |
44 | #include <sys/ioctl.h> | | 44 | #include <sys/ioctl.h> |
45 | #include <sys/mount.h> | | 45 | #include <sys/mount.h> |
46 | #include <sys/kernel.h> | | 46 | #include <sys/kernel.h> |
47 | #include <sys/signal.h> | | 47 | #include <sys/signal.h> |
48 | #include <sys/signalvar.h> | | 48 | #include <sys/signalvar.h> |
49 | #include <sys/malloc.h> | | 49 | #include <sys/malloc.h> |
50 | #include <sys/wait.h> | | 50 | #include <sys/wait.h> |
51 | | | 51 | |
52 | #include <sys/syscallargs.h> | | 52 | #include <sys/syscallargs.h> |
53 | | | 53 | |
54 | #include <compat/svr4_32/svr4_32_types.h> | | 54 | #include <compat/svr4_32/svr4_32_types.h> |
55 | #include <compat/svr4_32/svr4_32_signal.h> | | 55 | #include <compat/svr4_32/svr4_32_signal.h> |
56 | #include <compat/svr4_32/svr4_32_lwp.h> | | 56 | #include <compat/svr4_32/svr4_32_lwp.h> |
57 | #include <compat/svr4_32/svr4_32_ucontext.h> | | 57 | #include <compat/svr4_32/svr4_32_ucontext.h> |
58 | #include <compat/svr4_32/svr4_32_syscallargs.h> | | 58 | #include <compat/svr4_32/svr4_32_syscallargs.h> |
59 | #include <compat/svr4_32/svr4_32_util.h> | | 59 | #include <compat/svr4_32/svr4_32_util.h> |
60 | | | 60 | |
61 | #include <compat/common/compat_sigaltstack.h> | | 61 | #include <compat/common/compat_sigaltstack.h> |
62 | | | 62 | |
63 | #define svr4_sigmask(n) (1 << (((n) - 1) & 31)) | | 63 | #define svr4_sigmask(n) (1 << (((n) - 1) & 31)) |
64 | #define svr4_sigword(n) (((n) - 1) >> 5) | | 64 | #define svr4_sigword(n) (((n) - 1) >> 5) |
65 | #define svr4_sigemptyset(s) memset((s), 0, sizeof(*(s))) | | 65 | #define svr4_sigemptyset(s) memset((s), 0, sizeof(*(s))) |
66 | #define svr4_sigismember(s, n) ((s)->bits[svr4_sigword(n)] & svr4_sigmask(n)) | | 66 | #define svr4_sigismember(s, n) ((s)->bits[svr4_sigword(n)] & svr4_sigmask(n)) |
67 | #define svr4_sigaddset(s, n) ((s)->bits[svr4_sigword(n)] |= svr4_sigmask(n)) | | 67 | #define svr4_sigaddset(s, n) ((s)->bits[svr4_sigword(n)] |= svr4_sigmask(n)) |
68 | | | 68 | |
69 | static inline void svr4_32_sigfillset(svr4_32_sigset_t *); | | 69 | static inline void svr4_32_sigfillset(svr4_32_sigset_t *); |
70 | void svr4_32_to_native_sigaction(const struct svr4_32_sigaction *, | | 70 | void svr4_32_to_native_sigaction(const struct svr4_32_sigaction *, |
71 | struct sigaction *); | | 71 | struct sigaction *); |
72 | void native_to_svr4_32_sigaction(const struct sigaction *, | | 72 | void native_to_svr4_32_sigaction(const struct sigaction *, |
73 | struct svr4_32_sigaction *); | | 73 | struct svr4_32_sigaction *); |
74 | | | 74 | |
75 | #ifndef COMPAT_SVR4 | | 75 | #ifndef COMPAT_SVR4 |
76 | const int native_to_svr4_signo[NSIG] = { | | 76 | const int native_to_svr4_signo[NSIG] = { |
77 | 0, /* 0 */ | | 77 | 0, /* 0 */ |
78 | SVR4_SIGHUP, /* 1 */ | | 78 | SVR4_SIGHUP, /* 1 */ |
79 | SVR4_SIGINT, /* 2 */ | | 79 | SVR4_SIGINT, /* 2 */ |
80 | SVR4_SIGQUIT, /* 3 */ | | 80 | SVR4_SIGQUIT, /* 3 */ |
81 | SVR4_SIGILL, /* 4 */ | | 81 | SVR4_SIGILL, /* 4 */ |
82 | SVR4_SIGTRAP, /* 5 */ | | 82 | SVR4_SIGTRAP, /* 5 */ |
83 | SVR4_SIGABRT, /* 6 */ | | 83 | SVR4_SIGABRT, /* 6 */ |
84 | SVR4_SIGEMT, /* 7 */ | | 84 | SVR4_SIGEMT, /* 7 */ |
85 | SVR4_SIGFPE, /* 8 */ | | 85 | SVR4_SIGFPE, /* 8 */ |
86 | SVR4_SIGKILL, /* 9 */ | | 86 | SVR4_SIGKILL, /* 9 */ |
87 | SVR4_SIGBUS, /* 10 */ | | 87 | SVR4_SIGBUS, /* 10 */ |
88 | SVR4_SIGSEGV, /* 11 */ | | 88 | SVR4_SIGSEGV, /* 11 */ |
89 | SVR4_SIGSYS, /* 12 */ | | 89 | SVR4_SIGSYS, /* 12 */ |
90 | SVR4_SIGPIPE, /* 13 */ | | 90 | SVR4_SIGPIPE, /* 13 */ |
91 | SVR4_SIGALRM, /* 14 */ | | 91 | SVR4_SIGALRM, /* 14 */ |
92 | SVR4_SIGTERM, /* 15 */ | | 92 | SVR4_SIGTERM, /* 15 */ |
93 | SVR4_SIGURG, /* 16 */ | | 93 | SVR4_SIGURG, /* 16 */ |
94 | SVR4_SIGSTOP, /* 17 */ | | 94 | SVR4_SIGSTOP, /* 17 */ |
95 | SVR4_SIGTSTP, /* 18 */ | | 95 | SVR4_SIGTSTP, /* 18 */ |
96 | SVR4_SIGCONT, /* 19 */ | | 96 | SVR4_SIGCONT, /* 19 */ |
97 | SVR4_SIGCHLD, /* 20 */ | | 97 | SVR4_SIGCHLD, /* 20 */ |
98 | SVR4_SIGTTIN, /* 21 */ | | 98 | SVR4_SIGTTIN, /* 21 */ |
99 | SVR4_SIGTTOU, /* 22 */ | | 99 | SVR4_SIGTTOU, /* 22 */ |
100 | SVR4_SIGIO, /* 23 */ | | 100 | SVR4_SIGIO, /* 23 */ |
101 | SVR4_SIGXCPU, /* 24 */ | | 101 | SVR4_SIGXCPU, /* 24 */ |
102 | SVR4_SIGXFSZ, /* 25 */ | | 102 | SVR4_SIGXFSZ, /* 25 */ |
103 | SVR4_SIGVTALRM, /* 26 */ | | 103 | SVR4_SIGVTALRM, /* 26 */ |
104 | SVR4_SIGPROF, /* 27 */ | | 104 | SVR4_SIGPROF, /* 27 */ |
105 | SVR4_SIGWINCH, /* 28 */ | | 105 | SVR4_SIGWINCH, /* 28 */ |
106 | 0, /* 29 SIGINFO */ | | 106 | 0, /* 29 SIGINFO */ |
107 | SVR4_SIGUSR1, /* 30 */ | | 107 | SVR4_SIGUSR1, /* 30 */ |
108 | SVR4_SIGUSR2, /* 31 */ | | 108 | SVR4_SIGUSR2, /* 31 */ |
109 | SVR4_SIGPWR, /* 32 */ | | 109 | SVR4_SIGPWR, /* 32 */ |
110 | SVR4_SIGRTMIN + 0, /* 33 */ | | 110 | SVR4_SIGRTMIN + 0, /* 33 */ |
111 | SVR4_SIGRTMIN + 1, /* 34 */ | | 111 | SVR4_SIGRTMIN + 1, /* 34 */ |
112 | SVR4_SIGRTMIN + 2, /* 35 */ | | 112 | SVR4_SIGRTMIN + 2, /* 35 */ |
113 | SVR4_SIGRTMIN + 3, /* 36 */ | | 113 | SVR4_SIGRTMIN + 3, /* 36 */ |
114 | SVR4_SIGRTMIN + 4, /* 37 */ | | 114 | SVR4_SIGRTMIN + 4, /* 37 */ |
115 | SVR4_SIGRTMIN + 5, /* 38 */ | | 115 | SVR4_SIGRTMIN + 5, /* 38 */ |
116 | SVR4_SIGRTMIN + 6, /* 39 */ | | 116 | SVR4_SIGRTMIN + 6, /* 39 */ |
117 | SVR4_SIGRTMIN + 7, /* 40 */ | | 117 | SVR4_SIGRTMIN + 7, /* 40 */ |
118 | SVR4_SIGRTMIN + 8, /* 41 */ | | 118 | SVR4_SIGRTMIN + 8, /* 41 */ |
119 | SVR4_SIGRTMIN + 9, /* 42 */ | | 119 | SVR4_SIGRTMIN + 9, /* 42 */ |
120 | SVR4_SIGRTMIN + 10, /* 43 */ | | 120 | SVR4_SIGRTMIN + 10, /* 43 */ |
121 | SVR4_SIGRTMIN + 11, /* 44 */ | | 121 | SVR4_SIGRTMIN + 11, /* 44 */ |
122 | SVR4_SIGRTMIN + 12, /* 45 */ | | 122 | SVR4_SIGRTMIN + 12, /* 45 */ |
123 | SVR4_SIGRTMIN + 13, /* 46 */ | | 123 | SVR4_SIGRTMIN + 13, /* 46 */ |
124 | SVR4_SIGRTMIN + 14, /* 47 */ | | 124 | SVR4_SIGRTMIN + 14, /* 47 */ |
125 | SVR4_SIGRTMIN + 15, /* 48 */ | | 125 | SVR4_SIGRTMIN + 15, /* 48 */ |
126 | SVR4_SIGRTMIN + 16, /* 49 */ | | 126 | SVR4_SIGRTMIN + 16, /* 49 */ |
127 | SVR4_SIGRTMIN + 17, /* 50 */ | | 127 | SVR4_SIGRTMIN + 17, /* 50 */ |
128 | SVR4_SIGRTMIN + 18, /* 51 */ | | 128 | SVR4_SIGRTMIN + 18, /* 51 */ |
129 | SVR4_SIGRTMIN + 19, /* 52 */ | | 129 | SVR4_SIGRTMIN + 19, /* 52 */ |
130 | SVR4_SIGRTMIN + 20, /* 53 */ | | 130 | SVR4_SIGRTMIN + 20, /* 53 */ |
131 | SVR4_SIGRTMIN + 21, /* 54 */ | | 131 | SVR4_SIGRTMIN + 21, /* 54 */ |
132 | SVR4_SIGRTMIN + 22, /* 55 */ | | 132 | SVR4_SIGRTMIN + 22, /* 55 */ |
133 | SVR4_SIGRTMIN + 23, /* 56 */ | | 133 | SVR4_SIGRTMIN + 23, /* 56 */ |
134 | SVR4_SIGRTMIN + 24, /* 57 */ | | 134 | SVR4_SIGRTMIN + 24, /* 57 */ |
135 | SVR4_SIGRTMIN + 25, /* 58 */ | | 135 | SVR4_SIGRTMIN + 25, /* 58 */ |
136 | SVR4_SIGRTMIN + 26, /* 59 */ | | 136 | SVR4_SIGRTMIN + 26, /* 59 */ |
137 | SVR4_SIGRTMIN + 27, /* 60 */ | | 137 | SVR4_SIGRTMIN + 27, /* 60 */ |
138 | SVR4_SIGRTMIN + 28, /* 61 */ | | 138 | SVR4_SIGRTMIN + 28, /* 61 */ |
139 | SVR4_SIGRTMIN + 29, /* 62 */ | | 139 | SVR4_SIGRTMIN + 29, /* 62 */ |
140 | SVR4_SIGRTMIN + 30, /* 63 */ | | 140 | SVR4_SIGRTMIN + 30, /* 63 */ |
141 | }; | | 141 | }; |
142 | | | 142 | |
143 | const int svr4_to_native_signo[SVR4_NSIG] = { | | 143 | const int svr4_to_native_signo[SVR4_NSIG] = { |
144 | 0, /* 0 */ | | 144 | 0, /* 0 */ |
145 | SIGHUP, /* 1 */ | | 145 | SIGHUP, /* 1 */ |
146 | SIGINT, /* 2 */ | | 146 | SIGINT, /* 2 */ |
147 | SIGQUIT, /* 3 */ | | 147 | SIGQUIT, /* 3 */ |
148 | SIGILL, /* 4 */ | | 148 | SIGILL, /* 4 */ |
149 | SIGTRAP, /* 5 */ | | 149 | SIGTRAP, /* 5 */ |
150 | SIGABRT, /* 6 */ | | 150 | SIGABRT, /* 6 */ |
151 | SIGEMT, /* 7 */ | | 151 | SIGEMT, /* 7 */ |
152 | SIGFPE, /* 8 */ | | 152 | SIGFPE, /* 8 */ |
153 | SIGKILL, /* 9 */ | | 153 | SIGKILL, /* 9 */ |
154 | SIGBUS, /* 10 */ | | 154 | SIGBUS, /* 10 */ |
155 | SIGSEGV, /* 11 */ | | 155 | SIGSEGV, /* 11 */ |
156 | SIGSYS, /* 12 */ | | 156 | SIGSYS, /* 12 */ |
157 | SIGPIPE, /* 13 */ | | 157 | SIGPIPE, /* 13 */ |
158 | SIGALRM, /* 14 */ | | 158 | SIGALRM, /* 14 */ |
159 | SIGTERM, /* 15 */ | | 159 | SIGTERM, /* 15 */ |
160 | SIGUSR1, /* 16 */ | | 160 | SIGUSR1, /* 16 */ |
161 | SIGUSR2, /* 17 */ | | 161 | SIGUSR2, /* 17 */ |
162 | SIGCHLD, /* 18 */ | | 162 | SIGCHLD, /* 18 */ |
163 | SIGPWR, /* 19 */ | | 163 | SIGPWR, /* 19 */ |
164 | SIGWINCH, /* 20 */ | | 164 | SIGWINCH, /* 20 */ |
165 | SIGURG, /* 21 */ | | 165 | SIGURG, /* 21 */ |
166 | SIGIO, /* 22 */ | | 166 | SIGIO, /* 22 */ |
167 | SIGSTOP, /* 23 */ | | 167 | SIGSTOP, /* 23 */ |
168 | SIGTSTP, /* 24 */ | | 168 | SIGTSTP, /* 24 */ |
169 | SIGCONT, /* 25 */ | | 169 | SIGCONT, /* 25 */ |
170 | SIGTTIN, /* 26 */ | | 170 | SIGTTIN, /* 26 */ |
171 | SIGTTOU, /* 27 */ | | 171 | SIGTTOU, /* 27 */ |
172 | SIGVTALRM, /* 28 */ | | 172 | SIGVTALRM, /* 28 */ |
173 | SIGPROF, /* 29 */ | | 173 | SIGPROF, /* 29 */ |
174 | SIGXCPU, /* 30 */ | | 174 | SIGXCPU, /* 30 */ |
175 | SIGXFSZ, /* 31 */ | | 175 | SIGXFSZ, /* 31 */ |
176 | SIGRTMIN + 0, /* 32 */ | | 176 | SIGRTMIN + 0, /* 32 */ |
177 | SIGRTMIN + 1, /* 33 */ | | 177 | SIGRTMIN + 1, /* 33 */ |
178 | SIGRTMIN + 2, /* 34 */ | | 178 | SIGRTMIN + 2, /* 34 */ |
179 | SIGRTMIN + 3, /* 35 */ | | 179 | SIGRTMIN + 3, /* 35 */ |
180 | SIGRTMIN + 4, /* 36 */ | | 180 | SIGRTMIN + 4, /* 36 */ |
181 | SIGRTMIN + 5, /* 37 */ | | 181 | SIGRTMIN + 5, /* 37 */ |
182 | SIGRTMIN + 6, /* 38 */ | | 182 | SIGRTMIN + 6, /* 38 */ |
183 | SIGRTMIN + 7, /* 39 */ | | 183 | SIGRTMIN + 7, /* 39 */ |
184 | SIGRTMIN + 8, /* 40 */ | | 184 | SIGRTMIN + 8, /* 40 */ |
185 | SIGRTMIN + 9, /* 41 */ | | 185 | SIGRTMIN + 9, /* 41 */ |
186 | SIGRTMIN + 10, /* 42 */ | | 186 | SIGRTMIN + 10, /* 42 */ |
187 | SIGRTMIN + 11, /* 43 */ | | 187 | SIGRTMIN + 11, /* 43 */ |
188 | SIGRTMIN + 12, /* 44 */ | | 188 | SIGRTMIN + 12, /* 44 */ |
189 | SIGRTMIN + 13, /* 45 */ | | 189 | SIGRTMIN + 13, /* 45 */ |
190 | SIGRTMIN + 14, /* 46 */ | | 190 | SIGRTMIN + 14, /* 46 */ |
191 | SIGRTMIN + 15, /* 47 */ | | 191 | SIGRTMIN + 15, /* 47 */ |
192 | SIGRTMIN + 16, /* 48 */ | | 192 | SIGRTMIN + 16, /* 48 */ |
193 | SIGRTMIN + 17, /* 49 */ | | 193 | SIGRTMIN + 17, /* 49 */ |
194 | SIGRTMIN + 18, /* 50 */ | | 194 | SIGRTMIN + 18, /* 50 */ |
195 | SIGRTMIN + 19, /* 51 */ | | 195 | SIGRTMIN + 19, /* 51 */ |
196 | SIGRTMIN + 20, /* 52 */ | | 196 | SIGRTMIN + 20, /* 52 */ |
197 | SIGRTMIN + 21, /* 53 */ | | 197 | SIGRTMIN + 21, /* 53 */ |
198 | SIGRTMIN + 22, /* 54 */ | | 198 | SIGRTMIN + 22, /* 54 */ |
199 | SIGRTMIN + 23, /* 55 */ | | 199 | SIGRTMIN + 23, /* 55 */ |
200 | SIGRTMIN + 24, /* 56 */ | | 200 | SIGRTMIN + 24, /* 56 */ |
201 | SIGRTMIN + 25, /* 57 */ | | 201 | SIGRTMIN + 25, /* 57 */ |
202 | SIGRTMIN + 26, /* 58 */ | | 202 | SIGRTMIN + 26, /* 58 */ |
203 | SIGRTMIN + 27, /* 59 */ | | 203 | SIGRTMIN + 27, /* 59 */ |
204 | SIGRTMIN + 28, /* 60 */ | | 204 | SIGRTMIN + 28, /* 60 */ |
205 | SIGRTMIN + 29, /* 61 */ | | 205 | SIGRTMIN + 29, /* 61 */ |
206 | SIGRTMIN + 30, /* 62 */ | | 206 | SIGRTMIN + 30, /* 62 */ |
207 | 0, /* 63 */ | | 207 | 0, /* 63 */ |
208 | }; | | 208 | }; |
209 | #endif | | 209 | #endif |
210 | | | 210 | |
211 | static int | | 211 | static int |
212 | svr4_32_decode_signum(int signum, int *native_signo, int *sigcall) | | 212 | svr4_32_decode_signum(int signum, int *native_signo, int *sigcall) |
213 | { | | 213 | { |
214 | | | 214 | |
215 | if (SVR4_SIGNO(signum) >= SVR4_NSIG) | | 215 | if (SVR4_SIGNO(signum) >= SVR4_NSIG) |
216 | return EINVAL; | | 216 | return EINVAL; |
217 | | | 217 | |
218 | if (native_signo) | | 218 | if (native_signo) |
219 | *native_signo = svr4_to_native_signo[SVR4_SIGNO(signum)]; | | 219 | *native_signo = svr4_to_native_signo[SVR4_SIGNO(signum)]; |
220 | if (sigcall) | | 220 | if (sigcall) |
221 | *sigcall = SVR4_SIGCALL(signum); | | 221 | *sigcall = SVR4_SIGCALL(signum); |
222 | | | 222 | |
223 | return 0; | | 223 | return 0; |
224 | } | | 224 | } |
225 | | | 225 | |
226 | static inline void | | 226 | static inline void |
227 | svr4_32_sigfillset(svr4_32_sigset_t *s) | | 227 | svr4_32_sigfillset(svr4_32_sigset_t *s) |
228 | { | | 228 | { |
229 | int i; | | 229 | int i; |
230 | | | 230 | |
231 | svr4_sigemptyset(s); | | 231 | svr4_sigemptyset(s); |
232 | for (i = 1; i < SVR4_NSIG; i++) | | 232 | for (i = 1; i < SVR4_NSIG; i++) |
233 | if (svr4_to_native_signo[i] != 0) | | 233 | if (svr4_to_native_signo[i] != 0) |
234 | svr4_sigaddset(s, i); | | 234 | svr4_sigaddset(s, i); |
235 | } | | 235 | } |
236 | | | 236 | |
237 | void | | 237 | void |
238 | svr4_32_to_native_sigset(const svr4_32_sigset_t *sss, sigset_t *bss) | | 238 | svr4_32_to_native_sigset(const svr4_32_sigset_t *sss, sigset_t *bss) |
239 | { | | 239 | { |
240 | int i, newsig; | | 240 | int i, newsig; |
241 | | | 241 | |
242 | sigemptyset(bss); | | 242 | sigemptyset(bss); |
243 | for (i = 1; i < SVR4_NSIG; i++) { | | 243 | for (i = 1; i < SVR4_NSIG; i++) { |
244 | if (svr4_sigismember(sss, i)) { | | 244 | if (svr4_sigismember(sss, i)) { |
245 | newsig = svr4_to_native_signo[i]; | | 245 | newsig = svr4_to_native_signo[i]; |
246 | if (newsig) | | 246 | if (newsig) |
247 | sigaddset(bss, newsig); | | 247 | sigaddset(bss, newsig); |
248 | } | | 248 | } |
249 | } | | 249 | } |
250 | } | | 250 | } |
251 | | | 251 | |
252 | | | 252 | |
253 | void | | 253 | void |
254 | native_to_svr4_32_sigset(const sigset_t *bss, svr4_32_sigset_t *sss) | | 254 | native_to_svr4_32_sigset(const sigset_t *bss, svr4_32_sigset_t *sss) |
255 | { | | 255 | { |
256 | int i, newsig; | | 256 | int i, newsig; |
257 | | | 257 | |
258 | svr4_sigemptyset(sss); | | 258 | svr4_sigemptyset(sss); |
259 | for (i = 1; i < NSIG; i++) { | | 259 | for (i = 1; i < NSIG; i++) { |
260 | if (sigismember(bss, i)) { | | 260 | if (sigismember(bss, i)) { |
261 | newsig = native_to_svr4_signo[i]; | | 261 | newsig = native_to_svr4_signo[i]; |
262 | if (newsig) | | 262 | if (newsig) |
263 | svr4_sigaddset(sss, newsig); | | 263 | svr4_sigaddset(sss, newsig); |
264 | } | | 264 | } |
265 | } | | 265 | } |
266 | } | | 266 | } |
267 | | | 267 | |
268 | /* | | 268 | /* |
269 | * XXX: Only a subset of the flags is currently implemented. | | 269 | * XXX: Only a subset of the flags is currently implemented. |
270 | */ | | 270 | */ |
271 | void | | 271 | void |
272 | svr4_32_to_native_sigaction(const struct svr4_32_sigaction *ssa, struct sigaction *bsa) | | 272 | svr4_32_to_native_sigaction(const struct svr4_32_sigaction *ssa, struct sigaction *bsa) |
273 | { | | 273 | { |
274 | | | 274 | |
275 | bsa->sa_handler = NETBSD32PTR64(ssa->svr4_32_sa_handler); | | 275 | bsa->sa_handler = NETBSD32PTR64(ssa->svr4_32_sa_handler); |
276 | svr4_32_to_native_sigset(&ssa->svr4_32_sa_mask, &bsa->sa_mask); | | 276 | svr4_32_to_native_sigset(&ssa->svr4_32_sa_mask, &bsa->sa_mask); |
277 | bsa->sa_flags = 0; | | 277 | bsa->sa_flags = 0; |
278 | if ((ssa->svr4_32_sa_flags & SVR4_SA_ONSTACK) != 0) | | 278 | if ((ssa->svr4_32_sa_flags & SVR4_SA_ONSTACK) != 0) |
279 | bsa->sa_flags |= SA_ONSTACK; | | 279 | bsa->sa_flags |= SA_ONSTACK; |
280 | if ((ssa->svr4_32_sa_flags & SVR4_SA_RESETHAND) != 0) | | 280 | if ((ssa->svr4_32_sa_flags & SVR4_SA_RESETHAND) != 0) |
281 | bsa->sa_flags |= SA_RESETHAND; | | 281 | bsa->sa_flags |= SA_RESETHAND; |
282 | if ((ssa->svr4_32_sa_flags & SVR4_SA_RESTART) != 0) | | 282 | if ((ssa->svr4_32_sa_flags & SVR4_SA_RESTART) != 0) |
283 | bsa->sa_flags |= SA_RESTART; | | 283 | bsa->sa_flags |= SA_RESTART; |
284 | if ((ssa->svr4_32_sa_flags & SVR4_SA_SIGINFO) != 0) { | | 284 | if ((ssa->svr4_32_sa_flags & SVR4_SA_SIGINFO) != 0) { |
285 | DPRINTF(("svr4_to_native_sigaction: SA_SIGINFO ignored\n")); | | 285 | DPRINTF(("svr4_to_native_sigaction: SA_SIGINFO ignored\n")); |
286 | } | | 286 | } |
287 | if ((ssa->svr4_32_sa_flags & SVR4_SA_NODEFER) != 0) | | 287 | if ((ssa->svr4_32_sa_flags & SVR4_SA_NODEFER) != 0) |
288 | bsa->sa_flags |= SA_NODEFER; | | 288 | bsa->sa_flags |= SA_NODEFER; |
289 | if ((ssa->svr4_32_sa_flags & SVR4_SA_NOCLDWAIT) != 0) | | 289 | if ((ssa->svr4_32_sa_flags & SVR4_SA_NOCLDWAIT) != 0) |
290 | bsa->sa_flags |= SA_NOCLDWAIT; | | 290 | bsa->sa_flags |= SA_NOCLDWAIT; |
291 | if ((ssa->svr4_32_sa_flags & SVR4_SA_NOCLDSTOP) != 0) | | 291 | if ((ssa->svr4_32_sa_flags & SVR4_SA_NOCLDSTOP) != 0) |
292 | bsa->sa_flags |= SA_NOCLDSTOP; | | 292 | bsa->sa_flags |= SA_NOCLDSTOP; |
293 | if ((ssa->svr4_32_sa_flags & ~SVR4_SA_ALLBITS) != 0) { | | 293 | if ((ssa->svr4_32_sa_flags & ~SVR4_SA_ALLBITS) != 0) { |
294 | DPRINTF(("svr4_32_to_native_sigaction: extra bits %x ignored\n", | | 294 | DPRINTF(("svr4_32_to_native_sigaction: extra bits %x ignored\n", |
295 | ssa->svr4_32_sa_flags & ~SVR4_SA_ALLBITS)); | | 295 | ssa->svr4_32_sa_flags & ~SVR4_SA_ALLBITS)); |
296 | } | | 296 | } |
297 | } | | 297 | } |
298 | | | 298 | |
299 | void | | 299 | void |
300 | native_to_svr4_32_sigaction(const struct sigaction *bsa, struct svr4_32_sigaction *ssa) | | 300 | native_to_svr4_32_sigaction(const struct sigaction *bsa, struct svr4_32_sigaction *ssa) |
301 | { | | 301 | { |
302 | | | 302 | |
303 | NETBSD32PTR32(ssa->svr4_32_sa_handler, bsa->sa_handler); | | 303 | NETBSD32PTR32(ssa->svr4_32_sa_handler, bsa->sa_handler); |
304 | native_to_svr4_32_sigset(&bsa->sa_mask, &ssa->svr4_32_sa_mask); | | 304 | native_to_svr4_32_sigset(&bsa->sa_mask, &ssa->svr4_32_sa_mask); |
305 | ssa->svr4_32_sa_flags = 0; | | 305 | ssa->svr4_32_sa_flags = 0; |
306 | if ((bsa->sa_flags & SA_ONSTACK) != 0) | | 306 | if ((bsa->sa_flags & SA_ONSTACK) != 0) |
307 | ssa->svr4_32_sa_flags |= SVR4_SA_ONSTACK; | | 307 | ssa->svr4_32_sa_flags |= SVR4_SA_ONSTACK; |
308 | if ((bsa->sa_flags & SA_RESETHAND) != 0) | | 308 | if ((bsa->sa_flags & SA_RESETHAND) != 0) |
309 | ssa->svr4_32_sa_flags |= SVR4_SA_RESETHAND; | | 309 | ssa->svr4_32_sa_flags |= SVR4_SA_RESETHAND; |
310 | if ((bsa->sa_flags & SA_RESTART) != 0) | | 310 | if ((bsa->sa_flags & SA_RESTART) != 0) |
311 | ssa->svr4_32_sa_flags |= SVR4_SA_RESTART; | | 311 | ssa->svr4_32_sa_flags |= SVR4_SA_RESTART; |
312 | if ((bsa->sa_flags & SA_NODEFER) != 0) | | 312 | if ((bsa->sa_flags & SA_NODEFER) != 0) |
313 | ssa->svr4_32_sa_flags |= SVR4_SA_NODEFER; | | 313 | ssa->svr4_32_sa_flags |= SVR4_SA_NODEFER; |
314 | if ((bsa->sa_flags & SA_NOCLDSTOP) != 0) | | 314 | if ((bsa->sa_flags & SA_NOCLDSTOP) != 0) |
315 | ssa->svr4_32_sa_flags |= SVR4_SA_NOCLDSTOP; | | 315 | ssa->svr4_32_sa_flags |= SVR4_SA_NOCLDSTOP; |
316 | } | | 316 | } |
317 | | | 317 | |
318 | int | | 318 | int |
319 | svr4_32_sys_sigaction(struct lwp *l, const struct svr4_32_sys_sigaction_args *uap, register_t *retval) | | 319 | svr4_32_sys_sigaction(struct lwp *l, const struct svr4_32_sys_sigaction_args *uap, register_t *retval) |
320 | { | | 320 | { |
321 | /* { | | 321 | /* { |
322 | syscallarg(int) signum; | | 322 | syscallarg(int) signum; |
323 | syscallarg(const struct svr4_32_sigaction *) nsa; | | 323 | syscallarg(const struct svr4_32_sigaction *) nsa; |
324 | syscallarg(struct svr4_32_sigaction *) osa; | | 324 | syscallarg(struct svr4_32_sigaction *) osa; |
325 | } */ | | 325 | } */ |
326 | struct svr4_32_sigaction nssa, ossa; | | 326 | struct svr4_32_sigaction nssa, ossa; |
327 | struct sigaction nbsa, obsa; | | 327 | struct sigaction nbsa, obsa; |
328 | int native_signo; | | 328 | int native_signo; |
329 | int error; | | 329 | int error; |
330 | | | 330 | |
331 | if (SCARG_P32(uap, nsa)) { | | 331 | if (SCARG_P32(uap, nsa)) { |
332 | error = copyin(SCARG_P32(uap, nsa), | | 332 | error = copyin(SCARG_P32(uap, nsa), |
333 | &nssa, sizeof(nssa)); | | 333 | &nssa, sizeof(nssa)); |
334 | if (error) | | 334 | if (error) |
335 | return (error); | | 335 | return (error); |
336 | svr4_32_to_native_sigaction(&nssa, &nbsa); | | 336 | svr4_32_to_native_sigaction(&nssa, &nbsa); |
337 | } | | 337 | } |
338 | | | 338 | |
339 | error = svr4_32_decode_signum(SCARG(uap, signum), &native_signo, NULL); | | 339 | error = svr4_32_decode_signum(SCARG(uap, signum), &native_signo, NULL); |
340 | if (error) | | 340 | if (error) |
341 | return error; | | 341 | return error; |
342 | | | 342 | |
343 | error = sigaction1(l, native_signo, | | 343 | error = sigaction1(l, native_signo, |
344 | SCARG_P32(uap, nsa) ? &nbsa : 0, SCARG_P32(uap, osa) ? &obsa : 0, | | 344 | SCARG_P32(uap, nsa) ? &nbsa : 0, SCARG_P32(uap, osa) ? &obsa : 0, |
345 | NULL, 0); | | 345 | NULL, 0); |
346 | if (error) | | 346 | if (error) |
347 | return (error); | | 347 | return (error); |
348 | if (SCARG_P32(uap, osa)) { | | 348 | if (SCARG_P32(uap, osa)) { |
349 | native_to_svr4_32_sigaction(&obsa, &ossa); | | 349 | native_to_svr4_32_sigaction(&obsa, &ossa); |
350 | error = copyout(&ossa, SCARG_P32(uap, osa), | | 350 | error = copyout(&ossa, SCARG_P32(uap, osa), |
351 | sizeof(ossa)); | | 351 | sizeof(ossa)); |
352 | if (error) | | 352 | if (error) |
353 | return (error); | | 353 | return (error); |
354 | } | | 354 | } |
355 | return (0); | | 355 | return (0); |
356 | } | | 356 | } |
357 | | | 357 | |
358 | int | | 358 | int |
359 | svr4_32_sys_sigaltstack(struct lwp *l, const struct svr4_32_sys_sigaltstack_args *uap, register_t *retval) | | 359 | svr4_32_sys_sigaltstack(struct lwp *l, const struct svr4_32_sys_sigaltstack_args *uap, register_t *retval) |
360 | { | | 360 | { |
361 | /* { | | 361 | /* { |
362 | syscallarg(const struct svr4_32_sigaltstack_tp) nss; | | 362 | syscallarg(const struct svr4_32_sigaltstack_tp) nss; |
363 | syscallarg(struct svr4_32_sigaltstack_tp) oss; | | 363 | syscallarg(struct svr4_32_sigaltstack_tp) oss; |
364 | } */ | | 364 | } */ |
365 | compat_sigaltstack(uap, svr4_32_sigaltstack, | | 365 | compat_sigaltstack(uap, svr4_32_sigaltstack, |
366 | SVR4_SS_ONSTACK, SVR4_SS_DISABLE); | | 366 | SVR4_SS_ONSTACK, SVR4_SS_DISABLE); |
367 | } | | 367 | } |
368 | | | 368 | |
369 | /* | | 369 | /* |
370 | * Stolen from the ibcs2 one | | 370 | * Stolen from the ibcs2 one |
371 | */ | | 371 | */ |
372 | int | | 372 | int |
373 | svr4_32_sys_signal(struct lwp *l, const struct svr4_32_sys_signal_args *uap, register_t *retval) | | 373 | svr4_32_sys_signal(struct lwp *l, const struct svr4_32_sys_signal_args *uap, register_t *retval) |
374 | { | | 374 | { |
375 | /* { | | 375 | /* { |
376 | syscallarg(int) signum; | | 376 | syscallarg(int) signum; |
377 | syscallarg(svr4_32_sig_t) handler; | | 377 | syscallarg(svr4_32_sig_t) handler; |
378 | } */ | | 378 | } */ |
379 | struct proc *p = l->l_proc; | | 379 | struct proc *p = l->l_proc; |
380 | int native_signo, sigcall; | | 380 | int native_signo, sigcall; |
381 | struct sigaction nbsa, obsa; | | 381 | struct sigaction nbsa, obsa; |
382 | sigset_t ss; | | 382 | sigset_t ss; |
383 | int error; | | 383 | int error; |
384 | | | 384 | |
385 | error = svr4_32_decode_signum(SCARG(uap, signum), &native_signo, | | 385 | error = svr4_32_decode_signum(SCARG(uap, signum), &native_signo, |
386 | &sigcall); | | 386 | &sigcall); |
387 | if (error) | | 387 | if (error) |
388 | return error; | | 388 | return error; |
389 | | | 389 | |
390 | switch (sigcall) { | | 390 | switch (sigcall) { |
391 | case SVR4_SIGDEFER_MASK: | | 391 | case SVR4_SIGDEFER_MASK: |
392 | if (SCARG(uap, handler) == SVR4_SIG_HOLD) | | 392 | if (SCARG(uap, handler) == SVR4_SIG_HOLD) |
393 | goto sighold; | | 393 | goto sighold; |
394 | /* FALLTHROUGH */ | | 394 | /* FALLTHROUGH */ |
395 | | | 395 | |
396 | case SVR4_SIGNAL_MASK: | | 396 | case SVR4_SIGNAL_MASK: |
397 | nbsa.sa_handler = (sig_t)SCARG(uap, handler); | | 397 | nbsa.sa_handler = (sig_t)SCARG(uap, handler); |
398 | sigemptyset(&nbsa.sa_mask); | | 398 | sigemptyset(&nbsa.sa_mask); |
399 | nbsa.sa_flags = 0; | | 399 | nbsa.sa_flags = 0; |
400 | error = sigaction1(l, signum, &nbsa, &obsa, NULL, 0); | | 400 | error = sigaction1(l, native_signo, &nbsa, &obsa, NULL, 0); |
401 | if (error) | | 401 | if (error) |
402 | return (error); | | 402 | return error; |
403 | *retval = (u_int)(u_long)obsa.sa_handler; | | 403 | *retval = (u_int)(u_long)obsa.sa_handler; |
404 | return (0); | | 404 | return 0; |
405 | | | 405 | |
406 | case SVR4_SIGHOLD_MASK: | | 406 | case SVR4_SIGHOLD_MASK: |
407 | sighold: | | 407 | sighold: |
408 | sigemptyset(&ss); | | 408 | sigemptyset(&ss); |
409 | sigaddset(&ss, signum); | | 409 | sigaddset(&ss, native_signo); |
410 | mutex_enter(p->p_lock); | | 410 | mutex_enter(p->p_lock); |
411 | error = sigprocmask1(l, SIG_BLOCK, &ss, 0); | | 411 | error = sigprocmask1(l, SIG_BLOCK, &ss, 0); |
412 | mutex_exit(p->p_lock); | | 412 | mutex_exit(p->p_lock); |
413 | return error; | | 413 | return error; |
414 | | | 414 | |
415 | case SVR4_SIGRELSE_MASK: | | 415 | case SVR4_SIGRELSE_MASK: |
416 | sigemptyset(&ss); | | 416 | sigemptyset(&ss); |
417 | sigaddset(&ss, signum); | | 417 | sigaddset(&ss, native_signo); |
418 | mutex_enter(p->p_lock); | | 418 | mutex_enter(p->p_lock); |
419 | error = sigprocmask1(l, SIG_UNBLOCK, &ss, 0); | | 419 | error = sigprocmask1(l, SIG_UNBLOCK, &ss, 0); |
420 | mutex_exit(p->p_lock); | | 420 | mutex_exit(p->p_lock); |
421 | return error; | | 421 | return error; |
422 | | | 422 | |
423 | case SVR4_SIGIGNORE_MASK: | | 423 | case SVR4_SIGIGNORE_MASK: |
424 | nbsa.sa_handler = SIG_IGN; | | 424 | nbsa.sa_handler = SIG_IGN; |
425 | sigemptyset(&nbsa.sa_mask); | | 425 | sigemptyset(&nbsa.sa_mask); |
426 | nbsa.sa_flags = 0; | | 426 | nbsa.sa_flags = 0; |
427 | return (sigaction1(l, signum, &nbsa, 0, NULL, 0)); | | 427 | return sigaction1(l, native_signo, &nbsa, 0, NULL, 0); |
428 | | | 428 | |
429 | case SVR4_SIGPAUSE_MASK: | | 429 | case SVR4_SIGPAUSE_MASK: |
430 | mutex_enter(p->p_lock); | | 430 | mutex_enter(p->p_lock); |
431 | ss = l->l_sigmask; | | 431 | ss = l->l_sigmask; |
432 | mutex_exit(p->p_lock); | | 432 | mutex_exit(p->p_lock); |
433 | sigdelset(&ss, signum); | | 433 | sigdelset(&ss, native_signo); |
434 | return (sigsuspend1(l, &ss)); | | 434 | return sigsuspend1(l, &ss); |
435 | | | 435 | |
436 | default: | | 436 | default: |
437 | return (ENOSYS); | | 437 | return ENOSYS; |
438 | } | | 438 | } |
439 | } | | 439 | } |
440 | | | 440 | |
441 | int | | 441 | int |
442 | svr4_32_sys_sigprocmask(struct lwp *l, const struct svr4_32_sys_sigprocmask_args *uap, register_t *retval) | | 442 | svr4_32_sys_sigprocmask(struct lwp *l, const struct svr4_32_sys_sigprocmask_args *uap, register_t *retval) |
443 | { | | 443 | { |
444 | /* { | | 444 | /* { |
445 | syscallarg(int) how; | | 445 | syscallarg(int) how; |
446 | syscallarg(const svr4_32_sigset_t *) set; | | 446 | syscallarg(const svr4_32_sigset_t *) set; |
447 | syscallarg(svr4_32_sigset_t *) oset; | | 447 | syscallarg(svr4_32_sigset_t *) oset; |
448 | } */ | | 448 | } */ |
449 | struct proc *p = l->l_proc; | | 449 | struct proc *p = l->l_proc; |
450 | svr4_32_sigset_t nsss, osss; | | 450 | svr4_32_sigset_t nsss, osss; |
451 | sigset_t nbss, obss; | | 451 | sigset_t nbss, obss; |
452 | int how; | | 452 | int how; |
453 | int error; | | 453 | int error; |
454 | | | 454 | |
455 | /* | | 455 | /* |
456 | * Initialize how to 0 to avoid a compiler warning. Note that | | 456 | * Initialize how to 0 to avoid a compiler warning. Note that |
457 | * this is safe because of the check in the default: case. | | 457 | * this is safe because of the check in the default: case. |
458 | */ | | 458 | */ |
459 | how = 0; | | 459 | how = 0; |
460 | | | 460 | |
461 | switch (SCARG(uap, how)) { | | 461 | switch (SCARG(uap, how)) { |
462 | case SVR4_SIG_BLOCK: | | 462 | case SVR4_SIG_BLOCK: |
463 | how = SIG_BLOCK; | | 463 | how = SIG_BLOCK; |
464 | break; | | 464 | break; |
465 | case SVR4_SIG_UNBLOCK: | | 465 | case SVR4_SIG_UNBLOCK: |
466 | how = SIG_UNBLOCK; | | 466 | how = SIG_UNBLOCK; |
467 | break; | | 467 | break; |
468 | case SVR4_SIG_SETMASK: | | 468 | case SVR4_SIG_SETMASK: |
469 | how = SIG_SETMASK; | | 469 | how = SIG_SETMASK; |
470 | break; | | 470 | break; |
471 | default: | | 471 | default: |
472 | if (SCARG_P32(uap, set)) | | 472 | if (SCARG_P32(uap, set)) |
473 | return EINVAL; | | 473 | return EINVAL; |
474 | break; | | 474 | break; |
475 | } | | 475 | } |
476 | | | 476 | |
477 | if (SCARG_P32(uap, set)) { | | 477 | if (SCARG_P32(uap, set)) { |
478 | error = copyin(SCARG_P32(uap, set), | | 478 | error = copyin(SCARG_P32(uap, set), |
479 | &nsss, sizeof(nsss)); | | 479 | &nsss, sizeof(nsss)); |
480 | if (error) | | 480 | if (error) |
481 | return error; | | 481 | return error; |
482 | svr4_32_to_native_sigset(&nsss, &nbss); | | 482 | svr4_32_to_native_sigset(&nsss, &nbss); |
483 | } | | 483 | } |
484 | mutex_enter(p->p_lock); | | 484 | mutex_enter(p->p_lock); |
485 | error = sigprocmask1(l, how, | | 485 | error = sigprocmask1(l, how, |
486 | SCARG_P32(uap, set) ? &nbss : NULL, SCARG_P32(uap, oset) ? &obss : NULL); | | 486 | SCARG_P32(uap, set) ? &nbss : NULL, SCARG_P32(uap, oset) ? &obss : NULL); |
487 | mutex_exit(p->p_lock); | | 487 | mutex_exit(p->p_lock); |
488 | if (error) | | 488 | if (error) |
489 | return error; | | 489 | return error; |
490 | if (SCARG_P32(uap, oset)) { | | 490 | if (SCARG_P32(uap, oset)) { |
491 | native_to_svr4_32_sigset(&obss, &osss); | | 491 | native_to_svr4_32_sigset(&obss, &osss); |
492 | error = copyout(&osss, SCARG_P32(uap, oset), | | 492 | error = copyout(&osss, SCARG_P32(uap, oset), |
493 | sizeof(osss)); | | 493 | sizeof(osss)); |
494 | if (error) | | 494 | if (error) |
495 | return error; | | 495 | return error; |
496 | } | | 496 | } |
497 | return 0; | | 497 | return 0; |
498 | } | | 498 | } |
499 | | | 499 | |
500 | int | | 500 | int |
501 | svr4_32_sys_sigpending(struct lwp *l, const struct svr4_32_sys_sigpending_args *uap, register_t *retval) | | 501 | svr4_32_sys_sigpending(struct lwp *l, const struct svr4_32_sys_sigpending_args *uap, register_t *retval) |
502 | { | | 502 | { |
503 | /* { | | 503 | /* { |
504 | syscallarg(int) what; | | 504 | syscallarg(int) what; |
505 | syscallarg(svr4_sigset_t *) set; | | 505 | syscallarg(svr4_sigset_t *) set; |
506 | } */ | | 506 | } */ |
507 | sigset_t bss; | | 507 | sigset_t bss; |
508 | svr4_32_sigset_t sss; | | 508 | svr4_32_sigset_t sss; |
509 | | | 509 | |
510 | switch (SCARG(uap, what)) { | | 510 | switch (SCARG(uap, what)) { |
511 | case 1: /* sigpending */ | | 511 | case 1: /* sigpending */ |
512 | sigpending1(l, &bss); | | 512 | sigpending1(l, &bss); |
513 | native_to_svr4_32_sigset(&bss, &sss); | | 513 | native_to_svr4_32_sigset(&bss, &sss); |
514 | break; | | 514 | break; |
515 | | | 515 | |
516 | case 2: /* sigfillset */ | | 516 | case 2: /* sigfillset */ |
517 | svr4_32_sigfillset(&sss); | | 517 | svr4_32_sigfillset(&sss); |
518 | break; | | 518 | break; |
519 | | | 519 | |
520 | default: | | 520 | default: |
521 | return (EINVAL); | | 521 | return (EINVAL); |
522 | } | | 522 | } |
523 | return (copyout(&sss, SCARG_P32(uap, set), sizeof(sss))); | | 523 | return (copyout(&sss, SCARG_P32(uap, set), sizeof(sss))); |
524 | } | | 524 | } |
525 | | | 525 | |
526 | int | | 526 | int |
527 | svr4_32_sys_sigsuspend(struct lwp *l, const struct svr4_32_sys_sigsuspend_args *uap, register_t *retval) | | 527 | svr4_32_sys_sigsuspend(struct lwp *l, const struct svr4_32_sys_sigsuspend_args *uap, register_t *retval) |
528 | { | | 528 | { |
529 | /* { | | 529 | /* { |
530 | syscallarg(const svr4_32_sigset_t *) set; | | 530 | syscallarg(const svr4_32_sigset_t *) set; |
531 | } */ | | 531 | } */ |
532 | svr4_32_sigset_t sss; | | 532 | svr4_32_sigset_t sss; |
533 | sigset_t bss; | | 533 | sigset_t bss; |
534 | int error; | | 534 | int error; |
535 | | | 535 | |
536 | if (SCARG_P32(uap, set)) { | | 536 | if (SCARG_P32(uap, set)) { |
537 | error = copyin(SCARG_P32(uap, set), &sss, sizeof(sss)); | | 537 | error = copyin(SCARG_P32(uap, set), &sss, sizeof(sss)); |
538 | if (error) | | 538 | if (error) |
539 | return (error); | | 539 | return (error); |
540 | svr4_32_to_native_sigset(&sss, &bss); | | 540 | svr4_32_to_native_sigset(&sss, &bss); |
541 | } | | 541 | } |
542 | | | 542 | |
543 | return (sigsuspend1(l, SCARG_P32(uap, set) ? &bss : 0)); | | 543 | return (sigsuspend1(l, SCARG_P32(uap, set) ? &bss : 0)); |
544 | } | | 544 | } |
545 | | | 545 | |
546 | int | | 546 | int |
547 | svr4_32_sys_pause(struct lwp *l, const void *v, register_t *retval) | | 547 | svr4_32_sys_pause(struct lwp *l, const void *v, register_t *retval) |
548 | { | | 548 | { |
549 | | | 549 | |
550 | return (sigsuspend1(l, 0)); | | 550 | return (sigsuspend1(l, 0)); |
551 | } | | 551 | } |
552 | | | 552 | |
553 | int | | 553 | int |
554 | svr4_32_sys_kill(struct lwp *l, const struct svr4_32_sys_kill_args *uap, register_t *retval) | | 554 | svr4_32_sys_kill(struct lwp *l, const struct svr4_32_sys_kill_args *uap, register_t *retval) |
555 | { | | 555 | { |
556 | /* { | | 556 | /* { |
557 | syscallarg(int) pid; | | 557 | syscallarg(int) pid; |
558 | syscallarg(int) signum; | | 558 | syscallarg(int) signum; |
559 | } */ | | 559 | } */ |
560 | struct sys_kill_args ka; | | 560 | struct sys_kill_args ka; |
561 | int native_signo; | | 561 | int native_signo; |
562 | int error; | | 562 | int error; |
563 | | | 563 | |
564 | error = svr4_32_decode_signum(SCARG(uap, signum), &native_signo, NULL); | | 564 | error = svr4_32_decode_signum(SCARG(uap, signum), &native_signo, NULL); |
565 | if (error) | | 565 | if (error) |
566 | return error; | | 566 | return error; |
567 | | | 567 | |
568 | SCARG(&ka, pid) = SCARG(uap, pid); | | 568 | SCARG(&ka, pid) = SCARG(uap, pid); |
569 | SCARG(&ka, signum) = native_signo; | | 569 | SCARG(&ka, signum) = native_signo; |
570 | return sys_kill(l, &ka, retval); | | 570 | return sys_kill(l, &ka, retval); |
571 | } | | 571 | } |
572 | | | 572 | |
573 | void | | 573 | void |
574 | svr4_32_getcontext(struct lwp *l, struct svr4_32_ucontext *uc, const sigset_t *mask) | | 574 | svr4_32_getcontext(struct lwp *l, struct svr4_32_ucontext *uc, const sigset_t *mask) |
575 | { | | 575 | { |
576 | void *sp; | | 576 | void *sp; |
577 | struct svr4_32_sigaltstack *ss = &uc->uc_stack; | | 577 | struct svr4_32_sigaltstack *ss = &uc->uc_stack; |
578 | | | 578 | |
579 | memset(uc, 0, sizeof(*uc)); | | 579 | memset(uc, 0, sizeof(*uc)); |
580 | | | 580 | |
581 | /* get machine context */ | | 581 | /* get machine context */ |
582 | sp = svr4_32_getmcontext(l, &uc->uc_mcontext, &uc->uc_flags); | | 582 | sp = svr4_32_getmcontext(l, &uc->uc_mcontext, &uc->uc_flags); |
583 | | | 583 | |
584 | /* get link */ | | 584 | /* get link */ |
585 | NETBSD32PTR32(uc->uc_link, l->l_ctxlink); | | 585 | NETBSD32PTR32(uc->uc_link, l->l_ctxlink); |
586 | | | 586 | |
587 | /* get stack state. XXX: solaris appears to do this */ | | 587 | /* get stack state. XXX: solaris appears to do this */ |
588 | #if 0 | | 588 | #if 0 |
589 | svr4_32_to_native_sigaltstack(&uc->uc_stack, &p->p_sigacts->ps_sigstk); | | 589 | svr4_32_to_native_sigaltstack(&uc->uc_stack, &p->p_sigacts->ps_sigstk); |
590 | #else | | 590 | #else |
591 | NETBSD32PTR32(ss->ss_sp, (void *)(((u_long) sp) & ~(16384 - 1))); | | 591 | NETBSD32PTR32(ss->ss_sp, (void *)(((u_long) sp) & ~(16384 - 1))); |
592 | ss->ss_size = 16384; | | 592 | ss->ss_size = 16384; |
593 | ss->ss_flags = 0; | | 593 | ss->ss_flags = 0; |
594 | #endif | | 594 | #endif |
595 | /* get signal mask */ | | 595 | /* get signal mask */ |
596 | mutex_enter(l->l_proc->p_lock); | | 596 | mutex_enter(l->l_proc->p_lock); |
597 | native_to_svr4_32_sigset(mask, &uc->uc_sigmask); | | 597 | native_to_svr4_32_sigset(mask, &uc->uc_sigmask); |
598 | mutex_exit(l->l_proc->p_lock); | | 598 | mutex_exit(l->l_proc->p_lock); |
599 | | | 599 | |
600 | uc->uc_flags |= SVR4_UC_STACK|SVR4_UC_SIGMASK; | | 600 | uc->uc_flags |= SVR4_UC_STACK|SVR4_UC_SIGMASK; |
601 | } | | 601 | } |
602 | | | 602 | |
603 | | | 603 | |
604 | int | | 604 | int |
605 | svr4_32_setcontext(struct lwp *l, struct svr4_32_ucontext *uc) | | 605 | svr4_32_setcontext(struct lwp *l, struct svr4_32_ucontext *uc) |
606 | { | | 606 | { |
607 | int error; | | 607 | int error; |
608 | struct proc *p = l->l_proc; | | 608 | struct proc *p = l->l_proc; |
609 | | | 609 | |
610 | /* set machine context */ | | 610 | /* set machine context */ |
611 | if ((error = svr4_32_setmcontext(l, &uc->uc_mcontext, uc->uc_flags)) != 0) | | 611 | if ((error = svr4_32_setmcontext(l, &uc->uc_mcontext, uc->uc_flags)) != 0) |
612 | return error; | | 612 | return error; |
613 | | | 613 | |
614 | /* set link */ | | 614 | /* set link */ |
615 | l->l_ctxlink = NETBSD32PTR64(uc->uc_link); | | 615 | l->l_ctxlink = NETBSD32PTR64(uc->uc_link); |
616 | | | 616 | |
617 | mutex_enter(p->p_lock); | | 617 | mutex_enter(p->p_lock); |
618 | | | 618 | |
619 | /* set signal stack */ | | 619 | /* set signal stack */ |
620 | if (uc->uc_flags & SVR4_UC_STACK) { | | 620 | if (uc->uc_flags & SVR4_UC_STACK) { |
621 | l->l_sigstk.ss_sp = NETBSD32PTR64(uc->uc_stack.ss_sp); | | 621 | l->l_sigstk.ss_sp = NETBSD32PTR64(uc->uc_stack.ss_sp); |
622 | l->l_sigstk.ss_size = uc->uc_stack.ss_size; | | 622 | l->l_sigstk.ss_size = uc->uc_stack.ss_size; |
623 | l->l_sigstk.ss_flags = | | 623 | l->l_sigstk.ss_flags = |
624 | (uc->uc_stack.ss_flags & SVR4_SS_ONSTACK ? SS_ONSTACK : 0) | | | 624 | (uc->uc_stack.ss_flags & SVR4_SS_ONSTACK ? SS_ONSTACK : 0) | |
625 | (uc->uc_stack.ss_flags & SVR4_SS_DISABLE ? SS_DISABLE : 0); | | 625 | (uc->uc_stack.ss_flags & SVR4_SS_DISABLE ? SS_DISABLE : 0); |
626 | } | | 626 | } |
627 | | | 627 | |
628 | /* set signal mask */ | | 628 | /* set signal mask */ |
629 | if (uc->uc_flags & SVR4_UC_SIGMASK) { | | 629 | if (uc->uc_flags & SVR4_UC_SIGMASK) { |
630 | sigset_t mask; | | 630 | sigset_t mask; |
631 | | | 631 | |
632 | svr4_32_to_native_sigset(&uc->uc_sigmask, &mask); | | 632 | svr4_32_to_native_sigset(&uc->uc_sigmask, &mask); |
633 | (void)sigprocmask1(l, SIG_SETMASK, &mask, 0); | | 633 | (void)sigprocmask1(l, SIG_SETMASK, &mask, 0); |
634 | } | | 634 | } |
635 | | | 635 | |
636 | mutex_exit(p->p_lock); | | 636 | mutex_exit(p->p_lock); |
637 | | | 637 | |
638 | return EJUSTRETURN; | | 638 | return EJUSTRETURN; |
639 | } | | 639 | } |
640 | | | 640 | |
641 | int | | 641 | int |
642 | svr4_32_sys_context(struct lwp *l, const struct svr4_32_sys_context_args *uap, register_t *retval) | | 642 | svr4_32_sys_context(struct lwp *l, const struct svr4_32_sys_context_args *uap, register_t *retval) |
643 | { | | 643 | { |
644 | /* { | | 644 | /* { |
645 | syscallarg(int) func; | | 645 | syscallarg(int) func; |
646 | syscallarg(struct svr4_32_ucontext *) uc; | | 646 | syscallarg(struct svr4_32_ucontext *) uc; |
647 | } */ | | 647 | } */ |
648 | struct svr4_32_ucontext uc; | | 648 | struct svr4_32_ucontext uc; |
649 | int error; | | 649 | int error; |
650 | *retval = 0; | | 650 | *retval = 0; |
651 | | | 651 | |
652 | switch (SCARG(uap, func)) { | | 652 | switch (SCARG(uap, func)) { |
653 | case SVR4_GETCONTEXT: | | 653 | case SVR4_GETCONTEXT: |
654 | DPRINTF(("getcontext(%p)\n", SCARG(uap, uc))); | | 654 | DPRINTF(("getcontext(%p)\n", SCARG(uap, uc))); |
655 | svr4_32_getcontext(l, &uc, &l->l_sigmask); | | 655 | svr4_32_getcontext(l, &uc, &l->l_sigmask); |
656 | return copyout(&uc, SCARG_P32(uap, uc), sizeof(uc)); | | 656 | return copyout(&uc, SCARG_P32(uap, uc), sizeof(uc)); |
657 | | | 657 | |
658 | case SVR4_SETCONTEXT: | | 658 | case SVR4_SETCONTEXT: |
659 | DPRINTF(("setcontext(%p)\n", SCARG(uap, uc))); | | 659 | DPRINTF(("setcontext(%p)\n", SCARG(uap, uc))); |
660 | if (!SCARG_P32(uap, uc)) | | 660 | if (!SCARG_P32(uap, uc)) |
661 | exit1(l, W_EXITCODE(0, 0)); | | 661 | exit1(l, W_EXITCODE(0, 0)); |
662 | else if ((error = copyin(SCARG_P32(uap, uc), | | 662 | else if ((error = copyin(SCARG_P32(uap, uc), |
663 | &uc, sizeof(uc))) != 0) | | 663 | &uc, sizeof(uc))) != 0) |
664 | return error; | | 664 | return error; |
665 | else | | 665 | else |
666 | return svr4_32_setcontext(l, &uc); | | 666 | return svr4_32_setcontext(l, &uc); |
667 | | | 667 | |
668 | default: | | 668 | default: |
669 | DPRINTF(("context(%d, %p)\n", SCARG(uap, func), | | 669 | DPRINTF(("context(%d, %p)\n", SCARG(uap, func), |
670 | SCARG(uap, uc))); | | 670 | SCARG(uap, uc))); |
671 | return ENOSYS; | | 671 | return ENOSYS; |
672 | } | | 672 | } |
673 | return 0; | | 673 | return 0; |
674 | } | | 674 | } |