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