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