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