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