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