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