xref: /netbsd-src/sys/compat/netbsd32/netbsd32_netbsd.c (revision 09afef20633f5fe63d92dfe43ee3a9380dc06883)
1 /*	$NetBSD: netbsd32_netbsd.c,v 1.160 2009/11/21 11:54:54 njoly Exp $	*/
2 
3 /*
4  * Copyright (c) 1998, 2001, 2008 Matthew R. Green
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 AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #include <sys/cdefs.h>
30 __KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.160 2009/11/21 11:54:54 njoly Exp $");
31 
32 #if defined(_KERNEL_OPT)
33 #include "opt_ddb.h"
34 #include "opt_ntp.h"
35 #include "opt_compat_netbsd.h"
36 #include "opt_compat_43.h"
37 #include "opt_sysv.h"
38 #include "opt_syscall_debug.h"
39 #include "opt_sa.h"
40 
41 #include "fs_lfs.h"
42 #endif
43 
44 /*
45  * Though COMPAT_OLDSOCK is needed only for COMPAT_43, SunOS, Linux,
46  * HP-UX, FreeBSD, Ultrix, OSF1, we define it unconditionally so that
47  * this would be module-safe.
48  */
49 #define COMPAT_OLDSOCK /* used by <sys/socket.h> */
50 
51 #include <sys/param.h>
52 #include <sys/systm.h>
53 #include <sys/kernel.h>
54 //#define msg __msg /* Don't ask me! */
55 #include <sys/malloc.h>
56 #include <sys/mount.h>
57 #include <sys/socket.h>
58 #include <sys/sockio.h>
59 #include <sys/socketvar.h>
60 #include <sys/mbuf.h>
61 #include <sys/stat.h>
62 #include <sys/time.h>
63 #include <sys/signalvar.h>
64 #include <sys/ptrace.h>
65 #include <sys/ktrace.h>
66 #include <sys/trace.h>
67 #include <sys/resourcevar.h>
68 #include <sys/pool.h>
69 #include <sys/vnode.h>
70 #include <sys/file.h>
71 #include <sys/filedesc.h>
72 #include <sys/namei.h>
73 #include <sys/dirent.h>
74 #include <sys/kauth.h>
75 #include <sys/vfs_syscalls.h>
76 
77 #include <uvm/uvm_extern.h>
78 
79 #include <sys/sa.h>
80 #include <sys/savar.h>
81 #include <sys/syscallargs.h>
82 #include <sys/proc.h>
83 #include <sys/acct.h>
84 #include <sys/exec.h>
85 
86 #include <net/if.h>
87 
88 #include <compat/netbsd32/netbsd32.h>
89 #include <compat/netbsd32/netbsd32_exec.h>
90 #include <compat/netbsd32/netbsd32_syscall.h>
91 #include <compat/netbsd32/netbsd32_syscallargs.h>
92 #include <compat/netbsd32/netbsd32_conv.h>
93 #include <compat/netbsd32/netbsd32_sa.h>
94 
95 #include <machine/frame.h>
96 
97 #if defined(DDB)
98 #include <ddb/ddbvar.h>
99 #endif
100 
101 extern struct sysent netbsd32_sysent[];
102 #ifdef SYSCALL_DEBUG
103 extern const char * const netbsd32_syscallnames[];
104 #endif
105 #ifdef __HAVE_SYSCALL_INTERN
106 void netbsd32_syscall_intern(struct proc *);
107 #else
108 void syscall(void);
109 #endif
110 
111 #define LIMITCHECK(a, b) ((a) != RLIM_INFINITY && (a) > (b))
112 
113 #ifdef COMPAT_16
114 extern char netbsd32_sigcode[], netbsd32_esigcode[];
115 struct uvm_object *emul_netbsd32_object;
116 #endif
117 
118 extern struct sysctlnode netbsd32_sysctl_root;
119 
120 const struct sa_emul saemul_netbsd32 = {
121 	sizeof(ucontext32_t),
122 	sizeof(struct netbsd32_sa_t),
123 	sizeof(netbsd32_sa_tp),
124 	netbsd32_sacopyout,
125 	netbsd32_upcallconv,
126 	netbsd32_cpu_upcall,
127 	(void (*)(struct lwp *, void *))getucontext32_sa,
128 #ifdef KERN_SA
129 	netbsd32_sa_ucsp
130 #else
131 	NULL
132 #endif
133 };
134 
135 struct emul emul_netbsd32 = {
136 	.e_name =		"netbsd32",
137 	.e_path =		"/emul/netbsd32",
138 #ifndef __HAVE_MINIMAL_EMUL
139 	.e_flags =		0,
140 	.e_errno =		NULL,
141 	.e_nosys =		NETBSD32_SYS_netbsd32_syscall,
142 	.e_nsysent =		NETBSD32_SYS_NSYSENT,
143 #endif
144 	.e_sysent =		netbsd32_sysent,
145 #ifdef SYSCALL_DEBUG
146 	.e_syscallnames =	netbsd32_syscallnames,
147 #else
148 	.e_syscallnames =	NULL,
149 #endif
150 	.e_sendsig =		netbsd32_sendsig,
151 	.e_trapsignal =		trapsignal,
152 	.e_tracesig =		NULL,
153 #ifdef COMPAT_16
154 	.e_sigcode =		netbsd32_sigcode,
155 	.e_esigcode =		netbsd32_esigcode,
156 	.e_sigobject =		&emul_netbsd32_object,
157 #else
158 	.e_sigcode =		NULL,
159 	.e_esigcode =		NULL,
160 	.e_sigobject =		NULL,
161 #endif
162 	.e_setregs =		netbsd32_setregs,
163 	.e_proc_exec =		NULL,
164 	.e_proc_fork =		NULL,
165 	.e_proc_exit =		NULL,
166 	.e_lwp_fork =		NULL,
167 	.e_lwp_exit =		NULL,
168 #ifdef __HAVE_SYSCALL_INTERN
169 	.e_syscall_intern =	netbsd32_syscall_intern,
170 #else
171 	.e_syscall =		syscall,
172 #endif
173 	.e_sysctlovly =		&netbsd32_sysctl_root,
174 	.e_fault =		NULL,
175 	.e_vm_default_addr =	netbsd32_vm_default_addr,
176 	.e_usertrap =		NULL,
177 #ifdef COMPAT_40
178 	.e_sa =			&saemul_netbsd32,
179 #else
180 	.e_sa =			NULL,
181 #endif
182 	.e_ucsize =		sizeof(ucontext32_t),
183 	.e_startlwp =		startlwp32
184 };
185 
186 /*
187  * below are all the standard NetBSD system calls, in the 32bit
188  * environment, with the necessary conversions to 64bit before
189  * calling the real syscall.  anything that needs special
190  * attention is handled elsewhere.
191  */
192 
193 int
194 netbsd32_exit(struct lwp *l, const struct netbsd32_exit_args *uap, register_t *retval)
195 {
196 	/* {
197 		syscallarg(int) rval;
198 	} */
199 	struct sys_exit_args ua;
200 
201 	NETBSD32TO64_UAP(rval);
202 	return sys_exit(l, &ua, retval);
203 }
204 
205 int
206 netbsd32_read(struct lwp *l, const struct netbsd32_read_args *uap, register_t *retval)
207 {
208 	/* {
209 		syscallarg(int) fd;
210 		syscallarg(netbsd32_voidp) buf;
211 		syscallarg(netbsd32_size_t) nbyte;
212 	} */
213 	struct sys_read_args ua;
214 
215 	NETBSD32TO64_UAP(fd);
216 	NETBSD32TOP_UAP(buf, void *);
217 	NETBSD32TOX_UAP(nbyte, size_t);
218 	return sys_read(l, &ua, retval);
219 }
220 
221 int
222 netbsd32_write(struct lwp *l, const struct netbsd32_write_args *uap, register_t *retval)
223 {
224 	/* {
225 		syscallarg(int) fd;
226 		syscallarg(const netbsd32_voidp) buf;
227 		syscallarg(netbsd32_size_t) nbyte;
228 	} */
229 	struct sys_write_args ua;
230 
231 	NETBSD32TO64_UAP(fd);
232 	NETBSD32TOP_UAP(buf, void *);
233 	NETBSD32TOX_UAP(nbyte, size_t);
234 	return sys_write(l, &ua, retval);
235 }
236 
237 int
238 netbsd32_close(struct lwp *l, const struct netbsd32_close_args *uap, register_t *retval)
239 {
240 	/* {
241 		syscallarg(int) fd;
242 	} */
243 	struct sys_close_args ua;
244 
245 	NETBSD32TO64_UAP(fd);
246 	return sys_close(l, &ua, retval);
247 }
248 
249 int
250 netbsd32_open(struct lwp *l, const struct netbsd32_open_args *uap, register_t *retval)
251 {
252 	/* {
253 		syscallarg(const netbsd32_charp) path;
254 		syscallarg(int) flags;
255 		syscallarg(mode_t) mode;
256 	} */
257 	struct sys_open_args ua;
258 
259 	NETBSD32TOP_UAP(path, const char);
260 	NETBSD32TO64_UAP(flags);
261 	NETBSD32TO64_UAP(mode);
262 
263 	return (sys_open(l, &ua, retval));
264 }
265 
266 int
267 netbsd32_link(struct lwp *l, const struct netbsd32_link_args *uap, register_t *retval)
268 {
269 	/* {
270 		syscallarg(const netbsd32_charp) path;
271 		syscallarg(const netbsd32_charp) link;
272 	} */
273 	struct sys_link_args ua;
274 
275 	NETBSD32TOP_UAP(path, const char);
276 	NETBSD32TOP_UAP(link, const char);
277 	return (sys_link(l, &ua, retval));
278 }
279 
280 int
281 netbsd32_unlink(struct lwp *l, const struct netbsd32_unlink_args *uap, register_t *retval)
282 {
283 	/* {
284 		syscallarg(const netbsd32_charp) path;
285 	} */
286 	struct sys_unlink_args ua;
287 
288 	NETBSD32TOP_UAP(path, const char);
289 
290 	return (sys_unlink(l, &ua, retval));
291 }
292 
293 int
294 netbsd32_chdir(struct lwp *l, const struct netbsd32_chdir_args *uap, register_t *retval)
295 {
296 	/* {
297 		syscallarg(const netbsd32_charp) path;
298 	} */
299 	struct sys_chdir_args ua;
300 
301 	NETBSD32TOP_UAP(path, const char);
302 
303 	return (sys_chdir(l, &ua, retval));
304 }
305 
306 int
307 netbsd32_fchdir(struct lwp *l, const struct netbsd32_fchdir_args *uap, register_t *retval)
308 {
309 	/* {
310 		syscallarg(int) fd;
311 	} */
312 	struct sys_fchdir_args ua;
313 
314 	NETBSD32TO64_UAP(fd);
315 
316 	return (sys_fchdir(l, &ua, retval));
317 }
318 
319 int
320 netbsd32___mknod50(struct lwp *l, const struct netbsd32___mknod50_args *uap, register_t *retval)
321 {
322 	/* {
323 		syscallarg(const netbsd32_charp) path;
324 		syscallarg(mode_t) mode;
325 		syscallarg(netbsd32_dev_t) dev;
326 	} */
327 
328 	return do_sys_mknod(l, SCARG_P32(uap, path), SCARG(uap, mode),
329 	    SCARG(uap, dev), retval, UIO_USERSPACE);
330 }
331 
332 int
333 netbsd32_chmod(struct lwp *l, const struct netbsd32_chmod_args *uap, register_t *retval)
334 {
335 	/* {
336 		syscallarg(const netbsd32_charp) path;
337 		syscallarg(mode_t) mode;
338 	} */
339 	struct sys_chmod_args ua;
340 
341 	NETBSD32TOP_UAP(path, const char);
342 	NETBSD32TO64_UAP(mode);
343 
344 	return (sys_chmod(l, &ua, retval));
345 }
346 
347 int
348 netbsd32_chown(struct lwp *l, const struct netbsd32_chown_args *uap, register_t *retval)
349 {
350 	/* {
351 		syscallarg(const netbsd32_charp) path;
352 		syscallarg(uid_t) uid;
353 		syscallarg(gid_t) gid;
354 	} */
355 	struct sys_chown_args ua;
356 
357 	NETBSD32TOP_UAP(path, const char);
358 	NETBSD32TO64_UAP(uid);
359 	NETBSD32TO64_UAP(gid);
360 
361 	return (sys_chown(l, &ua, retval));
362 }
363 
364 int
365 netbsd32_break(struct lwp *l, const struct netbsd32_break_args *uap, register_t *retval)
366 {
367 	/* {
368 		syscallarg(netbsd32_charp) nsize;
369 	} */
370 	struct sys_obreak_args ua;
371 
372 	NETBSD32TOP_UAP(nsize, char);
373 	return (sys_obreak(l, &ua, retval));
374 }
375 
376 int
377 netbsd32_mount(struct lwp *l, const struct netbsd32_mount_args *uap, register_t *retval)
378 {
379 #ifdef COMPAT_40
380 	/* {
381 		syscallarg(const netbsd32_charp) type;
382 		syscallarg(const netbsd32_charp) path;
383 		syscallarg(int) flags;
384 		syscallarg(netbsd32_voidp) data;
385 	} */
386 	struct compat_40_sys_mount_args ua;
387 
388 	NETBSD32TOP_UAP(type, const char);
389 	NETBSD32TOP_UAP(path, const char);
390 	NETBSD32TO64_UAP(flags);
391 	NETBSD32TOP_UAP(data, void);
392 	return (compat_40_sys_mount(l, &ua, retval));
393 #else
394 	return ENOSYS;
395 #endif
396 }
397 
398 int
399 netbsd32_unmount(struct lwp *l, const struct netbsd32_unmount_args *uap, register_t *retval)
400 {
401 	/* {
402 		syscallarg(const netbsd32_charp) path;
403 		syscallarg(int) flags;
404 	} */
405 	struct sys_unmount_args ua;
406 
407 	NETBSD32TOP_UAP(path, const char);
408 	NETBSD32TO64_UAP(flags);
409 	return (sys_unmount(l, &ua, retval));
410 }
411 
412 int
413 netbsd32_setuid(struct lwp *l, const struct netbsd32_setuid_args *uap, register_t *retval)
414 {
415 	/* {
416 		syscallarg(uid_t) uid;
417 	} */
418 	struct sys_setuid_args ua;
419 
420 	NETBSD32TO64_UAP(uid);
421 	return (sys_setuid(l, &ua, retval));
422 }
423 
424 int
425 netbsd32_ptrace(struct lwp *l, const struct netbsd32_ptrace_args *uap, register_t *retval)
426 {
427 	/* {
428 		syscallarg(int) req;
429 		syscallarg(pid_t) pid;
430 		syscallarg(netbsd32_voidp) addr;
431 		syscallarg(int) data;
432 	} */
433 	struct sys_ptrace_args ua;
434 
435 	NETBSD32TO64_UAP(req);
436 	NETBSD32TO64_UAP(pid);
437 	NETBSD32TOP_UAP(addr, void *);
438 	NETBSD32TO64_UAP(data);
439 
440 	return (*sysent[SYS_ptrace].sy_call)(l, &ua, retval);
441 }
442 
443 int
444 netbsd32_accept(struct lwp *l, const struct netbsd32_accept_args *uap, register_t *retval)
445 {
446 	/* {
447 		syscallarg(int) s;
448 		syscallarg(netbsd32_sockaddrp_t) name;
449 		syscallarg(netbsd32_intp) anamelen;
450 	} */
451 	struct sys_accept_args ua;
452 
453 	NETBSD32TO64_UAP(s);
454 	NETBSD32TOP_UAP(name, struct sockaddr);
455 	NETBSD32TOP_UAP(anamelen, socklen_t);
456 	return (sys_accept(l, &ua, retval));
457 }
458 
459 int
460 netbsd32_getpeername(struct lwp *l, const struct netbsd32_getpeername_args *uap, register_t *retval)
461 {
462 	/* {
463 		syscallarg(int) fdes;
464 		syscallarg(netbsd32_sockaddrp_t) asa;
465 		syscallarg(netbsd32_intp) alen;
466 	} */
467 	struct sys_getpeername_args ua;
468 
469 	NETBSD32TO64_UAP(fdes);
470 	NETBSD32TOP_UAP(asa, struct sockaddr);
471 	NETBSD32TOP_UAP(alen, socklen_t);
472 /* NB: do the protocol specific sockaddrs need to be converted? */
473 	return (sys_getpeername(l, &ua, retval));
474 }
475 
476 int
477 netbsd32_getsockname(struct lwp *l, const struct netbsd32_getsockname_args *uap, register_t *retval)
478 {
479 	/* {
480 		syscallarg(int) fdes;
481 		syscallarg(netbsd32_sockaddrp_t) asa;
482 		syscallarg(netbsd32_intp) alen;
483 	} */
484 	struct sys_getsockname_args ua;
485 
486 	NETBSD32TO64_UAP(fdes);
487 	NETBSD32TOP_UAP(asa, struct sockaddr);
488 	NETBSD32TOP_UAP(alen, socklen_t);
489 	return (sys_getsockname(l, &ua, retval));
490 }
491 
492 int
493 netbsd32_access(struct lwp *l, const struct netbsd32_access_args *uap, register_t *retval)
494 {
495 	/* {
496 		syscallarg(const netbsd32_charp) path;
497 		syscallarg(int) flags;
498 	} */
499 	struct sys_access_args ua;
500 
501 	NETBSD32TOP_UAP(path, const char);
502 	NETBSD32TO64_UAP(flags);
503 
504 	return sys_access(l, &ua, retval);
505 }
506 
507 int
508 netbsd32_chflags(struct lwp *l, const struct netbsd32_chflags_args *uap, register_t *retval)
509 {
510 	/* {
511 		syscallarg(const netbsd32_charp) path;
512 		syscallarg(netbsd32_u_long) flags;
513 	} */
514 	struct sys_chflags_args ua;
515 
516 	NETBSD32TOP_UAP(path, const char);
517 	NETBSD32TO64_UAP(flags);
518 
519 	return (sys_chflags(l, &ua, retval));
520 }
521 
522 int
523 netbsd32_fchflags(struct lwp *l, const struct netbsd32_fchflags_args *uap, register_t *retval)
524 {
525 	/* {
526 		syscallarg(int) fd;
527 		syscallarg(netbsd32_u_long) flags;
528 	} */
529 	struct sys_fchflags_args ua;
530 
531 	NETBSD32TO64_UAP(fd);
532 	NETBSD32TO64_UAP(flags);
533 
534 	return (sys_fchflags(l, &ua, retval));
535 }
536 
537 int
538 netbsd32_lchflags(struct lwp *l, const struct netbsd32_lchflags_args *uap, register_t *retval)
539 {
540 	/* {
541 		syscallarg(const char *) path;
542 		syscallarg(netbsd32_u_long) flags;
543 	} */
544 	struct sys_lchflags_args ua;
545 
546 	NETBSD32TOP_UAP(path, const char);
547 	NETBSD32TO64_UAP(flags);
548 
549 	return (sys_lchflags(l, &ua, retval));
550 }
551 
552 int
553 netbsd32_kill(struct lwp *l, const struct netbsd32_kill_args *uap, register_t *retval)
554 {
555 	/* {
556 		syscallarg(int) pid;
557 		syscallarg(int) signum;
558 	} */
559 	struct sys_kill_args ua;
560 
561 	NETBSD32TO64_UAP(pid);
562 	NETBSD32TO64_UAP(signum);
563 
564 	return (sys_kill(l, &ua, retval));
565 }
566 
567 int
568 netbsd32_dup(struct lwp *l, const struct netbsd32_dup_args *uap, register_t *retval)
569 {
570 	/* {
571 		syscallarg(int) fd;
572 	} */
573 	struct sys_dup_args ua;
574 
575 	NETBSD32TO64_UAP(fd);
576 
577 	return (sys_dup(l, &ua, retval));
578 }
579 
580 int
581 netbsd32_profil(struct lwp *l, const struct netbsd32_profil_args *uap, register_t *retval)
582 {
583 	/* {
584 		syscallarg(netbsd32_voidp) samples;
585 		syscallarg(netbsd32_size_t) size;
586 		syscallarg(netbsd32_u_long) offset;
587 		syscallarg(u_int) scale;
588 	} */
589 	struct sys_profil_args ua;
590 
591 	NETBSD32TOP_UAP(samples, void *);
592 	NETBSD32TOX_UAP(size, size_t);
593 	NETBSD32TOX_UAP(offset, u_long);
594 	NETBSD32TO64_UAP(scale);
595 	return (sys_profil(l, &ua, retval));
596 }
597 
598 int
599 netbsd32_ktrace(struct lwp *l, const struct netbsd32_ktrace_args *uap, register_t *retval)
600 {
601 	/* {
602 		syscallarg(const netbsd32_charp) fname;
603 		syscallarg(int) ops;
604 		syscallarg(int) facs;
605 		syscallarg(int) pid;
606 	} */
607 	struct sys_ktrace_args ua;
608 
609 	NETBSD32TOP_UAP(fname, const char);
610 	NETBSD32TO64_UAP(ops);
611 	NETBSD32TO64_UAP(facs);
612 	NETBSD32TO64_UAP(pid);
613 	return (sys_ktrace(l, &ua, retval));
614 }
615 
616 int
617 netbsd32_utrace(struct lwp *l, const struct netbsd32_utrace_args *uap, register_t *retval)
618 {
619 	/* {
620 		syscallarg(const netbsd32_charp) label;
621 		syscallarg(netbsd32_voidp) addr;
622 		syscallarg(netbsd32_size_t) len;
623 	} */
624 	struct sys_utrace_args ua;
625 
626 	NETBSD32TOP_UAP(label, const char);
627 	NETBSD32TOP_UAP(addr, void);
628 	NETBSD32TO64_UAP(len);
629 	return (sys_utrace(l, &ua, retval));
630 }
631 
632 int
633 netbsd32___getlogin(struct lwp *l, const struct netbsd32___getlogin_args *uap, register_t *retval)
634 {
635 	/* {
636 		syscallarg(netbsd32_charp) namebuf;
637 		syscallarg(u_int) namelen;
638 	} */
639 	struct sys___getlogin_args ua;
640 
641 	NETBSD32TOP_UAP(namebuf, char);
642 	NETBSD32TO64_UAP(namelen);
643 	return (sys___getlogin(l, &ua, retval));
644 }
645 
646 int
647 netbsd32_setlogin(struct lwp *l, const struct netbsd32_setlogin_args *uap, register_t *retval)
648 {
649 	/* {
650 		syscallarg(const netbsd32_charp) namebuf;
651 	} */
652 	struct sys___setlogin_args ua;
653 
654 	NETBSD32TOP_UAP(namebuf, char);
655 	return (sys___setlogin(l, &ua, retval));
656 }
657 
658 int
659 netbsd32_acct(struct lwp *l, const struct netbsd32_acct_args *uap, register_t *retval)
660 {
661 	/* {
662 		syscallarg(const netbsd32_charp) path;
663 	} */
664 	struct sys_acct_args ua;
665 
666 	NETBSD32TOP_UAP(path, const char);
667 	return (sys_acct(l, &ua, retval));
668 }
669 
670 int
671 netbsd32_revoke(struct lwp *l, const struct netbsd32_revoke_args *uap, register_t *retval)
672 {
673 	/* {
674 		syscallarg(const netbsd32_charp) path;
675 	} */
676 	struct sys_revoke_args ua;
677 
678 	NETBSD32TOP_UAP(path, const char);
679 
680 	return (sys_revoke(l, &ua, retval));
681 }
682 
683 int
684 netbsd32_symlink(struct lwp *l, const struct netbsd32_symlink_args *uap, register_t *retval)
685 {
686 	/* {
687 		syscallarg(const netbsd32_charp) path;
688 		syscallarg(const netbsd32_charp) link;
689 	} */
690 	struct sys_symlink_args ua;
691 
692 	NETBSD32TOP_UAP(path, const char);
693 	NETBSD32TOP_UAP(link, const char);
694 
695 	return (sys_symlink(l, &ua, retval));
696 }
697 
698 int
699 netbsd32_readlink(struct lwp *l, const struct netbsd32_readlink_args *uap, register_t *retval)
700 {
701 	/* {
702 		syscallarg(const netbsd32_charp) path;
703 		syscallarg(netbsd32_charp) buf;
704 		syscallarg(netbsd32_size_t) count;
705 	} */
706 	struct sys_readlink_args ua;
707 
708 	NETBSD32TOP_UAP(path, const char);
709 	NETBSD32TOP_UAP(buf, char);
710 	NETBSD32TOX_UAP(count, size_t);
711 
712 	return (sys_readlink(l, &ua, retval));
713 }
714 
715 int
716 netbsd32_umask(struct lwp *l, const struct netbsd32_umask_args *uap, register_t *retval)
717 {
718 	/* {
719 		syscallarg(mode_t) newmask;
720 	} */
721 	struct sys_umask_args ua;
722 
723 	NETBSD32TO64_UAP(newmask);
724 	return (sys_umask(l, &ua, retval));
725 }
726 
727 int
728 netbsd32_chroot(struct lwp *l, const struct netbsd32_chroot_args *uap, register_t *retval)
729 {
730 	/* {
731 		syscallarg(const netbsd32_charp) path;
732 	} */
733 	struct sys_chroot_args ua;
734 
735 	NETBSD32TOP_UAP(path, const char);
736 	return (sys_chroot(l, &ua, retval));
737 }
738 
739 int
740 netbsd32_sbrk(struct lwp *l, const struct netbsd32_sbrk_args *uap, register_t *retval)
741 {
742 	/* {
743 		syscallarg(int) incr;
744 	} */
745 	struct sys_sbrk_args ua;
746 
747 	NETBSD32TO64_UAP(incr);
748 	return (sys_sbrk(l, &ua, retval));
749 }
750 
751 int
752 netbsd32_sstk(struct lwp *l, const struct netbsd32_sstk_args *uap, register_t *retval)
753 {
754 	/* {
755 		syscallarg(int) incr;
756 	} */
757 	struct sys_sstk_args ua;
758 
759 	NETBSD32TO64_UAP(incr);
760 	return (sys_sstk(l, &ua, retval));
761 }
762 
763 int
764 netbsd32_munmap(struct lwp *l, const struct netbsd32_munmap_args *uap, register_t *retval)
765 {
766 	/* {
767 		syscallarg(netbsd32_voidp) addr;
768 		syscallarg(netbsd32_size_t) len;
769 	} */
770 	struct sys_munmap_args ua;
771 
772 	NETBSD32TOP_UAP(addr, void);
773 	NETBSD32TOX_UAP(len, size_t);
774 	return (sys_munmap(l, &ua, retval));
775 }
776 
777 int
778 netbsd32_mprotect(struct lwp *l, const struct netbsd32_mprotect_args *uap, register_t *retval)
779 {
780 	/* {
781 		syscallarg(netbsd32_voidp) addr;
782 		syscallarg(netbsd32_size_t) len;
783 		syscallarg(int) prot;
784 	} */
785 	struct sys_mprotect_args ua;
786 
787 	NETBSD32TOP_UAP(addr, void);
788 	NETBSD32TOX_UAP(len, size_t);
789 	NETBSD32TO64_UAP(prot);
790 	return (sys_mprotect(l, &ua, retval));
791 }
792 
793 int
794 netbsd32_madvise(struct lwp *l, const struct netbsd32_madvise_args *uap, register_t *retval)
795 {
796 	/* {
797 		syscallarg(netbsd32_voidp) addr;
798 		syscallarg(netbsd32_size_t) len;
799 		syscallarg(int) behav;
800 	} */
801 	struct sys_madvise_args ua;
802 
803 	NETBSD32TOP_UAP(addr, void);
804 	NETBSD32TOX_UAP(len, size_t);
805 	NETBSD32TO64_UAP(behav);
806 	return (sys_madvise(l, &ua, retval));
807 }
808 
809 int
810 netbsd32_mincore(struct lwp *l, const struct netbsd32_mincore_args *uap, register_t *retval)
811 {
812 	/* {
813 		syscallarg(netbsd32_voidp) addr;
814 		syscallarg(netbsd32_size_t) len;
815 		syscallarg(netbsd32_charp) vec;
816 	} */
817 	struct sys_mincore_args ua;
818 
819 	NETBSD32TOP_UAP(addr, void *);
820 	NETBSD32TOX_UAP(len, size_t);
821 	NETBSD32TOP_UAP(vec, char);
822 	return (sys_mincore(l, &ua, retval));
823 }
824 
825 /* XXX MOVE ME XXX ? */
826 int
827 netbsd32_getgroups(struct lwp *l, const struct netbsd32_getgroups_args *uap, register_t *retval)
828 {
829 	/* {
830 		syscallarg(int) gidsetsize;
831 		syscallarg(netbsd32_gid_tp) gidset;
832 	} */
833 	struct sys_getgroups_args ua;
834 
835 	/* Since sizeof (gid_t) == sizeof (netbsd32_gid_t) ... */
836 
837 	NETBSD32TO64_UAP(gidsetsize);
838 	NETBSD32TOP_UAP(gidset, gid_t);
839 	return (sys_getgroups(l, &ua, retval));
840 }
841 
842 int
843 netbsd32_setgroups(struct lwp *l, const struct netbsd32_setgroups_args *uap, register_t *retval)
844 {
845 	/* {
846 		syscallarg(int) gidsetsize;
847 		syscallarg(const netbsd32_gid_tp) gidset;
848 	} */
849 	struct sys_setgroups_args ua;
850 
851 	NETBSD32TO64_UAP(gidsetsize);
852 	NETBSD32TOP_UAP(gidset, gid_t);
853 	return (sys_setgroups(l, &ua, retval));
854 }
855 
856 int
857 netbsd32_setpgid(struct lwp *l, const struct netbsd32_setpgid_args *uap, register_t *retval)
858 {
859 	/* {
860 		syscallarg(int) pid;
861 		syscallarg(int) pgid;
862 	} */
863 	struct sys_setpgid_args ua;
864 
865 	NETBSD32TO64_UAP(pid);
866 	NETBSD32TO64_UAP(pgid);
867 	return (sys_setpgid(l, &ua, retval));
868 }
869 
870 int
871 netbsd32_fcntl(struct lwp *l, const struct netbsd32_fcntl_args *uap, register_t *retval)
872 {
873 	/* {
874 		syscallarg(int) fd;
875 		syscallarg(int) cmd;
876 		syscallarg(netbsd32_voidp) arg;
877 	} */
878 	struct sys_fcntl_args ua;
879 
880 	NETBSD32TO64_UAP(fd);
881 	NETBSD32TO64_UAP(cmd);
882 	NETBSD32TOP_UAP(arg, void);
883 	/* we can do this because `struct flock' doesn't change */
884 	return (sys_fcntl(l, &ua, retval));
885 }
886 
887 int
888 netbsd32_dup2(struct lwp *l, const struct netbsd32_dup2_args *uap, register_t *retval)
889 {
890 	/* {
891 		syscallarg(int) from;
892 		syscallarg(int) to;
893 	} */
894 	struct sys_dup2_args ua;
895 
896 	NETBSD32TO64_UAP(from);
897 	NETBSD32TO64_UAP(to);
898 	return (sys_dup2(l, &ua, retval));
899 }
900 
901 int
902 netbsd32_fsync(struct lwp *l, const struct netbsd32_fsync_args *uap, register_t *retval)
903 {
904 	/* {
905 		syscallarg(int) fd;
906 	} */
907 	struct sys_fsync_args ua;
908 
909 	NETBSD32TO64_UAP(fd);
910 	return (sys_fsync(l, &ua, retval));
911 }
912 
913 int
914 netbsd32_setpriority(struct lwp *l, const struct netbsd32_setpriority_args *uap, register_t *retval)
915 {
916 	/* {
917 		syscallarg(int) which;
918 		syscallarg(int) who;
919 		syscallarg(int) prio;
920 	} */
921 	struct sys_setpriority_args ua;
922 
923 	NETBSD32TO64_UAP(which);
924 	NETBSD32TO64_UAP(who);
925 	NETBSD32TO64_UAP(prio);
926 	return (sys_setpriority(l, &ua, retval));
927 }
928 
929 int
930 netbsd32___socket30(struct lwp *l, const struct netbsd32___socket30_args *uap, register_t *retval)
931 {
932 	/* {
933 		syscallarg(int) domain;
934 		syscallarg(int) type;
935 		syscallarg(int) protocol;
936 	} */
937 	struct sys___socket30_args ua;
938 
939 	NETBSD32TO64_UAP(domain);
940 	NETBSD32TO64_UAP(type);
941 	NETBSD32TO64_UAP(protocol);
942 	return (sys___socket30(l, &ua, retval));
943 }
944 
945 int
946 netbsd32_connect(struct lwp *l, const struct netbsd32_connect_args *uap, register_t *retval)
947 {
948 	/* {
949 		syscallarg(int) s;
950 		syscallarg(const netbsd32_sockaddrp_t) name;
951 		syscallarg(int) namelen;
952 	} */
953 	struct sys_connect_args ua;
954 
955 	NETBSD32TO64_UAP(s);
956 	NETBSD32TOP_UAP(name, struct sockaddr);
957 	NETBSD32TO64_UAP(namelen);
958 	return (sys_connect(l, &ua, retval));
959 }
960 
961 int
962 netbsd32_getpriority(struct lwp *l, const struct netbsd32_getpriority_args *uap, register_t *retval)
963 {
964 	/* {
965 		syscallarg(int) which;
966 		syscallarg(int) who;
967 	} */
968 	struct sys_getpriority_args ua;
969 
970 	NETBSD32TO64_UAP(which);
971 	NETBSD32TO64_UAP(who);
972 	return (sys_getpriority(l, &ua, retval));
973 }
974 
975 int
976 netbsd32_bind(struct lwp *l, const struct netbsd32_bind_args *uap, register_t *retval)
977 {
978 	/* {
979 		syscallarg(int) s;
980 		syscallarg(const netbsd32_sockaddrp_t) name;
981 		syscallarg(int) namelen;
982 	} */
983 	struct sys_bind_args ua;
984 
985 	NETBSD32TO64_UAP(s);
986 	NETBSD32TOP_UAP(name, struct sockaddr);
987 	NETBSD32TO64_UAP(namelen);
988 	return (sys_bind(l, &ua, retval));
989 }
990 
991 int
992 netbsd32_setsockopt(struct lwp *l, const struct netbsd32_setsockopt_args *uap, register_t *retval)
993 {
994 	/* {
995 		syscallarg(int) s;
996 		syscallarg(int) level;
997 		syscallarg(int) name;
998 		syscallarg(const netbsd32_voidp) val;
999 		syscallarg(int) valsize;
1000 	} */
1001 	struct sys_setsockopt_args ua;
1002 
1003 	NETBSD32TO64_UAP(s);
1004 	NETBSD32TO64_UAP(level);
1005 	NETBSD32TO64_UAP(name);
1006 	NETBSD32TOP_UAP(val, void);
1007 	NETBSD32TO64_UAP(valsize);
1008 	/* may be more efficient to do this inline. */
1009 	return (sys_setsockopt(l, &ua, retval));
1010 }
1011 
1012 int
1013 netbsd32_listen(struct lwp *l, const struct netbsd32_listen_args *uap, register_t *retval)
1014 {
1015 	/* {
1016 		syscallarg(int) s;
1017 		syscallarg(int) backlog;
1018 	} */
1019 	struct sys_listen_args ua;
1020 
1021 	NETBSD32TO64_UAP(s);
1022 	NETBSD32TO64_UAP(backlog);
1023 	return (sys_listen(l, &ua, retval));
1024 }
1025 
1026 int
1027 netbsd32_fchown(struct lwp *l, const struct netbsd32_fchown_args *uap, register_t *retval)
1028 {
1029 	/* {
1030 		syscallarg(int) fd;
1031 		syscallarg(uid_t) uid;
1032 		syscallarg(gid_t) gid;
1033 	} */
1034 	struct sys_fchown_args ua;
1035 
1036 	NETBSD32TO64_UAP(fd);
1037 	NETBSD32TO64_UAP(uid);
1038 	NETBSD32TO64_UAP(gid);
1039 	return (sys_fchown(l, &ua, retval));
1040 }
1041 
1042 int
1043 netbsd32_fchmod(struct lwp *l, const struct netbsd32_fchmod_args *uap, register_t *retval)
1044 {
1045 	/* {
1046 		syscallarg(int) fd;
1047 		syscallarg(mode_t) mode;
1048 	} */
1049 	struct sys_fchmod_args ua;
1050 
1051 	NETBSD32TO64_UAP(fd);
1052 	NETBSD32TO64_UAP(mode);
1053 	return (sys_fchmod(l, &ua, retval));
1054 }
1055 
1056 int
1057 netbsd32_setreuid(struct lwp *l, const struct netbsd32_setreuid_args *uap, register_t *retval)
1058 {
1059 	/* {
1060 		syscallarg(uid_t) ruid;
1061 		syscallarg(uid_t) euid;
1062 	} */
1063 	struct sys_setreuid_args ua;
1064 
1065 	NETBSD32TO64_UAP(ruid);
1066 	NETBSD32TO64_UAP(euid);
1067 	return (sys_setreuid(l, &ua, retval));
1068 }
1069 
1070 int
1071 netbsd32_setregid(struct lwp *l, const struct netbsd32_setregid_args *uap, register_t *retval)
1072 {
1073 	/* {
1074 		syscallarg(gid_t) rgid;
1075 		syscallarg(gid_t) egid;
1076 	} */
1077 	struct sys_setregid_args ua;
1078 
1079 	NETBSD32TO64_UAP(rgid);
1080 	NETBSD32TO64_UAP(egid);
1081 	return (sys_setregid(l, &ua, retval));
1082 }
1083 
1084 int
1085 netbsd32_getsockopt(struct lwp *l, const struct netbsd32_getsockopt_args *uap, register_t *retval)
1086 {
1087 	/* {
1088 		syscallarg(int) s;
1089 		syscallarg(int) level;
1090 		syscallarg(int) name;
1091 		syscallarg(netbsd32_voidp) val;
1092 		syscallarg(netbsd32_intp) avalsize;
1093 	} */
1094 	struct sys_getsockopt_args ua;
1095 
1096 	NETBSD32TO64_UAP(s);
1097 	NETBSD32TO64_UAP(level);
1098 	NETBSD32TO64_UAP(name);
1099 	NETBSD32TOP_UAP(val, void);
1100 	NETBSD32TOP_UAP(avalsize, socklen_t);
1101 	return (sys_getsockopt(l, &ua, retval));
1102 }
1103 
1104 int
1105 netbsd32_rename(struct lwp *l, const struct netbsd32_rename_args *uap, register_t *retval)
1106 {
1107 	/* {
1108 		syscallarg(const netbsd32_charp) from;
1109 		syscallarg(const netbsd32_charp) to;
1110 	} */
1111 	struct sys_rename_args ua;
1112 
1113 	NETBSD32TOP_UAP(from, const char);
1114 	NETBSD32TOP_UAP(to, const char)
1115 
1116 	return (sys_rename(l, &ua, retval));
1117 }
1118 
1119 int
1120 netbsd32_flock(struct lwp *l, const struct netbsd32_flock_args *uap, register_t *retval)
1121 {
1122 	/* {
1123 		syscallarg(int) fd;
1124 		syscallarg(int) how;
1125 	} */
1126 	struct sys_flock_args ua;
1127 
1128 	NETBSD32TO64_UAP(fd);
1129 	NETBSD32TO64_UAP(how)
1130 
1131 	return (sys_flock(l, &ua, retval));
1132 }
1133 
1134 int
1135 netbsd32_mkfifo(struct lwp *l, const struct netbsd32_mkfifo_args *uap, register_t *retval)
1136 {
1137 	/* {
1138 		syscallarg(const netbsd32_charp) path;
1139 		syscallarg(mode_t) mode;
1140 	} */
1141 	struct sys_mkfifo_args ua;
1142 
1143 	NETBSD32TOP_UAP(path, const char)
1144 	NETBSD32TO64_UAP(mode);
1145 	return (sys_mkfifo(l, &ua, retval));
1146 }
1147 
1148 int
1149 netbsd32_shutdown(struct lwp *l, const struct netbsd32_shutdown_args *uap, register_t *retval)
1150 {
1151 	/* {
1152 		syscallarg(int) s;
1153 		syscallarg(int) how;
1154 	} */
1155 	struct sys_shutdown_args ua;
1156 
1157 	NETBSD32TO64_UAP(s)
1158 	NETBSD32TO64_UAP(how);
1159 	return (sys_shutdown(l, &ua, retval));
1160 }
1161 
1162 int
1163 netbsd32_socketpair(struct lwp *l, const struct netbsd32_socketpair_args *uap, register_t *retval)
1164 {
1165 	/* {
1166 		syscallarg(int) domain;
1167 		syscallarg(int) type;
1168 		syscallarg(int) protocol;
1169 		syscallarg(netbsd32_intp) rsv;
1170 	} */
1171 	struct sys_socketpair_args ua;
1172 
1173 	NETBSD32TO64_UAP(domain);
1174 	NETBSD32TO64_UAP(type);
1175 	NETBSD32TO64_UAP(protocol);
1176 	NETBSD32TOP_UAP(rsv, int);
1177 	/* Since we're just copying out two `int's we can do this */
1178 	return (sys_socketpair(l, &ua, retval));
1179 }
1180 
1181 int
1182 netbsd32_mkdir(struct lwp *l, const struct netbsd32_mkdir_args *uap, register_t *retval)
1183 {
1184 	/* {
1185 		syscallarg(const netbsd32_charp) path;
1186 		syscallarg(mode_t) mode;
1187 	} */
1188 	struct sys_mkdir_args ua;
1189 
1190 	NETBSD32TOP_UAP(path, const char)
1191 	NETBSD32TO64_UAP(mode);
1192 	return (sys_mkdir(l, &ua, retval));
1193 }
1194 
1195 int
1196 netbsd32_rmdir(struct lwp *l, const struct netbsd32_rmdir_args *uap, register_t *retval)
1197 {
1198 	/* {
1199 		syscallarg(const netbsd32_charp) path;
1200 	} */
1201 	struct sys_rmdir_args ua;
1202 
1203 	NETBSD32TOP_UAP(path, const char);
1204 	return (sys_rmdir(l, &ua, retval));
1205 }
1206 
1207 int
1208 netbsd32_quotactl(struct lwp *l, const struct netbsd32_quotactl_args *uap, register_t *retval)
1209 {
1210 	/* {
1211 		syscallarg(const netbsd32_charp) path;
1212 		syscallarg(int) cmd;
1213 		syscallarg(int) uid;
1214 		syscallarg(netbsd32_voidp) arg;
1215 	} */
1216 	struct sys_quotactl_args ua;
1217 
1218 	NETBSD32TOP_UAP(path, const char);
1219 	NETBSD32TO64_UAP(cmd);
1220 	NETBSD32TO64_UAP(uid);
1221 	NETBSD32TOP_UAP(arg, void *);
1222 	return (sys_quotactl(l, &ua, retval));
1223 }
1224 
1225 int
1226 netbsd32_nfssvc(struct lwp *l, const struct netbsd32_nfssvc_args *uap, register_t *retval)
1227 {
1228 #if 0
1229 	/* {
1230 		syscallarg(int) flag;
1231 		syscallarg(netbsd32_voidp) argp;
1232 	} */
1233 	struct sys_nfssvc_args ua;
1234 
1235 	NETBSD32TO64_UAP(flag);
1236 	NETBSD32TOP_UAP(argp, void);
1237 	return (sys_nfssvc(l, &ua, retval));
1238 #else
1239 	/* Why would we want to support a 32-bit nfsd? */
1240 	return (ENOSYS);
1241 #endif
1242 }
1243 
1244 int
1245 netbsd32___getfh30(struct lwp *l, const struct netbsd32___getfh30_args *uap, register_t *retval)
1246 {
1247 	/* {
1248 		syscallarg(const netbsd32_charp) fname;
1249 		syscallarg(netbsd32_fhandlep_t) fhp;
1250 		syscallarg(netbsd32_size_tp) fh_size;
1251 	} */
1252 	struct vnode *vp;
1253 	fhandle_t *fh;
1254 	int error;
1255 	struct nameidata nd;
1256 	netbsd32_size_t sz32;
1257 	size_t sz;
1258 
1259 	/*
1260 	 * Must be super user
1261 	 */
1262 	error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FILEHANDLE,
1263 	    0, NULL, NULL, NULL);
1264 	if (error)
1265 		return (error);
1266 	fh = NULL;
1267 	NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | TRYEMULROOT, UIO_USERSPACE,
1268 	    SCARG_P32(uap, fname));
1269 	error = namei(&nd);
1270 	if (error)
1271 		return (error);
1272 	vp = nd.ni_vp;
1273 	error = copyin(SCARG_P32(uap, fh_size), &sz32,
1274 	    sizeof(netbsd32_size_t));
1275 	if (!error) {
1276 		fh = malloc(sz32, M_TEMP, M_WAITOK);
1277 		if (fh == NULL)
1278 			return EINVAL;
1279 		sz = sz32;
1280 		error = vfs_composefh(vp, fh, &sz);
1281 		sz32 = sz;
1282 	}
1283 	vput(vp);
1284 	if (error == E2BIG)
1285 		copyout(&sz, SCARG_P32(uap, fh_size), sizeof(size_t));
1286 	if (error == 0) {
1287 		error = copyout(&sz32, SCARG_P32(uap, fh_size),
1288 		    sizeof(netbsd32_size_t));
1289 		if (!error)
1290 			error = copyout(fh, SCARG_P32(uap, fhp), sz);
1291 	}
1292 	free(fh, M_TEMP);
1293 	return (error);
1294 }
1295 
1296 int
1297 netbsd32_pread(struct lwp *l, const struct netbsd32_pread_args *uap, register_t *retval)
1298 {
1299 	/* {
1300 		syscallarg(int) fd;
1301 		syscallarg(netbsd32_voidp) buf;
1302 		syscallarg(netbsd32_size_t) nbyte;
1303 		syscallarg(int) PAD;
1304 		syscallarg(off_t) offset;
1305 	} */
1306 	struct sys_pread_args ua;
1307 
1308 	NETBSD32TO64_UAP(fd);
1309 	NETBSD32TOP_UAP(buf, void);
1310 	NETBSD32TOX_UAP(nbyte, size_t);
1311 	NETBSD32TO64_UAP(PAD);
1312 	NETBSD32TO64_UAP(offset);
1313 	return sys_pread(l, &ua, retval);
1314 }
1315 
1316 int
1317 netbsd32_pwrite(struct lwp *l, const struct netbsd32_pwrite_args *uap, register_t *retval)
1318 {
1319 	/* {
1320 		syscallarg(int) fd;
1321 		syscallarg(const netbsd32_voidp) buf;
1322 		syscallarg(netbsd32_size_t) nbyte;
1323 		syscallarg(int) PAD;
1324 		syscallarg(off_t) offset;
1325 	} */
1326 	struct sys_pwrite_args ua;
1327 
1328 	NETBSD32TO64_UAP(fd);
1329 	NETBSD32TOP_UAP(buf, void);
1330 	NETBSD32TOX_UAP(nbyte, size_t);
1331 	NETBSD32TO64_UAP(PAD);
1332 	NETBSD32TO64_UAP(offset);
1333 	return sys_pwrite(l, &ua, retval);
1334 }
1335 
1336 int
1337 netbsd32_setgid(struct lwp *l, const struct netbsd32_setgid_args *uap, register_t *retval)
1338 {
1339 	/* {
1340 		syscallarg(gid_t) gid;
1341 	} */
1342 	struct sys_setgid_args ua;
1343 
1344 	NETBSD32TO64_UAP(gid);
1345 	return (sys_setgid(l, &ua, retval));
1346 }
1347 
1348 int
1349 netbsd32_setegid(struct lwp *l, const struct netbsd32_setegid_args *uap, register_t *retval)
1350 {
1351 	/* {
1352 		syscallarg(gid_t) egid;
1353 	} */
1354 	struct sys_setegid_args ua;
1355 
1356 	NETBSD32TO64_UAP(egid);
1357 	return (sys_setegid(l, &ua, retval));
1358 }
1359 
1360 int
1361 netbsd32_seteuid(struct lwp *l, const struct netbsd32_seteuid_args *uap, register_t *retval)
1362 {
1363 	/* {
1364 		syscallarg(gid_t) euid;
1365 	} */
1366 	struct sys_seteuid_args ua;
1367 
1368 	NETBSD32TO64_UAP(euid);
1369 	return (sys_seteuid(l, &ua, retval));
1370 }
1371 
1372 #ifdef LFS
1373 int
1374 netbsd32_lfs_bmapv(struct lwp *l, const struct netbsd32_lfs_bmapv_args *v, register_t *retval)
1375 {
1376 
1377 	return (ENOSYS);	/* XXX */
1378 }
1379 
1380 int
1381 netbsd32_lfs_markv(struct lwp *l, const struct netbsd32_lfs_markv_args *v, register_t *retval)
1382 {
1383 
1384 	return (ENOSYS);	/* XXX */
1385 }
1386 
1387 int
1388 netbsd32_lfs_segclean(struct lwp *l, const struct netbsd32_lfs_segclean_args *v, register_t *retval)
1389 {
1390 
1391 	return (ENOSYS);	/* XXX */
1392 }
1393 
1394 int
1395 netbsd32___lfs_segwait50(struct lwp *l, const struct netbsd32___lfs_segwait50_args *v, register_t *retval)
1396 {
1397 
1398 	return (ENOSYS);	/* XXX */
1399 }
1400 #endif
1401 
1402 int
1403 netbsd32_pathconf(struct lwp *l, const struct netbsd32_pathconf_args *uap, register_t *retval)
1404 {
1405 	/* {
1406 		syscallarg(int) fd;
1407 		syscallarg(int) name;
1408 	} */
1409 	struct sys_pathconf_args ua;
1410 
1411 	NETBSD32TOP_UAP(path, const char);
1412 	NETBSD32TO64_UAP(name);
1413 	return sys_pathconf(l, &ua, retval);
1414 }
1415 
1416 int
1417 netbsd32_fpathconf(struct lwp *l, const struct netbsd32_fpathconf_args *uap, register_t *retval)
1418 {
1419 	/* {
1420 		syscallarg(int) fd;
1421 		syscallarg(int) name;
1422 	} */
1423 	struct sys_fpathconf_args ua;
1424 
1425 	NETBSD32TO64_UAP(fd);
1426 	NETBSD32TO64_UAP(name);
1427 	return sys_fpathconf(l, &ua, retval);
1428 }
1429 
1430 int
1431 netbsd32_getrlimit(struct lwp *l, const struct netbsd32_getrlimit_args *uap, register_t *retval)
1432 {
1433 	/* {
1434 		syscallarg(int) which;
1435 		syscallarg(netbsd32_rlimitp_t) rlp;
1436 	} */
1437 	int which = SCARG(uap, which);
1438 
1439 	if ((u_int)which >= RLIM_NLIMITS)
1440 		return (EINVAL);
1441 	return (copyout(&l->l_proc->p_rlimit[which],
1442 	    SCARG_P32(uap, rlp), sizeof(struct rlimit)));
1443 }
1444 
1445 int
1446 netbsd32_setrlimit(struct lwp *l, const struct netbsd32_setrlimit_args *uap, register_t *retval)
1447 {
1448 	/* {
1449 		syscallarg(int) which;
1450 		syscallarg(const netbsd32_rlimitp_t) rlp;
1451 	} */
1452 		int which = SCARG(uap, which);
1453 	struct rlimit alim;
1454 	int error;
1455 
1456 	error = copyin(SCARG_P32(uap, rlp), &alim, sizeof(struct rlimit));
1457 	if (error)
1458 		return (error);
1459 
1460 	switch (which) {
1461 	case RLIMIT_DATA:
1462 		if (LIMITCHECK(alim.rlim_cur, MAXDSIZ32))
1463 			alim.rlim_cur = MAXDSIZ32;
1464 		if (LIMITCHECK(alim.rlim_max, MAXDSIZ32))
1465 			alim.rlim_max = MAXDSIZ32;
1466 		break;
1467 
1468 	case RLIMIT_STACK:
1469 		if (LIMITCHECK(alim.rlim_cur, MAXSSIZ32))
1470 			alim.rlim_cur = MAXSSIZ32;
1471 		if (LIMITCHECK(alim.rlim_max, MAXSSIZ32))
1472 			alim.rlim_max = MAXSSIZ32;
1473 	default:
1474 		break;
1475 	}
1476 
1477 	return (dosetrlimit(l, l->l_proc, which, &alim));
1478 }
1479 
1480 int
1481 netbsd32_mmap(struct lwp *l, const struct netbsd32_mmap_args *uap, register_t *retval)
1482 {
1483 	/* {
1484 		syscallarg(netbsd32_voidp) addr;
1485 		syscallarg(netbsd32_size_t) len;
1486 		syscallarg(int) prot;
1487 		syscallarg(int) flags;
1488 		syscallarg(int) fd;
1489 		syscallarg(netbsd32_long) PAD;
1490 		syscallarg(off_t) pos;
1491 	} */
1492 	struct sys_mmap_args ua;
1493 	int error;
1494 
1495 	NETBSD32TOP_UAP(addr, void);
1496 	NETBSD32TOX_UAP(len, size_t);
1497 	NETBSD32TO64_UAP(prot);
1498 	NETBSD32TO64_UAP(flags);
1499 	NETBSD32TO64_UAP(fd);
1500 	NETBSD32TOX_UAP(PAD, long);
1501 	NETBSD32TOX_UAP(pos, off_t);
1502 	error = sys_mmap(l, &ua, retval);
1503 	if ((u_long)*retval > (u_long)UINT_MAX) {
1504 		printf("netbsd32_mmap: retval out of range: 0x%lx",
1505 		    (u_long)*retval);
1506 		/* Should try to recover and return an error here. */
1507 	}
1508 	return (error);
1509 }
1510 
1511 int
1512 netbsd32_mremap(struct lwp *l, const struct netbsd32_mremap_args *uap, register_t *retval)
1513 {
1514 	/* {
1515 		syscallarg(void *) old_address;
1516 		syscallarg(size_t) old_size;
1517 		syscallarg(void *) new_address;
1518 		syscallarg(size_t) new_size;
1519 		syscallarg(int) flags;
1520 	} */
1521 	struct sys_mremap_args ua;
1522 
1523 	NETBSD32TOP_UAP(old_address, void);
1524 	NETBSD32TOX_UAP(old_size, size_t);
1525 	NETBSD32TOP_UAP(new_address, void);
1526 	NETBSD32TOX_UAP(new_size, size_t);
1527 	NETBSD32TO64_UAP(flags);
1528 
1529 	return sys_mremap(l, &ua, retval);
1530 }
1531 
1532 int
1533 netbsd32_lseek(struct lwp *l, const struct netbsd32_lseek_args *uap, register_t *retval)
1534 {
1535 	/* {
1536 		syscallarg(int) fd;
1537 		syscallarg(int) PAD;
1538 		syscallarg(off_t) offset;
1539 		syscallarg(int) whence;
1540 	} */
1541 	struct sys_lseek_args ua;
1542 	union {
1543 	    register_t retval64[2];
1544 	    register32_t retval32[4];
1545 	} newpos;
1546 	int rv;
1547 
1548 	NETBSD32TO64_UAP(fd);
1549 	NETBSD32TO64_UAP(PAD);
1550 	NETBSD32TO64_UAP(offset);
1551 	NETBSD32TO64_UAP(whence);
1552 	rv = sys_lseek(l, &ua, newpos.retval64);
1553 
1554 	/*
1555 	 * We have to split the 64 bit value into 2 halves which will
1556 	 * end up in separate 32 bit registers.
1557 	 * This should DTRT on big and little-endian systems provided that
1558 	 * gcc's 'strict aliasing' tests don't decide that the retval32[]
1559 	 * entries can't have been assigned to, so need not be read!
1560 	 */
1561 	retval[0] = newpos.retval32[0];
1562 	retval[1] = newpos.retval32[1];
1563 
1564 	return rv;
1565 }
1566 
1567 int
1568 netbsd32_truncate(struct lwp *l, const struct netbsd32_truncate_args *uap, register_t *retval)
1569 {
1570 	/* {
1571 		syscallarg(const netbsd32_charp) path;
1572 		syscallarg(int) PAD;
1573 		syscallarg(off_t) length;
1574 	} */
1575 	struct sys_truncate_args ua;
1576 
1577 	NETBSD32TOP_UAP(path, const char);
1578 	NETBSD32TO64_UAP(PAD);
1579 	NETBSD32TO64_UAP(length);
1580 	return (sys_truncate(l, &ua, retval));
1581 }
1582 
1583 int
1584 netbsd32_ftruncate(struct lwp *l, const struct netbsd32_ftruncate_args *uap, register_t *retval)
1585 {
1586 	/* {
1587 		syscallarg(int) fd;
1588 		syscallarg(int) PAD;
1589 		syscallarg(off_t) length;
1590 	} */
1591 	struct sys_ftruncate_args ua;
1592 
1593 	NETBSD32TO64_UAP(fd);
1594 	NETBSD32TO64_UAP(PAD);
1595 	NETBSD32TO64_UAP(length);
1596 	return (sys_ftruncate(l, &ua, retval));
1597 }
1598 
1599 int
1600 netbsd32_mlock(struct lwp *l, const struct netbsd32_mlock_args *uap, register_t *retval)
1601 {
1602 	/* {
1603 		syscallarg(const netbsd32_voidp) addr;
1604 		syscallarg(netbsd32_size_t) len;
1605 	} */
1606 	struct sys_mlock_args ua;
1607 
1608 	NETBSD32TOP_UAP(addr, const void);
1609 	NETBSD32TO64_UAP(len);
1610 	return (sys_mlock(l, &ua, retval));
1611 }
1612 
1613 int
1614 netbsd32_munlock(struct lwp *l, const struct netbsd32_munlock_args *uap, register_t *retval)
1615 {
1616 	/* {
1617 		syscallarg(const netbsd32_voidp) addr;
1618 		syscallarg(netbsd32_size_t) len;
1619 	} */
1620 	struct sys_munlock_args ua;
1621 
1622 	NETBSD32TOP_UAP(addr, const void);
1623 	NETBSD32TO64_UAP(len);
1624 	return (sys_munlock(l, &ua, retval));
1625 }
1626 
1627 int
1628 netbsd32_undelete(struct lwp *l, const struct netbsd32_undelete_args *uap, register_t *retval)
1629 {
1630 	/* {
1631 		syscallarg(const netbsd32_charp) path;
1632 	} */
1633 	struct sys_undelete_args ua;
1634 
1635 	NETBSD32TOP_UAP(path, const char);
1636 	return (sys_undelete(l, &ua, retval));
1637 }
1638 
1639 int
1640 netbsd32_getpgid(struct lwp *l, const struct netbsd32_getpgid_args *uap, register_t *retval)
1641 {
1642 	/* {
1643 		syscallarg(pid_t) pid;
1644 	} */
1645 	struct sys_getpgid_args ua;
1646 
1647 	NETBSD32TO64_UAP(pid);
1648 	return (sys_getpgid(l, &ua, retval));
1649 }
1650 
1651 int
1652 netbsd32_reboot(struct lwp *l, const struct netbsd32_reboot_args *uap, register_t *retval)
1653 {
1654 	/* {
1655 		syscallarg(int) opt;
1656 		syscallarg(netbsd32_charp) bootstr;
1657 	} */
1658 	struct sys_reboot_args ua;
1659 
1660 	NETBSD32TO64_UAP(opt);
1661 	NETBSD32TOP_UAP(bootstr, char);
1662 	return (sys_reboot(l, &ua, retval));
1663 }
1664 
1665 #include <sys/poll.h>
1666 int
1667 netbsd32_poll(struct lwp *l, const struct netbsd32_poll_args *uap, register_t *retval)
1668 {
1669 	/* {
1670 		syscallarg(netbsd32_pollfdp_t) fds;
1671 		syscallarg(u_int) nfds;
1672 		syscallarg(int) timeout;
1673 	} */
1674 	struct sys_poll_args ua;
1675 
1676 	NETBSD32TOP_UAP(fds, struct pollfd);
1677 	NETBSD32TO64_UAP(nfds);
1678 	NETBSD32TO64_UAP(timeout);
1679 
1680 	return (sys_poll(l, &ua, retval));
1681 }
1682 
1683 int
1684 netbsd32_fdatasync(struct lwp *l, const struct netbsd32_fdatasync_args *uap, register_t *retval)
1685 {
1686 	/* {
1687 		syscallarg(int) fd;
1688 	} */
1689 	struct sys_fdatasync_args ua;
1690 
1691 	NETBSD32TO64_UAP(fd);
1692 	return (sys_fdatasync(l, &ua, retval));
1693 }
1694 
1695 int
1696 netbsd32___posix_rename(struct lwp *l, const struct netbsd32___posix_rename_args *uap, register_t *retval)
1697 {
1698 	/* {
1699 		syscallarg(const netbsd32_charp) from;
1700 		syscallarg(const netbsd32_charp) to;
1701 	} */
1702 	struct sys___posix_rename_args ua;
1703 
1704 	NETBSD32TOP_UAP(from, const char);
1705 	NETBSD32TOP_UAP(to, const char);
1706 	return (sys___posix_rename(l, &ua, retval));
1707 }
1708 
1709 int
1710 netbsd32_swapctl(struct lwp *l, const struct netbsd32_swapctl_args *uap, register_t *retval)
1711 {
1712 	/* {
1713 		syscallarg(int) cmd;
1714 		syscallarg(const netbsd32_voidp) arg;
1715 		syscallarg(int) misc;
1716 	} */
1717 	struct sys_swapctl_args ua;
1718 
1719 	NETBSD32TO64_UAP(cmd);
1720 	NETBSD32TOP_UAP(arg, void);
1721 	NETBSD32TO64_UAP(misc);
1722 	return (sys_swapctl(l, &ua, retval));
1723 }
1724 
1725 int
1726 netbsd32_minherit(struct lwp *l, const struct netbsd32_minherit_args *uap, register_t *retval)
1727 {
1728 	/* {
1729 		syscallarg(netbsd32_voidp) addr;
1730 		syscallarg(netbsd32_size_t) len;
1731 		syscallarg(int) inherit;
1732 	} */
1733 	struct sys_minherit_args ua;
1734 
1735 	NETBSD32TOP_UAP(addr, void);
1736 	NETBSD32TOX_UAP(len, size_t);
1737 	NETBSD32TO64_UAP(inherit);
1738 	return (sys_minherit(l, &ua, retval));
1739 }
1740 
1741 int
1742 netbsd32_lchmod(struct lwp *l, const struct netbsd32_lchmod_args *uap, register_t *retval)
1743 {
1744 	/* {
1745 		syscallarg(const netbsd32_charp) path;
1746 		syscallarg(mode_t) mode;
1747 	} */
1748 	struct sys_lchmod_args ua;
1749 
1750 	NETBSD32TOP_UAP(path, const char);
1751 	NETBSD32TO64_UAP(mode);
1752 	return (sys_lchmod(l, &ua, retval));
1753 }
1754 
1755 int
1756 netbsd32_lchown(struct lwp *l, const struct netbsd32_lchown_args *uap, register_t *retval)
1757 {
1758 	/* {
1759 		syscallarg(const netbsd32_charp) path;
1760 		syscallarg(uid_t) uid;
1761 		syscallarg(gid_t) gid;
1762 	} */
1763 	struct sys_lchown_args ua;
1764 
1765 	NETBSD32TOP_UAP(path, const char);
1766 	NETBSD32TO64_UAP(uid);
1767 	NETBSD32TO64_UAP(gid);
1768 	return (sys_lchown(l, &ua, retval));
1769 }
1770 
1771 int
1772 netbsd32___msync13(struct lwp *l, const struct netbsd32___msync13_args *uap, register_t *retval)
1773 {
1774 	/* {
1775 		syscallarg(netbsd32_voidp) addr;
1776 		syscallarg(netbsd32_size_t) len;
1777 		syscallarg(int) flags;
1778 	} */
1779 	struct sys___msync13_args ua;
1780 
1781 	NETBSD32TOP_UAP(addr, void);
1782 	NETBSD32TOX_UAP(len, size_t);
1783 	NETBSD32TO64_UAP(flags);
1784 	return (sys___msync13(l, &ua, retval));
1785 }
1786 
1787 int
1788 netbsd32___posix_chown(struct lwp *l, const struct netbsd32___posix_chown_args *uap, register_t *retval)
1789 {
1790 	/* {
1791 		syscallarg(const netbsd32_charp) path;
1792 		syscallarg(uid_t) uid;
1793 		syscallarg(gid_t) gid;
1794 	} */
1795 	struct sys___posix_chown_args ua;
1796 
1797 	NETBSD32TOP_UAP(path, const char);
1798 	NETBSD32TO64_UAP(uid);
1799 	NETBSD32TO64_UAP(gid);
1800 	return (sys___posix_chown(l, &ua, retval));
1801 }
1802 
1803 int
1804 netbsd32___posix_fchown(struct lwp *l, const struct netbsd32___posix_fchown_args *uap, register_t *retval)
1805 {
1806 	/* {
1807 		syscallarg(int) fd;
1808 		syscallarg(uid_t) uid;
1809 		syscallarg(gid_t) gid;
1810 	} */
1811 	struct sys___posix_fchown_args ua;
1812 
1813 	NETBSD32TO64_UAP(fd);
1814 	NETBSD32TO64_UAP(uid);
1815 	NETBSD32TO64_UAP(gid);
1816 	return (sys___posix_fchown(l, &ua, retval));
1817 }
1818 
1819 int
1820 netbsd32___posix_lchown(struct lwp *l, const struct netbsd32___posix_lchown_args *uap, register_t *retval)
1821 {
1822 	/* {
1823 		syscallarg(const netbsd32_charp) path;
1824 		syscallarg(uid_t) uid;
1825 		syscallarg(gid_t) gid;
1826 	} */
1827 	struct sys___posix_lchown_args ua;
1828 
1829 	NETBSD32TOP_UAP(path, const char);
1830 	NETBSD32TO64_UAP(uid);
1831 	NETBSD32TO64_UAP(gid);
1832 	return (sys___posix_lchown(l, &ua, retval));
1833 }
1834 
1835 int
1836 netbsd32_getsid(struct lwp *l, const struct netbsd32_getsid_args *uap, register_t *retval)
1837 {
1838 	/* {
1839 		syscallarg(pid_t) pid;
1840 	} */
1841 	struct sys_getsid_args ua;
1842 
1843 	NETBSD32TO64_UAP(pid);
1844 	return (sys_getsid(l, &ua, retval));
1845 }
1846 
1847 int
1848 netbsd32_fktrace(struct lwp *l, const struct netbsd32_fktrace_args *uap, register_t *retval)
1849 {
1850 	/* {
1851 		syscallarg(int) fd;
1852 		syscallarg(int) ops;
1853 		syscallarg(int) facs;
1854 		syscallarg(int) pid;
1855 	} */
1856 	struct sys_fktrace_args ua;
1857 
1858 	NETBSD32TOX_UAP(fd, int);
1859 	NETBSD32TO64_UAP(ops);
1860 	NETBSD32TO64_UAP(facs);
1861 	NETBSD32TO64_UAP(pid);
1862 	return (sys_fktrace(l, &ua, retval));
1863 }
1864 
1865 int
1866 netbsd32___sigpending14(struct lwp *l, const struct netbsd32___sigpending14_args *uap, register_t *retval)
1867 {
1868 	/* {
1869 		syscallarg(sigset_t *) set;
1870 	} */
1871 	struct sys___sigpending14_args ua;
1872 
1873 	NETBSD32TOP_UAP(set, sigset_t);
1874 	return (sys___sigpending14(l, &ua, retval));
1875 }
1876 
1877 int
1878 netbsd32___sigprocmask14(struct lwp *l, const struct netbsd32___sigprocmask14_args *uap, register_t *retval)
1879 {
1880 	/* {
1881 		syscallarg(int) how;
1882 		syscallarg(const sigset_t *) set;
1883 		syscallarg(sigset_t *) oset;
1884 	} */
1885 	struct sys___sigprocmask14_args ua;
1886 
1887 	NETBSD32TO64_UAP(how);
1888 	NETBSD32TOP_UAP(set, sigset_t);
1889 	NETBSD32TOP_UAP(oset, sigset_t);
1890 	return (sys___sigprocmask14(l, &ua, retval));
1891 }
1892 
1893 int
1894 netbsd32___sigsuspend14(struct lwp *l, const struct netbsd32___sigsuspend14_args *uap, register_t *retval)
1895 {
1896 	/* {
1897 		syscallarg(const sigset_t *) set;
1898 	} */
1899 	struct sys___sigsuspend14_args ua;
1900 
1901 	NETBSD32TOP_UAP(set, sigset_t);
1902 	return (sys___sigsuspend14(l, &ua, retval));
1903 };
1904 
1905 int
1906 netbsd32_fchroot(struct lwp *l, const struct netbsd32_fchroot_args *uap, register_t *retval)
1907 {
1908 	/* {
1909 		syscallarg(int) fd;
1910 	} */
1911 	struct sys_fchroot_args ua;
1912 
1913 	NETBSD32TO64_UAP(fd);
1914 	return (sys_fchroot(l, &ua, retval));
1915 }
1916 
1917 /*
1918  * Open a file given a file handle.
1919  *
1920  * Check permissions, allocate an open file structure,
1921  * and call the device open routine if any.
1922  */
1923 int
1924 netbsd32___fhopen40(struct lwp *l, const struct netbsd32___fhopen40_args *uap, register_t *retval)
1925 {
1926 	/* {
1927 		syscallarg(const netbsd32_pointer_t *) fhp;
1928 		syscallarg(netbsd32_size_t) fh_size;
1929 		syscallarg(int) flags;
1930 	} */
1931 	struct sys___fhopen40_args ua;
1932 
1933 	NETBSD32TOP_UAP(fhp, fhandle_t);
1934 	NETBSD32TO64_UAP(fh_size);
1935 	NETBSD32TO64_UAP(flags);
1936 	return (sys___fhopen40(l, &ua, retval));
1937 }
1938 
1939 /* virtual memory syscalls */
1940 int
1941 netbsd32_ovadvise(struct lwp *l, const struct netbsd32_ovadvise_args *uap, register_t *retval)
1942 {
1943 	/* {
1944 		syscallarg(int) anom;
1945 	} */
1946 	struct sys_ovadvise_args ua;
1947 
1948 	NETBSD32TO64_UAP(anom);
1949 	return (sys_ovadvise(l, &ua, retval));
1950 }
1951 
1952 void
1953 netbsd32_adjust_limits(struct proc *p)
1954 {
1955 	static const struct {
1956 		int id;
1957 		rlim_t lim;
1958 	} lm[] = {
1959 		{ RLIMIT_DATA,	MAXDSIZ32 },
1960 		{ RLIMIT_STACK, MAXSSIZ32 },
1961 	};
1962 	size_t i;
1963 	struct plimit *lim;
1964 	struct rlimit *rlim;
1965 
1966 	/*
1967 	 * We can only reduce the current limits, we cannot stop external
1968 	 * processes from changing them (eg via sysctl) later on.
1969 	 * So there is no point trying to lock out such changes here.
1970 	 *
1971 	 * If we assume that rlim_cur/max are accessed using atomic
1972 	 * operations, we don't need to lock against any other updates
1973 	 * that might happen if the plimit structure is shared writable
1974 	 * between multiple processes.
1975 	 */
1976 
1977 	/* Scan to determine is any limits are out of range */
1978 	lim = p->p_limit;
1979 	for (i = 0; ; i++) {
1980 		if (i >= __arraycount(lm))
1981 			/* All in range */
1982 			return;
1983 		rlim = lim->pl_rlimit + lm[i].id;
1984 		if (LIMITCHECK(rlim->rlim_cur, lm[i].lim))
1985 			break;
1986 		if (LIMITCHECK(rlim->rlim_max, lm[i].lim))
1987 			break;
1988 	}
1989 
1990 	lim_privatise(p, false);
1991 
1992 	lim = p->p_limit;
1993 	for (i = 0; i < __arraycount(lm); i++) {
1994 		rlim = lim->pl_rlimit + lm[i].id;
1995 		if (LIMITCHECK(rlim->rlim_cur, lm[i].lim))
1996 			rlim->rlim_cur = lm[i].lim;
1997 		if (LIMITCHECK(rlim->rlim_max, lm[i].lim))
1998 			rlim->rlim_max = lm[i].lim;
1999 	}
2000 }
2001 
2002 int
2003 netbsd32_uuidgen(struct lwp *l, const struct netbsd32_uuidgen_args *uap, register_t *retval)
2004 {
2005 	/* {
2006 		syscallarg(netbsd32_uuidp_t) store;
2007 		syscallarg(int) count;
2008 	} */
2009 	struct sys_uuidgen_args ua;
2010 
2011 	NETBSD32TOP_UAP(store, struct uuid);
2012 	NETBSD32TO64_UAP(count);
2013 	return (sys_uuidgen(l, &ua, retval));
2014 }
2015 
2016 int
2017 netbsd32_extattrctl(struct lwp *l, const struct netbsd32_extattrctl_args *uap, register_t *retval)
2018 {
2019 	/* {
2020 		syscallarg(const netbsd32_charp) path;
2021 		syscallarg(int) cmd;
2022 		syscallarg(const netbsd32_charp) filename;
2023 		syscallarg(int) attrnamespace;
2024 		syscallarg(const netbsd32_charp) attrname;
2025 	} */
2026 	struct sys_extattrctl_args ua;
2027 
2028 	NETBSD32TOP_UAP(path, const char);
2029 	NETBSD32TO64_UAP(cmd);
2030 	NETBSD32TOP_UAP(filename, const char);
2031 	NETBSD32TO64_UAP(attrnamespace);
2032 	NETBSD32TOP_UAP(attrname, const char);
2033 	return sys_extattrctl(l, &ua, retval);
2034 }
2035 
2036 int
2037 netbsd32_extattr_set_fd(struct lwp *l, const struct netbsd32_extattr_set_fd_args *uap, register_t *retval)
2038 {
2039 	/* {
2040 		syscallarg(int) fd;
2041 		syscallarg(int) attrnamespace;
2042 		syscallarg(const netbsd32_charp) attrname;
2043 		syscallarg(const netbsd32_voidp) data;
2044 		syscallarg(netbsd32_size_t) nbytes;
2045 	} */
2046 	struct sys_extattr_set_fd_args ua;
2047 
2048 	NETBSD32TO64_UAP(fd);
2049 	NETBSD32TO64_UAP(attrnamespace);
2050 	NETBSD32TOP_UAP(attrname, const char);
2051 	NETBSD32TOP_UAP(data, const void);
2052 	NETBSD32TOX_UAP(nbytes, size_t);
2053 	return sys_extattr_set_fd(l, &ua, retval);
2054 }
2055 
2056 int
2057 netbsd32_extattr_set_file(struct lwp *l, const struct netbsd32_extattr_set_file_args *uap, register_t *retval)
2058 {
2059 	/* {
2060 		syscallarg(const netbsd32_charp) path;
2061 		syscallarg(int) attrnamespace;
2062 		syscallarg(const netbsd32_charp) attrname;
2063 		syscallarg(const netbsd32_voidp) data;
2064 		syscallarg(netbsd32_size_t) nbytes;
2065 	} */
2066 	struct sys_extattr_set_file_args ua;
2067 
2068 	NETBSD32TOP_UAP(path, const char);
2069 	NETBSD32TO64_UAP(attrnamespace);
2070 	NETBSD32TOP_UAP(attrname, const char);
2071 	NETBSD32TOP_UAP(data, const void);
2072 	NETBSD32TOX_UAP(nbytes, size_t);
2073 	return sys_extattr_set_file(l, &ua, retval);
2074 }
2075 
2076 int
2077 netbsd32_extattr_set_link(struct lwp *l, const struct netbsd32_extattr_set_link_args *uap, register_t *retval)
2078 {
2079 	/* {
2080 		syscallarg(const netbsd32_charp) path;
2081 		syscallarg(int) attrnamespace;
2082 		syscallarg(const netbsd32_charp) attrname;
2083 		syscallarg(const netbsd32_voidp) data;
2084 		syscallarg(netbsd32_size_t) nbytes;
2085 	} */
2086 	struct sys_extattr_set_link_args ua;
2087 
2088 	NETBSD32TOP_UAP(path, const char);
2089 	NETBSD32TO64_UAP(attrnamespace);
2090 	NETBSD32TOP_UAP(attrname, const char);
2091 	NETBSD32TOP_UAP(data, const void);
2092 	NETBSD32TOX_UAP(nbytes, size_t);
2093 	return sys_extattr_set_link(l, &ua, retval);
2094 }
2095 
2096 int
2097 netbsd32_extattr_get_fd(struct lwp *l, const struct netbsd32_extattr_get_fd_args *uap, register_t *retval)
2098 {
2099 	/* {
2100 		syscallarg(int) fd;
2101 		syscallarg(int) attrnamespace;
2102 		syscallarg(const netbsd32_charp) attrname;
2103 		syscallarg(netbsd32_voidp) data;
2104 		syscallarg(netbsd32_size_t) nbytes;
2105 	} */
2106 	struct sys_extattr_get_fd_args ua;
2107 
2108 	NETBSD32TO64_UAP(fd);
2109 	NETBSD32TO64_UAP(attrnamespace);
2110 	NETBSD32TOP_UAP(attrname, const char);
2111 	NETBSD32TOP_UAP(data, void);
2112 	NETBSD32TOX_UAP(nbytes, size_t);
2113 	return sys_extattr_get_fd(l, &ua, retval);
2114 }
2115 
2116 int
2117 netbsd32_extattr_get_file(struct lwp *l, const struct netbsd32_extattr_get_file_args *uap, register_t *retval)
2118 {
2119 	/* {
2120 		syscallarg(const netbsd32_charp) path;
2121 		syscallarg(int) attrnamespace;
2122 		syscallarg(const netbsd32_charp) attrname;
2123 		syscallarg(netbsd32_voidp) data;
2124 		syscallarg(netbsd32_size_t) nbytes;
2125 	} */
2126 	struct sys_extattr_get_file_args ua;
2127 
2128 	NETBSD32TOP_UAP(path, const char);
2129 	NETBSD32TO64_UAP(attrnamespace);
2130 	NETBSD32TOP_UAP(attrname, const char);
2131 	NETBSD32TOP_UAP(data, void);
2132 	NETBSD32TOX_UAP(nbytes, size_t);
2133 	return sys_extattr_get_file(l, &ua, retval);
2134 }
2135 
2136 int
2137 netbsd32_extattr_get_link(struct lwp *l, const struct netbsd32_extattr_get_link_args *uap, register_t *retval)
2138 {
2139 	/* {
2140 		syscallarg(const netbsd32_charp) path;
2141 		syscallarg(int) attrnamespace;
2142 		syscallarg(const netbsd32_charp) attrname;
2143 		syscallarg(netbsd32_voidp) data;
2144 		syscallarg(netbsd32_size_t) nbytes;
2145 	} */
2146 	struct sys_extattr_get_link_args ua;
2147 
2148 	NETBSD32TOP_UAP(path, const char);
2149 	NETBSD32TO64_UAP(attrnamespace);
2150 	NETBSD32TOP_UAP(attrname, const char);
2151 	NETBSD32TOP_UAP(data, void);
2152 	NETBSD32TOX_UAP(nbytes, size_t);
2153 	return sys_extattr_get_link(l, &ua, retval);
2154 }
2155 
2156 int
2157 netbsd32_extattr_delete_fd(struct lwp *l, const struct netbsd32_extattr_delete_fd_args *uap, register_t *retval)
2158 {
2159 	/* {
2160 		syscallarg(int) fd;
2161 		syscallarg(int) attrnamespace;
2162 		syscallarg(const netbsd32_charp) attrname;
2163 	} */
2164 	struct sys_extattr_delete_fd_args ua;
2165 
2166 	NETBSD32TO64_UAP(fd);
2167 	NETBSD32TO64_UAP(attrnamespace);
2168 	NETBSD32TOP_UAP(attrname, const char);
2169 	return sys_extattr_delete_fd(l, &ua, retval);
2170 }
2171 
2172 int
2173 netbsd32_extattr_delete_file(struct lwp *l, const struct netbsd32_extattr_delete_file_args *uap, register_t *retval)
2174 {
2175 	/* {
2176 		syscallarg(const netbsd32_charp) path;
2177 		syscallarg(int) attrnamespace;
2178 		syscallarg(const netbsd32_charp) attrname;
2179 	} */
2180 	struct sys_extattr_delete_file_args ua;
2181 
2182 	NETBSD32TOP_UAP(path, const char);
2183 	NETBSD32TO64_UAP(attrnamespace);
2184 	NETBSD32TOP_UAP(attrname, const char);
2185 	return sys_extattr_delete_file(l, &ua, retval);
2186 }
2187 
2188 int
2189 netbsd32_extattr_delete_link(struct lwp *l, const struct netbsd32_extattr_delete_link_args *uap, register_t *retval)
2190 {
2191 	/* {
2192 		syscallarg(const netbsd32_charp) path;
2193 		syscallarg(int) attrnamespace;
2194 		syscallarg(const netbsd32_charp) attrname;
2195 	} */
2196 	struct sys_extattr_delete_link_args ua;
2197 
2198 	NETBSD32TOP_UAP(path, const char);
2199 	NETBSD32TO64_UAP(attrnamespace);
2200 	NETBSD32TOP_UAP(attrname, const char);
2201 	return sys_extattr_delete_link(l, &ua, retval);
2202 }
2203 
2204 int
2205 netbsd32_extattr_list_fd(struct lwp *l, const struct netbsd32_extattr_list_fd_args *uap, register_t *retval)
2206 {
2207 	/* {
2208 		syscallarg(int) fd;
2209 		syscallarg(int) attrnamespace;
2210 		syscallarg(netbsd32_voidp) data;
2211 		syscallarg(netbsd32_size_t) nbytes;
2212 	} */
2213 	struct sys_extattr_list_fd_args ua;
2214 
2215 	NETBSD32TO64_UAP(fd);
2216 	NETBSD32TO64_UAP(attrnamespace);
2217 	NETBSD32TOP_UAP(data, void);
2218 	NETBSD32TOX_UAP(nbytes, size_t);
2219 	return sys_extattr_list_fd(l, &ua, retval);
2220 }
2221 
2222 int
2223 netbsd32_extattr_list_file(struct lwp *l, const struct netbsd32_extattr_list_file_args *uap, register_t *retval)
2224 {
2225 	/* {
2226 		syscallarg(const netbsd32_charp) path;
2227 		syscallarg(int) attrnamespace;
2228 		syscallarg(netbsd32_voidp) data;
2229 		syscallarg(netbsd32_size_t) nbytes;
2230 	} */
2231 	struct sys_extattr_list_file_args ua;
2232 
2233 	NETBSD32TOP_UAP(path, const char);
2234 	NETBSD32TO64_UAP(attrnamespace);
2235 	NETBSD32TOP_UAP(data, void);
2236 	NETBSD32TOX_UAP(nbytes, size_t);
2237 	return sys_extattr_list_file(l, &ua, retval);
2238 }
2239 
2240 int
2241 netbsd32_extattr_list_link(struct lwp *l, const struct netbsd32_extattr_list_link_args *uap, register_t *retval)
2242 {
2243 	/* {
2244 		syscallarg(const netbsd32_charp) path;
2245 		syscallarg(int) attrnamespace;
2246 		syscallarg(netbsd32_voidp) data;
2247 		syscallarg(netbsd32_size_t) nbytes;
2248 	} */
2249 	struct sys_extattr_list_link_args ua;
2250 
2251 	NETBSD32TOP_UAP(path, const char);
2252 	NETBSD32TO64_UAP(attrnamespace);
2253 	NETBSD32TOP_UAP(data, void);
2254 	NETBSD32TOX_UAP(nbytes, size_t);
2255 	return sys_extattr_list_link(l, &ua, retval);
2256 }
2257 
2258 int
2259 netbsd32_mlockall(struct lwp *l, const struct netbsd32_mlockall_args *uap, register_t *retval)
2260 {
2261 	/* {
2262 		syscallarg(int) flags;
2263 	} */
2264 	struct sys_mlockall_args ua;
2265 
2266 	NETBSD32TO64_UAP(flags);
2267 	return (sys_mlockall(l, &ua, retval));
2268 }
2269 
2270 int
2271 netbsd32___clone(struct lwp *l, const struct netbsd32___clone_args *uap, register_t *retval)
2272 {
2273 	/*  {
2274 		syscallarg(int) flags;
2275 		syscallarg(netbsd32_voidp) stack;
2276 	} */
2277 	struct sys___clone_args ua;
2278 
2279 	NETBSD32TO64_UAP(flags);
2280 	NETBSD32TOP_UAP(stack, void);
2281 	return sys___clone(l, &ua, retval);
2282 }
2283 
2284 int
2285 netbsd32_fsync_range(struct lwp *l, const struct netbsd32_fsync_range_args *uap, register_t *retval)
2286 {
2287 	/* {
2288 		syscallarg(int) fd;
2289 		syscallarg(int) flags;
2290 		syscallarg(off_t) start;
2291 		syscallarg(off_t) length;
2292 	} */
2293 	struct sys_fsync_range_args ua;
2294 
2295 	NETBSD32TO64_UAP(fd);
2296 	NETBSD32TO64_UAP(flags);
2297 	NETBSD32TO64_UAP(start);
2298 	NETBSD32TO64_UAP(length);
2299 	return (sys_fsync_range(l, &ua, retval));
2300 }
2301 
2302 int
2303 netbsd32_rasctl(struct lwp *l, const struct netbsd32_rasctl_args *uap, register_t *retval)
2304 {
2305 	/* {
2306 		syscallarg(netbsd32_voidp) addr;
2307 		syscallarg(netbsd32_size_t) len;
2308 		syscallarg(int) op;
2309 	} */
2310 	struct sys_rasctl_args ua;
2311 
2312 	NETBSD32TOP_UAP(addr, void *);
2313 	NETBSD32TOX_UAP(len, size_t);
2314 	NETBSD32TO64_UAP(op);
2315 	return sys_rasctl(l, &ua, retval);
2316 }
2317 
2318 int
2319 netbsd32_setxattr(struct lwp *l, const struct netbsd32_setxattr_args *uap, register_t *retval)
2320 {
2321 	/* {
2322 		syscallarg(const netbsd32_charp) path;
2323 		syscallarg(const netbsd32_charp) name;
2324 		syscallarg(netbsd32_voidp) value;
2325 		syscallarg(netbsd32_size_t) size;
2326 		syscallarg(int) flags;
2327 	} */
2328 	struct sys_setxattr_args ua;
2329 	NETBSD32TOP_UAP(path, const char);
2330 	NETBSD32TOP_UAP(name, const char);
2331 	NETBSD32TOP_UAP(value, void);
2332 	NETBSD32TOX_UAP(size, size_t);
2333 	NETBSD32TO64_UAP(flags);
2334 	return sys_setxattr(l, &ua, retval);
2335 }
2336 
2337 int
2338 netbsd32_lsetxattr(struct lwp *l, const struct netbsd32_lsetxattr_args *uap, register_t *retval)
2339 {
2340 	/* {
2341 		syscallarg(const netbsd32_charp) path;
2342 		syscallarg(const netbsd32_charp) name;
2343 		syscallarg(netbsd32_voidp) value;
2344 		syscallarg(netbsd32_size_t) size;
2345 		syscallarg(int) flags;
2346 	} */
2347 	struct sys_lsetxattr_args ua;
2348 	NETBSD32TOP_UAP(path, const char);
2349 	NETBSD32TOP_UAP(name, const char);
2350 	NETBSD32TOP_UAP(value, void);
2351 	NETBSD32TOX_UAP(size, size_t);
2352 	NETBSD32TO64_UAP(flags);
2353 	return sys_lsetxattr(l, &ua, retval);
2354 }
2355 
2356 int
2357 netbsd32_fsetxattr(struct lwp *l, const struct netbsd32_fsetxattr_args *uap, register_t *retval)
2358 {
2359 	/* {
2360 		syscallarg(int) fd;
2361 		syscallarg(const netbsd32_charp) name;
2362 		syscallarg(netbsd32_voidp) value;
2363 		syscallarg(netbsd32_size_t) size;
2364 		syscallarg(int) flags;
2365 	} */
2366 	struct sys_fsetxattr_args ua;
2367 	NETBSD32TO64_UAP(fd);
2368 	NETBSD32TOP_UAP(name, const char);
2369 	NETBSD32TOP_UAP(value, void);
2370 	NETBSD32TOX_UAP(size, size_t);
2371 	NETBSD32TO64_UAP(flags);
2372 	return sys_fsetxattr(l, &ua, retval);
2373 }
2374 
2375 int
2376 netbsd32_getxattr(struct lwp *l, const struct netbsd32_getxattr_args *uap, register_t *retval)
2377 {
2378 	/* {
2379 		syscallarg(const netbsd32_charp) path;
2380 		syscallarg(const netbsd32_charp) name;
2381 		syscallarg(netbsd32_voidp) value;
2382 		syscallarg(netbsd32_size_t) size;
2383 	} */
2384 	struct sys_getxattr_args ua;
2385 	NETBSD32TOP_UAP(path, const char);
2386 	NETBSD32TOP_UAP(name, const char);
2387 	NETBSD32TOP_UAP(value, void);
2388 	NETBSD32TOX_UAP(size, size_t);
2389 	return sys_getxattr(l, &ua, retval);
2390 }
2391 
2392 int
2393 netbsd32_lgetxattr(struct lwp *l, const struct netbsd32_lgetxattr_args *uap, register_t *retval)
2394 {
2395 	/* {
2396 		syscallarg(const netbsd32_charp) path;
2397 		syscallarg(const netbsd32_charp) name;
2398 		syscallarg(netbsd32_voidp) value;
2399 		syscallarg(netbsd32_size_t) size;
2400 	} */
2401 	struct sys_lgetxattr_args ua;
2402 	NETBSD32TOP_UAP(path, const char);
2403 	NETBSD32TOP_UAP(name, const char);
2404 	NETBSD32TOP_UAP(value, void);
2405 	NETBSD32TOX_UAP(size, size_t);
2406 	return sys_lgetxattr(l, &ua, retval);
2407 }
2408 
2409 int
2410 netbsd32_fgetxattr(struct lwp *l, const struct netbsd32_fgetxattr_args *uap, register_t *retval)
2411 {
2412 	/* {
2413 		syscallarg(int) fd;
2414 		syscallarg(const netbsd32_charp) name;
2415 		syscallarg(netbsd32_voidp) value;
2416 		syscallarg(netbsd32_size_t) size;
2417 	} */
2418 	struct sys_fgetxattr_args ua;
2419 	NETBSD32TO64_UAP(fd);
2420 	NETBSD32TOP_UAP(name, const char);
2421 	NETBSD32TOP_UAP(value, void);
2422 	NETBSD32TOX_UAP(size, size_t);
2423 	return sys_fgetxattr(l, &ua, retval);
2424 }
2425 
2426 int
2427 netbsd32_listxattr(struct lwp *l, const struct netbsd32_listxattr_args *uap, register_t *retval)
2428 {
2429 	/* {
2430 		syscallarg(const netbsd32_charp) path;
2431 		syscallarg(netbsd32_charp) list;
2432 		syscallarg(netbsd32_size_t) size;
2433 	} */
2434 	struct sys_listxattr_args ua;
2435 	NETBSD32TOP_UAP(path, const char);
2436 	NETBSD32TOP_UAP(list, char);
2437 	NETBSD32TOX_UAP(size, size_t);
2438 	return sys_listxattr(l, &ua, retval);
2439 }
2440 
2441 int
2442 netbsd32_llistxattr(struct lwp *l, const struct netbsd32_llistxattr_args *uap, register_t *retval)
2443 {
2444 	/* {
2445 		syscallarg(const netbsd32_charp) path;
2446 		syscallarg(netbsd32_charp) list;
2447 		syscallarg(netbsd32_size_t) size;
2448 	} */
2449 	struct sys_llistxattr_args ua;
2450 	NETBSD32TOP_UAP(path, const char);
2451 	NETBSD32TOP_UAP(list, char);
2452 	NETBSD32TOX_UAP(size, size_t);
2453 	return sys_llistxattr(l, &ua, retval);
2454 }
2455 
2456 int
2457 netbsd32_flistxattr(struct lwp *l, const struct netbsd32_flistxattr_args *uap, register_t *retval)
2458 {
2459 	/* {
2460 		syscallarg(int) fd;
2461 		syscallarg(netbsd32_charp) list;
2462 		syscallarg(netbsd32_size_t) size;
2463 	} */
2464 	struct sys_flistxattr_args ua;
2465 	NETBSD32TO64_UAP(fd);
2466 	NETBSD32TOP_UAP(list, char);
2467 	NETBSD32TOX_UAP(size, size_t);
2468 	return sys_flistxattr(l, &ua, retval);
2469 }
2470 
2471 int
2472 netbsd32_removexattr(struct lwp *l, const struct netbsd32_removexattr_args *uap, register_t *retval)
2473 {
2474 	/* {
2475 		syscallarg(const netbsd32_charp) path;
2476 		syscallarg(const netbsd32_charp) name;
2477 	} */
2478 	struct sys_removexattr_args ua;
2479 	NETBSD32TOP_UAP(path, const char);
2480 	NETBSD32TOP_UAP(name, const char);
2481 	return sys_removexattr(l, &ua, retval);
2482 }
2483 
2484 int
2485 netbsd32_lremovexattr(struct lwp *l, const struct netbsd32_lremovexattr_args *uap, register_t *retval)
2486 {
2487 	/* {
2488 		syscallarg(const netbsd32_charp) path;
2489 		syscallarg(const netbsd32_charp) name;
2490 	} */
2491 	struct sys_lremovexattr_args ua;
2492 	NETBSD32TOP_UAP(path, const char);
2493 	NETBSD32TOP_UAP(name, const char);
2494 	return sys_lremovexattr(l, &ua, retval);
2495 }
2496 
2497 int
2498 netbsd32_fremovexattr(struct lwp *l, const struct netbsd32_fremovexattr_args *uap, register_t *retval)
2499 {
2500 	/* {
2501 		syscallarg(int) fd;
2502 		syscallarg(const netbsd32_charp) name;
2503 	} */
2504 	struct sys_fremovexattr_args ua;
2505 	NETBSD32TO64_UAP(fd);
2506 	NETBSD32TOP_UAP(name, const char);
2507 	return sys_fremovexattr(l, &ua, retval);
2508 }
2509 
2510 int
2511 netbsd32___posix_fadvise50(struct lwp *l,
2512 	const struct netbsd32___posix_fadvise50_args *uap, register_t *retval)
2513 {
2514 	/* {
2515 		syscallarg(int) fd;
2516 		syscallarg(int) PAD;
2517 		syscallarg(off_t) offset;
2518 		syscallarg(off_t) len;
2519 		syscallarg(int) advice;
2520 	} */
2521 
2522 	*retval = do_posix_fadvise(SCARG(uap, fd), SCARG(uap, offset),
2523 	    SCARG(uap, len), SCARG(uap, advice));
2524 
2525 	return 0;
2526 }
2527 
2528 int
2529 netbsd32__sched_setparam(struct lwp *l,
2530 			 const struct netbsd32__sched_setparam_args *uap,
2531 			 register_t *retval)
2532 {
2533 	/* {
2534 		syscallarg(pid_t) pid;
2535 		syscallarg(lwpid_t) lid;
2536 		syscallarg(int) policy;
2537 		syscallarg(const netbsd32_sched_paramp_t) params;
2538 	} */
2539 	struct sys__sched_setparam_args ua;
2540 
2541 	NETBSD32TO64_UAP(pid);
2542 	NETBSD32TO64_UAP(lid);
2543 	NETBSD32TO64_UAP(policy);
2544 	NETBSD32TOP_UAP(params, const struct sched_param *);
2545 	return sys__sched_setparam(l, &ua, retval);
2546 }
2547 
2548 int
2549 netbsd32__sched_getparam(struct lwp *l,
2550 			 const struct netbsd32__sched_getparam_args *uap,
2551 			 register_t *retval)
2552 {
2553 	/* {
2554 		syscallarg(pid_t) pid;
2555 		syscallarg(lwpid_t) lid;
2556 		syscallarg(netbsd32_intp) policy;
2557 		syscallarg(netbsd32_sched_paramp_t) params;
2558 	} */
2559 	struct sys__sched_getparam_args ua;
2560 
2561 	NETBSD32TO64_UAP(pid);
2562 	NETBSD32TO64_UAP(lid);
2563 	NETBSD32TOP_UAP(policy, int *);
2564 	NETBSD32TOP_UAP(params, struct sched_param *);
2565 	return sys__sched_getparam(l, &ua, retval);
2566 }
2567 
2568 int
2569 netbsd32__sched_setaffinity(struct lwp *l,
2570 			    const struct netbsd32__sched_setaffinity_args *uap,
2571 			    register_t *retval)
2572 {
2573 	/* {
2574 		syscallarg(pid_t) pid;
2575 		syscallarg(lwpid_t) lid;
2576 		syscallarg(netbsd_size_t) size;
2577 		syscallarg(const netbsd32_cpusetp_t) cpuset;
2578 	} */
2579 	struct sys__sched_setaffinity_args ua;
2580 
2581 	NETBSD32TO64_UAP(pid);
2582 	NETBSD32TO64_UAP(lid);
2583 	NETBSD32TOX_UAP(size, size_t);
2584 	NETBSD32TOP_UAP(cpuset, const cpuset_t *);
2585 	return sys__sched_setaffinity(l, &ua, retval);
2586 }
2587 
2588 int
2589 netbsd32__sched_getaffinity(struct lwp *l,
2590 			    const struct netbsd32__sched_getaffinity_args *uap,
2591 			    register_t *retval)
2592 {
2593 	/* {
2594 		syscallarg(pid_t) pid;
2595 		syscallarg(lwpid_t) lid;
2596 		syscallarg(netbsd_size_t) size;
2597 		syscallarg(netbsd32_cpusetp_t) cpuset;
2598 	} */
2599 	struct sys__sched_getaffinity_args ua;
2600 
2601 	NETBSD32TO64_UAP(pid);
2602 	NETBSD32TO64_UAP(lid);
2603 	NETBSD32TOX_UAP(size, size_t);
2604 	NETBSD32TOP_UAP(cpuset, cpuset_t *);
2605 	return sys__sched_getaffinity(l, &ua, retval);
2606 }
2607 
2608 /*
2609  * MI indirect system call support.
2610  * Only used if the MD netbsd32_syscall.c doesn't intercept the calls.
2611  */
2612 
2613 #define NETBSD32_SYSCALL
2614 #undef SYS_NSYSENT
2615 #define SYS_NSYSENT NETBSD32_SYS_NSYSENT
2616 
2617 #define SYS_SYSCALL netbsd32_syscall
2618 #include "../../kern/sys_syscall.c"
2619 #undef SYS_SYSCALL
2620 
2621 #define SYS_SYSCALL netbsd32____syscall
2622 #include "../../kern/sys_syscall.c"
2623 #undef SYS_SYSCALL
2624