netbsd32_signal.c revision 1.21.6.2 1 1.21.6.2 reinoud /* $NetBSD: netbsd32_signal.c,v 1.21.6.2 2007/03/29 19:27:42 reinoud Exp $ */
2 1.1 mrg
3 1.1 mrg /*
4 1.1 mrg * Copyright (c) 1998, 2001 Matthew R. Green
5 1.1 mrg * All rights reserved.
6 1.1 mrg *
7 1.1 mrg * Redistribution and use in source and binary forms, with or without
8 1.1 mrg * modification, are permitted provided that the following conditions
9 1.1 mrg * are met:
10 1.1 mrg * 1. Redistributions of source code must retain the above copyright
11 1.1 mrg * notice, this list of conditions and the following disclaimer.
12 1.1 mrg * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 mrg * notice, this list of conditions and the following disclaimer in the
14 1.1 mrg * documentation and/or other materials provided with the distribution.
15 1.1 mrg * 3. The name of the author may not be used to endorse or promote products
16 1.1 mrg * derived from this software without specific prior written permission.
17 1.1 mrg *
18 1.1 mrg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 1.1 mrg * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.1 mrg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.1 mrg * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 1.1 mrg * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 1.1 mrg * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 1.1 mrg * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 1.1 mrg * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 1.1 mrg * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 1.1 mrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 1.1 mrg * SUCH DAMAGE.
29 1.1 mrg */
30 1.2 lukem
31 1.2 lukem #include <sys/cdefs.h>
32 1.21.6.2 reinoud __KERNEL_RCSID(0, "$NetBSD: netbsd32_signal.c,v 1.21.6.2 2007/03/29 19:27:42 reinoud Exp $");
33 1.1 mrg
34 1.1 mrg #include <sys/param.h>
35 1.1 mrg #include <sys/systm.h>
36 1.1 mrg #include <sys/malloc.h>
37 1.1 mrg #include <sys/mount.h>
38 1.1 mrg #include <sys/stat.h>
39 1.1 mrg #include <sys/time.h>
40 1.1 mrg #include <sys/signalvar.h>
41 1.1 mrg #include <sys/proc.h>
42 1.7 fvdl #include <sys/wait.h>
43 1.11 christos #include <sys/dirent.h>
44 1.7 fvdl
45 1.7 fvdl #include <uvm/uvm_extern.h>
46 1.1 mrg
47 1.1 mrg #include <compat/netbsd32/netbsd32.h>
48 1.10 cube #include <compat/netbsd32/netbsd32_conv.h>
49 1.1 mrg #include <compat/netbsd32/netbsd32_syscallargs.h>
50 1.1 mrg
51 1.12 christos #include <compat/sys/signal.h>
52 1.12 christos #include <compat/sys/signalvar.h>
53 1.13 christos #include <compat/sys/siginfo.h>
54 1.12 christos #include <compat/sys/ucontext.h>
55 1.12 christos
56 1.14 christos #ifdef unused
57 1.14 christos static void netbsd32_si32_to_si(siginfo_t *, const siginfo32_t *);
58 1.14 christos #endif
59 1.14 christos
60 1.14 christos
61 1.1 mrg int
62 1.6 thorpej netbsd32_sigaction(l, v, retval)
63 1.6 thorpej struct lwp *l;
64 1.1 mrg void *v;
65 1.1 mrg register_t *retval;
66 1.1 mrg {
67 1.1 mrg struct netbsd32_sigaction_args /* {
68 1.1 mrg syscallarg(int) signum;
69 1.1 mrg syscallarg(const netbsd32_sigactionp_t) nsa;
70 1.1 mrg syscallarg(netbsd32_sigactionp_t) osa;
71 1.1 mrg } */ *uap = v;
72 1.1 mrg struct sigaction nsa, osa;
73 1.1 mrg struct netbsd32_sigaction *sa32p, sa32;
74 1.1 mrg int error;
75 1.1 mrg
76 1.21.6.2 reinoud if (SCARG_P32(uap, nsa)) {
77 1.21.6.2 reinoud sa32p = SCARG_P32(uap, nsa);
78 1.1 mrg if (copyin(sa32p, &sa32, sizeof(sa32)))
79 1.1 mrg return EFAULT;
80 1.5 atatat nsa.sa_handler = (void *)NETBSD32PTR64(sa32.netbsd32_sa_handler);
81 1.5 atatat nsa.sa_mask = sa32.netbsd32_sa_mask;
82 1.5 atatat nsa.sa_flags = sa32.netbsd32_sa_flags;
83 1.1 mrg }
84 1.19 ad error = sigaction1(l, SCARG(uap, signum),
85 1.21.6.2 reinoud SCARG_P32(uap, nsa) ? &nsa : 0,
86 1.21.6.2 reinoud SCARG_P32(uap, osa) ? &osa : 0,
87 1.3 thorpej NULL, 0);
88 1.8 perry
89 1.1 mrg if (error)
90 1.1 mrg return (error);
91 1.1 mrg
92 1.21.6.2 reinoud if (SCARG_P32(uap, osa)) {
93 1.21.6.1 reinoud NETBSD32PTR32(sa32.netbsd32_sa_handler, osa.sa_handler);
94 1.5 atatat sa32.netbsd32_sa_mask = osa.sa_mask;
95 1.5 atatat sa32.netbsd32_sa_flags = osa.sa_flags;
96 1.21.6.2 reinoud sa32p = SCARG_P32(uap, osa);
97 1.1 mrg if (copyout(&sa32, sa32p, sizeof(sa32)))
98 1.1 mrg return EFAULT;
99 1.1 mrg }
100 1.1 mrg
101 1.1 mrg return (0);
102 1.1 mrg }
103 1.1 mrg
104 1.1 mrg int
105 1.6 thorpej netbsd32___sigaltstack14(l, v, retval)
106 1.6 thorpej struct lwp *l;
107 1.1 mrg void *v;
108 1.1 mrg register_t *retval;
109 1.1 mrg {
110 1.1 mrg struct netbsd32___sigaltstack14_args /* {
111 1.1 mrg syscallarg(const netbsd32_sigaltstackp_t) nss;
112 1.1 mrg syscallarg(netbsd32_sigaltstackp_t) oss;
113 1.1 mrg } */ *uap = v;
114 1.1 mrg struct netbsd32_sigaltstack s32;
115 1.1 mrg struct sigaltstack nss, oss;
116 1.1 mrg int error;
117 1.1 mrg
118 1.21.6.2 reinoud if (SCARG_P32(uap, nss)) {
119 1.21.6.2 reinoud error = copyin(SCARG_P32(uap, nss), &s32, sizeof(s32));
120 1.1 mrg if (error)
121 1.1 mrg return (error);
122 1.21.6.1 reinoud nss.ss_sp = NETBSD32PTR64(s32.ss_sp);
123 1.1 mrg nss.ss_size = (size_t)s32.ss_size;
124 1.1 mrg nss.ss_flags = s32.ss_flags;
125 1.1 mrg }
126 1.21.6.2 reinoud error = sigaltstack1(l, SCARG_P32(uap, nss) ? &nss : 0,
127 1.21.6.2 reinoud SCARG_P32(uap, oss) ? &oss : 0);
128 1.1 mrg if (error)
129 1.1 mrg return (error);
130 1.21.6.2 reinoud if (SCARG_P32(uap, oss)) {
131 1.21.6.1 reinoud NETBSD32PTR32(s32.ss_sp, oss.ss_sp);
132 1.1 mrg s32.ss_size = (netbsd32_size_t)oss.ss_size;
133 1.1 mrg s32.ss_flags = oss.ss_flags;
134 1.21.6.2 reinoud error = copyout(&s32, SCARG_P32(uap, oss), sizeof(s32));
135 1.1 mrg if (error)
136 1.1 mrg return (error);
137 1.1 mrg }
138 1.1 mrg return (0);
139 1.1 mrg }
140 1.1 mrg
141 1.1 mrg /* ARGSUSED */
142 1.1 mrg int
143 1.6 thorpej netbsd32___sigaction14(l, v, retval)
144 1.6 thorpej struct lwp *l;
145 1.1 mrg void *v;
146 1.1 mrg register_t *retval;
147 1.1 mrg {
148 1.1 mrg struct netbsd32___sigaction14_args /* {
149 1.1 mrg syscallarg(int) signum;
150 1.1 mrg syscallarg(const struct sigaction *) nsa;
151 1.1 mrg syscallarg(struct sigaction *) osa;
152 1.1 mrg } */ *uap = v;
153 1.1 mrg struct netbsd32_sigaction sa32;
154 1.1 mrg struct sigaction nsa, osa;
155 1.1 mrg int error;
156 1.1 mrg
157 1.21.6.2 reinoud if (SCARG_P32(uap, nsa)) {
158 1.21.6.2 reinoud error = copyin(SCARG_P32(uap, nsa), &sa32, sizeof(sa32));
159 1.1 mrg if (error)
160 1.1 mrg return (error);
161 1.21.6.1 reinoud nsa.sa_handler = NETBSD32PTR64(sa32.netbsd32_sa_handler);
162 1.5 atatat nsa.sa_mask = sa32.netbsd32_sa_mask;
163 1.5 atatat nsa.sa_flags = sa32.netbsd32_sa_flags;
164 1.1 mrg }
165 1.19 ad error = sigaction1(l, SCARG(uap, signum),
166 1.21.6.2 reinoud SCARG_P32(uap, nsa) ? &nsa : 0,
167 1.21.6.2 reinoud SCARG_P32(uap, osa) ? &osa : 0,
168 1.21.6.1 reinoud NULL, 0);
169 1.1 mrg if (error)
170 1.1 mrg return (error);
171 1.21.6.2 reinoud if (SCARG_P32(uap, osa)) {
172 1.21.6.1 reinoud NETBSD32PTR32(sa32.netbsd32_sa_handler, osa.sa_handler);
173 1.5 atatat sa32.netbsd32_sa_mask = osa.sa_mask;
174 1.5 atatat sa32.netbsd32_sa_flags = osa.sa_flags;
175 1.21.6.2 reinoud error = copyout(&sa32, SCARG_P32(uap, osa), sizeof(sa32));
176 1.4 scw if (error)
177 1.4 scw return (error);
178 1.4 scw }
179 1.4 scw return (0);
180 1.4 scw }
181 1.4 scw
182 1.4 scw /* ARGSUSED */
183 1.4 scw int
184 1.6 thorpej netbsd32___sigaction_sigtramp(l, v, retval)
185 1.6 thorpej struct lwp *l;
186 1.4 scw void *v;
187 1.4 scw register_t *retval;
188 1.4 scw {
189 1.4 scw struct netbsd32___sigaction_sigtramp_args /* {
190 1.4 scw syscallarg(int) signum;
191 1.4 scw syscallarg(const netbsd32_sigactionp_t) nsa;
192 1.4 scw syscallarg(netbsd32_sigactionp_t) osa;
193 1.4 scw syscallarg(netbsd32_voidp) tramp;
194 1.4 scw syscallarg(int) vers;
195 1.4 scw } */ *uap = v;
196 1.4 scw struct netbsd32_sigaction sa32;
197 1.4 scw struct sigaction nsa, osa;
198 1.4 scw int error;
199 1.4 scw
200 1.21.6.2 reinoud if (SCARG_P32(uap, nsa)) {
201 1.21.6.2 reinoud error = copyin(SCARG_P32(uap, nsa), &sa32, sizeof(sa32));
202 1.4 scw if (error)
203 1.4 scw return (error);
204 1.21.6.1 reinoud nsa.sa_handler = NETBSD32PTR64(sa32.netbsd32_sa_handler);
205 1.5 atatat nsa.sa_mask = sa32.netbsd32_sa_mask;
206 1.5 atatat nsa.sa_flags = sa32.netbsd32_sa_flags;
207 1.4 scw }
208 1.19 ad error = sigaction1(l, SCARG(uap, signum),
209 1.21.6.2 reinoud SCARG_P32(uap, nsa) ? &nsa : 0,
210 1.21.6.2 reinoud SCARG_P32(uap, osa) ? &osa : 0,
211 1.21.6.2 reinoud SCARG_P32(uap, tramp), SCARG(uap, vers));
212 1.4 scw if (error)
213 1.4 scw return (error);
214 1.21.6.2 reinoud if (SCARG_P32(uap, osa)) {
215 1.21.6.1 reinoud NETBSD32PTR32(sa32.netbsd32_sa_handler, osa.sa_handler);
216 1.5 atatat sa32.netbsd32_sa_mask = osa.sa_mask;
217 1.5 atatat sa32.netbsd32_sa_flags = osa.sa_flags;
218 1.21.6.2 reinoud error = copyout(&sa32, SCARG_P32(uap, osa), sizeof(sa32));
219 1.1 mrg if (error)
220 1.1 mrg return (error);
221 1.1 mrg }
222 1.1 mrg return (0);
223 1.7 fvdl }
224 1.7 fvdl
225 1.14 christos #ifdef unused
226 1.14 christos static void
227 1.9 drochner netbsd32_si32_to_si(siginfo_t *si, const siginfo32_t *si32)
228 1.7 fvdl {
229 1.7 fvdl memset(si, 0, sizeof (*si));
230 1.7 fvdl si->si_signo = si32->si_signo;
231 1.7 fvdl si->si_code = si32->si_code;
232 1.7 fvdl si->si_errno = si32->si_errno;
233 1.7 fvdl
234 1.7 fvdl switch (si32->si_signo) {
235 1.7 fvdl case SIGILL:
236 1.7 fvdl case SIGBUS:
237 1.7 fvdl case SIGSEGV:
238 1.7 fvdl case SIGFPE:
239 1.7 fvdl case SIGTRAP:
240 1.21.6.1 reinoud si->si_addr = NETBSD32PTR64(si32->si_addr);
241 1.7 fvdl si->si_trap = si32->si_trap;
242 1.7 fvdl break;
243 1.7 fvdl case SIGALRM:
244 1.7 fvdl case SIGVTALRM:
245 1.7 fvdl case SIGPROF:
246 1.7 fvdl si->si_pid = si32->si_pid;
247 1.7 fvdl si->si_uid = si32->si_uid;
248 1.7 fvdl /*
249 1.7 fvdl * XXX sival_ptr is currently unused.
250 1.7 fvdl */
251 1.7 fvdl si->si_sigval.sival_int = si32->si_sigval.sival_int;
252 1.7 fvdl break;
253 1.7 fvdl case SIGCHLD:
254 1.7 fvdl si->si_pid = si32->si_pid;
255 1.7 fvdl si->si_uid = si32->si_uid;
256 1.7 fvdl si->si_utime = si32->si_utime;
257 1.7 fvdl si->si_stime = si32->si_stime;
258 1.7 fvdl break;
259 1.7 fvdl case SIGURG:
260 1.7 fvdl case SIGIO:
261 1.7 fvdl si->si_band = si32->si_band;
262 1.7 fvdl si->si_fd = si32->si_fd;
263 1.7 fvdl break;
264 1.7 fvdl }
265 1.7 fvdl }
266 1.14 christos #endif
267 1.7 fvdl
268 1.15 chs void
269 1.9 drochner netbsd32_si_to_si32(siginfo32_t *si32, const siginfo_t *si)
270 1.7 fvdl {
271 1.7 fvdl memset(si32, 0, sizeof (*si32));
272 1.7 fvdl si32->si_signo = si->si_signo;
273 1.7 fvdl si32->si_code = si->si_code;
274 1.7 fvdl si32->si_errno = si->si_errno;
275 1.7 fvdl
276 1.7 fvdl switch (si32->si_signo) {
277 1.17 cube case 0: /* SA */
278 1.17 cube si32->si_sigval.sival_int = si->si_sigval.sival_int;
279 1.17 cube break;
280 1.7 fvdl case SIGILL:
281 1.7 fvdl case SIGBUS:
282 1.7 fvdl case SIGSEGV:
283 1.7 fvdl case SIGFPE:
284 1.7 fvdl case SIGTRAP:
285 1.7 fvdl si32->si_addr = (uint32_t)(uintptr_t)si->si_addr;
286 1.7 fvdl si32->si_trap = si->si_trap;
287 1.7 fvdl break;
288 1.7 fvdl case SIGALRM:
289 1.7 fvdl case SIGVTALRM:
290 1.7 fvdl case SIGPROF:
291 1.7 fvdl si32->si_pid = si->si_pid;
292 1.7 fvdl si32->si_uid = si->si_uid;
293 1.7 fvdl /*
294 1.7 fvdl * XXX sival_ptr is currently unused.
295 1.7 fvdl */
296 1.7 fvdl si32->si_sigval.sival_int = si->si_sigval.sival_int;
297 1.7 fvdl break;
298 1.7 fvdl case SIGCHLD:
299 1.7 fvdl si32->si_pid = si->si_pid;
300 1.7 fvdl si32->si_uid = si->si_uid;
301 1.7 fvdl si32->si_status = si->si_status;
302 1.7 fvdl si32->si_utime = si->si_utime;
303 1.7 fvdl si32->si_stime = si->si_stime;
304 1.7 fvdl break;
305 1.7 fvdl case SIGURG:
306 1.7 fvdl case SIGIO:
307 1.7 fvdl si32->si_band = si->si_band;
308 1.7 fvdl si32->si_fd = si->si_fd;
309 1.7 fvdl break;
310 1.7 fvdl }
311 1.7 fvdl }
312 1.7 fvdl
313 1.7 fvdl void
314 1.7 fvdl getucontext32(struct lwp *l, ucontext32_t *ucp)
315 1.7 fvdl {
316 1.20 cube struct proc *p = l->l_proc;
317 1.7 fvdl
318 1.20 cube LOCK_ASSERT(mutex_owned(&p->p_smutex));
319 1.7 fvdl
320 1.7 fvdl ucp->uc_flags = 0;
321 1.7 fvdl ucp->uc_link = (uint32_t)(intptr_t)l->l_ctxlink;
322 1.7 fvdl
323 1.20 cube ucp->uc_sigmask = l->l_sigmask;
324 1.7 fvdl ucp->uc_flags |= _UC_SIGMASK;
325 1.7 fvdl
326 1.7 fvdl /*
327 1.7 fvdl * The (unsupplied) definition of the `current execution stack'
328 1.7 fvdl * in the System V Interface Definition appears to allow returning
329 1.7 fvdl * the main context stack.
330 1.7 fvdl */
331 1.19 ad if ((l->l_sigstk.ss_flags & SS_ONSTACK) == 0) {
332 1.7 fvdl ucp->uc_stack.ss_sp = USRSTACK32;
333 1.7 fvdl ucp->uc_stack.ss_size = ctob(p->p_vmspace->vm_ssize);
334 1.7 fvdl ucp->uc_stack.ss_flags = 0; /* XXX, def. is Very Fishy */
335 1.7 fvdl } else {
336 1.7 fvdl /* Simply copy alternate signal execution stack. */
337 1.7 fvdl ucp->uc_stack.ss_sp =
338 1.19 ad (uint32_t)(intptr_t)l->l_sigstk.ss_sp;
339 1.19 ad ucp->uc_stack.ss_size = l->l_sigstk.ss_size;
340 1.19 ad ucp->uc_stack.ss_flags = l->l_sigstk.ss_flags;
341 1.7 fvdl }
342 1.7 fvdl ucp->uc_flags |= _UC_STACK;
343 1.20 cube mutex_exit(&p->p_smutex);
344 1.7 fvdl cpu_getmcontext32(l, &ucp->uc_mcontext, &ucp->uc_flags);
345 1.20 cube mutex_enter(&p->p_smutex);
346 1.7 fvdl }
347 1.7 fvdl
348 1.7 fvdl /* ARGSUSED */
349 1.7 fvdl int
350 1.7 fvdl netbsd32_getcontext(struct lwp *l, void *v, register_t *retval)
351 1.7 fvdl {
352 1.7 fvdl struct netbsd32_getcontext_args /* {
353 1.7 fvdl syscallarg(netbsd32_ucontextp) ucp;
354 1.7 fvdl } */ *uap = v;
355 1.20 cube struct proc *p = l->l_proc;
356 1.7 fvdl ucontext32_t uc;
357 1.7 fvdl
358 1.20 cube mutex_enter(&p->p_smutex);
359 1.7 fvdl getucontext32(l, &uc);
360 1.20 cube mutex_exit(&p->p_smutex);
361 1.7 fvdl
362 1.21.6.2 reinoud return copyout(&uc, SCARG_P32(uap, ucp), sizeof (ucontext32_t));
363 1.7 fvdl }
364 1.7 fvdl
365 1.7 fvdl int
366 1.7 fvdl setucontext32(struct lwp *l, const ucontext32_t *ucp)
367 1.7 fvdl {
368 1.20 cube struct proc *p = l->l_proc;
369 1.20 cube int error;
370 1.20 cube
371 1.20 cube LOCK_ASSERT(mutex_owned(&p->p_smutex));
372 1.20 cube
373 1.20 cube if ((ucp->uc_flags & _UC_SIGMASK) != 0) {
374 1.20 cube error = sigprocmask1(l, SIG_SETMASK, &ucp->uc_sigmask, NULL);
375 1.20 cube if (error != 0)
376 1.20 cube return error;
377 1.20 cube }
378 1.7 fvdl
379 1.20 cube mutex_exit(&p->p_smutex);
380 1.20 cube error = cpu_setmcontext32(l, &ucp->uc_mcontext, ucp->uc_flags);
381 1.20 cube mutex_enter(&p->p_smutex);
382 1.20 cube if (error != 0)
383 1.7 fvdl return (error);
384 1.20 cube
385 1.7 fvdl l->l_ctxlink = (void *)(intptr_t)ucp->uc_link;
386 1.20 cube
387 1.7 fvdl /*
388 1.20 cube * If there was stack information, update whether or not we are
389 1.20 cube * still running on an alternate signal stack.
390 1.7 fvdl */
391 1.20 cube if ((ucp->uc_flags & _UC_STACK) != 0) {
392 1.20 cube if (ucp->uc_stack.ss_flags & SS_ONSTACK)
393 1.20 cube l->l_sigstk.ss_flags |= SS_ONSTACK;
394 1.20 cube else
395 1.20 cube l->l_sigstk.ss_flags &= ~SS_ONSTACK;
396 1.20 cube }
397 1.7 fvdl
398 1.7 fvdl return 0;
399 1.7 fvdl }
400 1.7 fvdl
401 1.7 fvdl /* ARGSUSED */
402 1.7 fvdl int
403 1.7 fvdl netbsd32_setcontext(struct lwp *l, void *v, register_t *retval)
404 1.7 fvdl {
405 1.7 fvdl struct netbsd32_setcontext_args /* {
406 1.7 fvdl syscallarg(netbsd32_ucontextp) ucp;
407 1.7 fvdl } */ *uap = v;
408 1.7 fvdl ucontext32_t uc;
409 1.7 fvdl int error;
410 1.20 cube struct proc *p = l->l_proc;
411 1.7 fvdl
412 1.21.6.2 reinoud error = copyin(SCARG_P32(uap, ucp), &uc, sizeof (uc));
413 1.18 drochner if (error)
414 1.18 drochner return (error);
415 1.18 drochner if (!(uc.uc_flags & _UC_CPU))
416 1.18 drochner return (EINVAL);
417 1.20 cube mutex_enter(&p->p_smutex);
418 1.18 drochner error = setucontext32(l, &uc);
419 1.20 cube mutex_exit(&p->p_smutex);
420 1.18 drochner if (error)
421 1.7 fvdl return (error);
422 1.7 fvdl
423 1.7 fvdl return (EJUSTRETURN);
424 1.1 mrg }
425 1.10 cube
426 1.10 cube static int
427 1.10 cube netbsd32_sigtimedwait_put_info(const void *src, void *dst, size_t size)
428 1.10 cube {
429 1.10 cube const siginfo_t *info = src;
430 1.10 cube siginfo32_t info32;
431 1.10 cube
432 1.10 cube netbsd32_si_to_si32(&info32, info);
433 1.10 cube
434 1.10 cube return copyout(&info32, dst, sizeof(info32));
435 1.10 cube }
436 1.10 cube
437 1.10 cube static int
438 1.10 cube netbsd32_sigtimedwait_fetch_timeout(const void *src, void *dst, size_t size)
439 1.10 cube {
440 1.10 cube struct timespec *ts = dst;
441 1.10 cube struct netbsd32_timespec ts32;
442 1.10 cube int error;
443 1.10 cube
444 1.10 cube error = copyin(src, &ts32, sizeof(ts32));
445 1.10 cube if (error)
446 1.10 cube return error;
447 1.10 cube
448 1.10 cube netbsd32_to_timespec(&ts32, ts);
449 1.10 cube return 0;
450 1.10 cube }
451 1.10 cube
452 1.10 cube static int
453 1.10 cube netbsd32_sigtimedwait_put_timeout(const void *src, void *dst, size_t size)
454 1.10 cube {
455 1.10 cube const struct timespec *ts = src;
456 1.10 cube struct netbsd32_timespec ts32;
457 1.10 cube
458 1.10 cube netbsd32_from_timespec(ts, &ts32);
459 1.10 cube
460 1.10 cube return copyout(&ts32, dst, sizeof(ts32));
461 1.10 cube }
462 1.10 cube
463 1.10 cube int
464 1.10 cube netbsd32___sigtimedwait(struct lwp *l, void *v, register_t *retval)
465 1.10 cube {
466 1.10 cube struct netbsd32___sigtimedwait_args /* {
467 1.10 cube syscallarg(netbsd32_sigsetp_t) set;
468 1.10 cube syscallarg(netbsd32_siginfop_t) info;
469 1.10 cube syscallarg(netbsd32_timespecp_t) timeout;
470 1.10 cube } */ *uap = v;
471 1.10 cube struct sys___sigtimedwait_args ua;
472 1.10 cube
473 1.10 cube NETBSD32TOP_UAP(set, const sigset_t);
474 1.10 cube NETBSD32TOP_UAP(info, siginfo_t);
475 1.10 cube NETBSD32TOP_UAP(timeout, struct timespec);
476 1.10 cube
477 1.10 cube return __sigtimedwait1(l, &ua, retval, netbsd32_sigtimedwait_put_info,
478 1.10 cube netbsd32_sigtimedwait_fetch_timeout,
479 1.10 cube netbsd32_sigtimedwait_put_timeout);
480 1.10 cube }
481