Home | History | Annotate | Line # | Download | only in netbsd32
netbsd32_netbsd.c revision 1.178
      1 /*	$NetBSD: netbsd32_netbsd.c,v 1.178 2012/02/01 05:40:00 dholland Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1998, 2001, 2008 Matthew R. Green
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  * SUCH DAMAGE.
     27  */
     28 
     29 #include <sys/cdefs.h>
     30 __KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.178 2012/02/01 05:40:00 dholland Exp $");
     31 
     32 #if defined(_KERNEL_OPT)
     33 #include "opt_ddb.h"
     34 #include "opt_ntp.h"
     35 #include "opt_compat_netbsd.h"
     36 #include "opt_compat_43.h"
     37 #include "opt_sysv.h"
     38 #include "opt_syscall_debug.h"
     39 #include "opt_sa.h"
     40 #endif
     41 
     42 /*
     43  * Though COMPAT_OLDSOCK is needed only for COMPAT_43, SunOS, Linux,
     44  * HP-UX, FreeBSD, Ultrix, OSF1, we define it unconditionally so that
     45  * this would be module-safe.
     46  */
     47 #define COMPAT_OLDSOCK /* used by <sys/socket.h> */
     48 
     49 #include <sys/param.h>
     50 #include <sys/systm.h>
     51 #include <sys/kernel.h>
     52 //#define msg __msg /* Don't ask me! */
     53 #include <sys/mount.h>
     54 #include <sys/socket.h>
     55 #include <sys/sockio.h>
     56 #include <sys/socketvar.h>
     57 #include <sys/mbuf.h>
     58 #include <sys/stat.h>
     59 #include <sys/time.h>
     60 #include <sys/signalvar.h>
     61 #include <sys/ptrace.h>
     62 #include <sys/ktrace.h>
     63 #include <sys/trace.h>
     64 #include <sys/resourcevar.h>
     65 #include <sys/pool.h>
     66 #include <sys/vnode.h>
     67 #include <sys/file.h>
     68 #include <sys/filedesc.h>
     69 #include <sys/namei.h>
     70 #include <sys/dirent.h>
     71 #include <sys/quotactl.h>
     72 #include <sys/kauth.h>
     73 #include <sys/vfs_syscalls.h>
     74 
     75 #include <uvm/uvm_extern.h>
     76 
     77 #include <sys/sa.h>
     78 #include <sys/savar.h>
     79 #include <sys/syscallargs.h>
     80 #include <sys/proc.h>
     81 #include <sys/acct.h>
     82 #include <sys/exec.h>
     83 
     84 #include <net/if.h>
     85 
     86 #include <compat/netbsd32/netbsd32.h>
     87 #include <compat/netbsd32/netbsd32_exec.h>
     88 #include <compat/netbsd32/netbsd32_syscall.h>
     89 #include <compat/netbsd32/netbsd32_syscallargs.h>
     90 #include <compat/netbsd32/netbsd32_conv.h>
     91 #include <compat/netbsd32/netbsd32_sa.h>
     92 
     93 #if defined(DDB)
     94 #include <ddb/ddbvar.h>
     95 #endif
     96 
     97 extern struct sysent netbsd32_sysent[];
     98 #ifdef SYSCALL_DEBUG
     99 extern const char * const netbsd32_syscallnames[];
    100 #endif
    101 #ifdef __HAVE_SYSCALL_INTERN
    102 void netbsd32_syscall_intern(struct proc *);
    103 #else
    104 void syscall(void);
    105 #endif
    106 
    107 #define LIMITCHECK(a, b) ((a) != RLIM_INFINITY && (a) > (b))
    108 
    109 #ifdef COMPAT_16
    110 extern char netbsd32_sigcode[], netbsd32_esigcode[];
    111 struct uvm_object *emul_netbsd32_object;
    112 #endif
    113 
    114 extern struct sysctlnode netbsd32_sysctl_root;
    115 
    116 struct emul emul_netbsd32 = {
    117 	.e_name =		"netbsd32",
    118 	.e_path =		"/emul/netbsd32",
    119 #ifndef __HAVE_MINIMAL_EMUL
    120 	.e_flags =		0,
    121 	.e_errno =		NULL,
    122 	.e_nosys =		NETBSD32_SYS_netbsd32_syscall,
    123 	.e_nsysent =		NETBSD32_SYS_NSYSENT,
    124 #endif
    125 	.e_sysent =		netbsd32_sysent,
    126 #ifdef SYSCALL_DEBUG
    127 	.e_syscallnames =	netbsd32_syscallnames,
    128 #else
    129 	.e_syscallnames =	NULL,
    130 #endif
    131 	.e_sendsig =		netbsd32_sendsig,
    132 	.e_trapsignal =		trapsignal,
    133 	.e_tracesig =		NULL,
    134 #ifdef COMPAT_16
    135 	.e_sigcode =		netbsd32_sigcode,
    136 	.e_esigcode =		netbsd32_esigcode,
    137 	.e_sigobject =		&emul_netbsd32_object,
    138 #else
    139 	.e_sigcode =		NULL,
    140 	.e_esigcode =		NULL,
    141 	.e_sigobject =		NULL,
    142 #endif
    143 	.e_setregs =		netbsd32_setregs,
    144 	.e_proc_exec =		NULL,
    145 	.e_proc_fork =		NULL,
    146 	.e_proc_exit =		NULL,
    147 	.e_lwp_fork =		NULL,
    148 	.e_lwp_exit =		NULL,
    149 #ifdef __HAVE_SYSCALL_INTERN
    150 	.e_syscall_intern =	netbsd32_syscall_intern,
    151 #else
    152 	.e_syscall =		syscall,
    153 #endif
    154 	.e_sysctlovly =		&netbsd32_sysctl_root,
    155 	.e_fault =		NULL,
    156 	.e_vm_default_addr =	netbsd32_vm_default_addr,
    157 	.e_usertrap =		NULL,
    158 #if defined(COMPAT_40) && defined(KERN_SA)
    159 	.e_sa =			&saemul_netbsd32,
    160 #else
    161 	.e_sa =			NULL,
    162 #endif
    163 	.e_ucsize =		sizeof(ucontext32_t),
    164 	.e_startlwp =		startlwp32
    165 };
    166 
    167 /*
    168  * below are all the standard NetBSD system calls, in the 32bit
    169  * environment, with the necessary conversions to 64bit before
    170  * calling the real syscall.  anything that needs special
    171  * attention is handled elsewhere.
    172  */
    173 
    174 int
    175 netbsd32_exit(struct lwp *l, const struct netbsd32_exit_args *uap, register_t *retval)
    176 {
    177 	/* {
    178 		syscallarg(int) rval;
    179 	} */
    180 	struct sys_exit_args ua;
    181 
    182 	NETBSD32TO64_UAP(rval);
    183 	return sys_exit(l, &ua, retval);
    184 }
    185 
    186 int
    187 netbsd32_read(struct lwp *l, const struct netbsd32_read_args *uap, register_t *retval)
    188 {
    189 	/* {
    190 		syscallarg(int) fd;
    191 		syscallarg(netbsd32_voidp) buf;
    192 		syscallarg(netbsd32_size_t) nbyte;
    193 	} */
    194 	struct sys_read_args ua;
    195 
    196 	NETBSD32TO64_UAP(fd);
    197 	NETBSD32TOP_UAP(buf, void *);
    198 	NETBSD32TOX_UAP(nbyte, size_t);
    199 	return sys_read(l, &ua, retval);
    200 }
    201 
    202 int
    203 netbsd32_write(struct lwp *l, const struct netbsd32_write_args *uap, register_t *retval)
    204 {
    205 	/* {
    206 		syscallarg(int) fd;
    207 		syscallarg(const netbsd32_voidp) buf;
    208 		syscallarg(netbsd32_size_t) nbyte;
    209 	} */
    210 	struct sys_write_args ua;
    211 
    212 	NETBSD32TO64_UAP(fd);
    213 	NETBSD32TOP_UAP(buf, void *);
    214 	NETBSD32TOX_UAP(nbyte, size_t);
    215 	return sys_write(l, &ua, retval);
    216 }
    217 
    218 int
    219 netbsd32_close(struct lwp *l, const struct netbsd32_close_args *uap, register_t *retval)
    220 {
    221 	/* {
    222 		syscallarg(int) fd;
    223 	} */
    224 	struct sys_close_args ua;
    225 
    226 	NETBSD32TO64_UAP(fd);
    227 	return sys_close(l, &ua, retval);
    228 }
    229 
    230 int
    231 netbsd32_open(struct lwp *l, const struct netbsd32_open_args *uap, register_t *retval)
    232 {
    233 	/* {
    234 		syscallarg(const netbsd32_charp) path;
    235 		syscallarg(int) flags;
    236 		syscallarg(mode_t) mode;
    237 	} */
    238 	struct sys_open_args ua;
    239 
    240 	NETBSD32TOP_UAP(path, const char);
    241 	NETBSD32TO64_UAP(flags);
    242 	NETBSD32TO64_UAP(mode);
    243 
    244 	return (sys_open(l, &ua, retval));
    245 }
    246 
    247 int
    248 netbsd32_link(struct lwp *l, const struct netbsd32_link_args *uap, register_t *retval)
    249 {
    250 	/* {
    251 		syscallarg(const netbsd32_charp) path;
    252 		syscallarg(const netbsd32_charp) link;
    253 	} */
    254 	struct sys_link_args ua;
    255 
    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 	NETBSD32TOP_UAP(path, const char);
    270 
    271 	return (sys_unlink(l, &ua, retval));
    272 }
    273 
    274 int
    275 netbsd32_chdir(struct lwp *l, const struct netbsd32_chdir_args *uap, register_t *retval)
    276 {
    277 	/* {
    278 		syscallarg(const netbsd32_charp) path;
    279 	} */
    280 	struct sys_chdir_args ua;
    281 
    282 	NETBSD32TOP_UAP(path, const char);
    283 
    284 	return (sys_chdir(l, &ua, retval));
    285 }
    286 
    287 int
    288 netbsd32_fchdir(struct lwp *l, const struct netbsd32_fchdir_args *uap, register_t *retval)
    289 {
    290 	/* {
    291 		syscallarg(int) fd;
    292 	} */
    293 	struct sys_fchdir_args ua;
    294 
    295 	NETBSD32TO64_UAP(fd);
    296 
    297 	return (sys_fchdir(l, &ua, retval));
    298 }
    299 
    300 int
    301 netbsd32___mknod50(struct lwp *l, const struct netbsd32___mknod50_args *uap, register_t *retval)
    302 {
    303 	/* {
    304 		syscallarg(const netbsd32_charp) path;
    305 		syscallarg(mode_t) mode;
    306 		syscallarg(netbsd32_dev_t) dev;
    307 	} */
    308 
    309 	return do_sys_mknod(l, SCARG_P32(uap, path), SCARG(uap, mode),
    310 	    SCARG(uap, dev), retval, UIO_USERSPACE);
    311 }
    312 
    313 int
    314 netbsd32_chmod(struct lwp *l, const struct netbsd32_chmod_args *uap, register_t *retval)
    315 {
    316 	/* {
    317 		syscallarg(const netbsd32_charp) path;
    318 		syscallarg(mode_t) mode;
    319 	} */
    320 	struct sys_chmod_args ua;
    321 
    322 	NETBSD32TOP_UAP(path, const char);
    323 	NETBSD32TO64_UAP(mode);
    324 
    325 	return (sys_chmod(l, &ua, retval));
    326 }
    327 
    328 int
    329 netbsd32_chown(struct lwp *l, const struct netbsd32_chown_args *uap, register_t *retval)
    330 {
    331 	/* {
    332 		syscallarg(const netbsd32_charp) path;
    333 		syscallarg(uid_t) uid;
    334 		syscallarg(gid_t) gid;
    335 	} */
    336 	struct sys_chown_args ua;
    337 
    338 	NETBSD32TOP_UAP(path, const char);
    339 	NETBSD32TO64_UAP(uid);
    340 	NETBSD32TO64_UAP(gid);
    341 
    342 	return (sys_chown(l, &ua, retval));
    343 }
    344 
    345 int
    346 netbsd32_break(struct lwp *l, const struct netbsd32_break_args *uap, register_t *retval)
    347 {
    348 	/* {
    349 		syscallarg(netbsd32_charp) nsize;
    350 	} */
    351 	struct sys_obreak_args ua;
    352 
    353 	NETBSD32TOP_UAP(nsize, char);
    354 	return (sys_obreak(l, &ua, retval));
    355 }
    356 
    357 int
    358 netbsd32_mount(struct lwp *l, const struct netbsd32_mount_args *uap, register_t *retval)
    359 {
    360 #ifdef COMPAT_40
    361 	/* {
    362 		syscallarg(const netbsd32_charp) type;
    363 		syscallarg(const netbsd32_charp) path;
    364 		syscallarg(int) flags;
    365 		syscallarg(netbsd32_voidp) data;
    366 	} */
    367 	struct compat_40_sys_mount_args ua;
    368 
    369 	NETBSD32TOP_UAP(type, const char);
    370 	NETBSD32TOP_UAP(path, const char);
    371 	NETBSD32TO64_UAP(flags);
    372 	NETBSD32TOP_UAP(data, void);
    373 	return (compat_40_sys_mount(l, &ua, retval));
    374 #else
    375 	return ENOSYS;
    376 #endif
    377 }
    378 
    379 int
    380 netbsd32_unmount(struct lwp *l, const struct netbsd32_unmount_args *uap, register_t *retval)
    381 {
    382 	/* {
    383 		syscallarg(const netbsd32_charp) path;
    384 		syscallarg(int) flags;
    385 	} */
    386 	struct sys_unmount_args ua;
    387 
    388 	NETBSD32TOP_UAP(path, const char);
    389 	NETBSD32TO64_UAP(flags);
    390 	return (sys_unmount(l, &ua, retval));
    391 }
    392 
    393 int
    394 netbsd32_setuid(struct lwp *l, const struct netbsd32_setuid_args *uap, register_t *retval)
    395 {
    396 	/* {
    397 		syscallarg(uid_t) uid;
    398 	} */
    399 	struct sys_setuid_args ua;
    400 
    401 	NETBSD32TO64_UAP(uid);
    402 	return (sys_setuid(l, &ua, retval));
    403 }
    404 
    405 int
    406 netbsd32_ptrace(struct lwp *l, const struct netbsd32_ptrace_args *uap, register_t *retval)
    407 {
    408 	/* {
    409 		syscallarg(int) req;
    410 		syscallarg(pid_t) pid;
    411 		syscallarg(netbsd32_voidp) addr;
    412 		syscallarg(int) data;
    413 	} */
    414 	struct sys_ptrace_args ua;
    415 
    416 	NETBSD32TO64_UAP(req);
    417 	NETBSD32TO64_UAP(pid);
    418 	NETBSD32TOP_UAP(addr, void *);
    419 	NETBSD32TO64_UAP(data);
    420 
    421 	return (*sysent[SYS_ptrace].sy_call)(l, &ua, retval);
    422 }
    423 
    424 int
    425 netbsd32_accept(struct lwp *l, const struct netbsd32_accept_args *uap, register_t *retval)
    426 {
    427 	/* {
    428 		syscallarg(int) s;
    429 		syscallarg(netbsd32_sockaddrp_t) name;
    430 		syscallarg(netbsd32_intp) anamelen;
    431 	} */
    432 	struct sys_accept_args ua;
    433 
    434 	NETBSD32TO64_UAP(s);
    435 	NETBSD32TOP_UAP(name, struct sockaddr);
    436 	NETBSD32TOP_UAP(anamelen, socklen_t);
    437 	return (sys_accept(l, &ua, retval));
    438 }
    439 
    440 int
    441 netbsd32_getpeername(struct lwp *l, const struct netbsd32_getpeername_args *uap, register_t *retval)
    442 {
    443 	/* {
    444 		syscallarg(int) fdes;
    445 		syscallarg(netbsd32_sockaddrp_t) asa;
    446 		syscallarg(netbsd32_intp) alen;
    447 	} */
    448 	struct sys_getpeername_args ua;
    449 
    450 	NETBSD32TO64_UAP(fdes);
    451 	NETBSD32TOP_UAP(asa, struct sockaddr);
    452 	NETBSD32TOP_UAP(alen, socklen_t);
    453 /* NB: do the protocol specific sockaddrs need to be converted? */
    454 	return (sys_getpeername(l, &ua, retval));
    455 }
    456 
    457 int
    458 netbsd32_getsockname(struct lwp *l, const struct netbsd32_getsockname_args *uap, register_t *retval)
    459 {
    460 	/* {
    461 		syscallarg(int) fdes;
    462 		syscallarg(netbsd32_sockaddrp_t) asa;
    463 		syscallarg(netbsd32_intp) alen;
    464 	} */
    465 	struct sys_getsockname_args ua;
    466 
    467 	NETBSD32TO64_UAP(fdes);
    468 	NETBSD32TOP_UAP(asa, struct sockaddr);
    469 	NETBSD32TOP_UAP(alen, socklen_t);
    470 	return (sys_getsockname(l, &ua, retval));
    471 }
    472 
    473 int
    474 netbsd32_access(struct lwp *l, const struct netbsd32_access_args *uap, register_t *retval)
    475 {
    476 	/* {
    477 		syscallarg(const netbsd32_charp) path;
    478 		syscallarg(int) flags;
    479 	} */
    480 	struct sys_access_args ua;
    481 
    482 	NETBSD32TOP_UAP(path, const char);
    483 	NETBSD32TO64_UAP(flags);
    484 
    485 	return sys_access(l, &ua, retval);
    486 }
    487 
    488 int
    489 netbsd32_chflags(struct lwp *l, const struct netbsd32_chflags_args *uap, register_t *retval)
    490 {
    491 	/* {
    492 		syscallarg(const netbsd32_charp) path;
    493 		syscallarg(netbsd32_u_long) flags;
    494 	} */
    495 	struct sys_chflags_args ua;
    496 
    497 	NETBSD32TOP_UAP(path, const char);
    498 	NETBSD32TO64_UAP(flags);
    499 
    500 	return (sys_chflags(l, &ua, retval));
    501 }
    502 
    503 int
    504 netbsd32_fchflags(struct lwp *l, const struct netbsd32_fchflags_args *uap, register_t *retval)
    505 {
    506 	/* {
    507 		syscallarg(int) fd;
    508 		syscallarg(netbsd32_u_long) flags;
    509 	} */
    510 	struct sys_fchflags_args ua;
    511 
    512 	NETBSD32TO64_UAP(fd);
    513 	NETBSD32TO64_UAP(flags);
    514 
    515 	return (sys_fchflags(l, &ua, retval));
    516 }
    517 
    518 int
    519 netbsd32_lchflags(struct lwp *l, const struct netbsd32_lchflags_args *uap, register_t *retval)
    520 {
    521 	/* {
    522 		syscallarg(const char *) path;
    523 		syscallarg(netbsd32_u_long) flags;
    524 	} */
    525 	struct sys_lchflags_args ua;
    526 
    527 	NETBSD32TOP_UAP(path, const char);
    528 	NETBSD32TO64_UAP(flags);
    529 
    530 	return (sys_lchflags(l, &ua, retval));
    531 }
    532 
    533 int
    534 netbsd32_kill(struct lwp *l, const struct netbsd32_kill_args *uap, register_t *retval)
    535 {
    536 	/* {
    537 		syscallarg(int) pid;
    538 		syscallarg(int) signum;
    539 	} */
    540 	struct sys_kill_args ua;
    541 
    542 	NETBSD32TO64_UAP(pid);
    543 	NETBSD32TO64_UAP(signum);
    544 
    545 	return (sys_kill(l, &ua, retval));
    546 }
    547 
    548 int
    549 netbsd32_dup(struct lwp *l, const struct netbsd32_dup_args *uap, register_t *retval)
    550 {
    551 	/* {
    552 		syscallarg(int) fd;
    553 	} */
    554 	struct sys_dup_args ua;
    555 
    556 	NETBSD32TO64_UAP(fd);
    557 
    558 	return (sys_dup(l, &ua, retval));
    559 }
    560 
    561 int
    562 netbsd32_profil(struct lwp *l, const struct netbsd32_profil_args *uap, register_t *retval)
    563 {
    564 	/* {
    565 		syscallarg(netbsd32_voidp) samples;
    566 		syscallarg(netbsd32_size_t) size;
    567 		syscallarg(netbsd32_u_long) offset;
    568 		syscallarg(u_int) scale;
    569 	} */
    570 	struct sys_profil_args ua;
    571 
    572 	NETBSD32TOP_UAP(samples, void *);
    573 	NETBSD32TOX_UAP(size, size_t);
    574 	NETBSD32TOX_UAP(offset, u_long);
    575 	NETBSD32TO64_UAP(scale);
    576 	return (sys_profil(l, &ua, retval));
    577 }
    578 
    579 int
    580 netbsd32_ktrace(struct lwp *l, const struct netbsd32_ktrace_args *uap, register_t *retval)
    581 {
    582 	/* {
    583 		syscallarg(const netbsd32_charp) fname;
    584 		syscallarg(int) ops;
    585 		syscallarg(int) facs;
    586 		syscallarg(int) pid;
    587 	} */
    588 	struct sys_ktrace_args ua;
    589 
    590 	NETBSD32TOP_UAP(fname, const char);
    591 	NETBSD32TO64_UAP(ops);
    592 	NETBSD32TO64_UAP(facs);
    593 	NETBSD32TO64_UAP(pid);
    594 	return (sys_ktrace(l, &ua, retval));
    595 }
    596 
    597 int
    598 netbsd32_utrace(struct lwp *l, const struct netbsd32_utrace_args *uap, register_t *retval)
    599 {
    600 	/* {
    601 		syscallarg(const netbsd32_charp) label;
    602 		syscallarg(netbsd32_voidp) addr;
    603 		syscallarg(netbsd32_size_t) len;
    604 	} */
    605 	struct sys_utrace_args ua;
    606 
    607 	NETBSD32TOP_UAP(label, const char);
    608 	NETBSD32TOP_UAP(addr, void);
    609 	NETBSD32TO64_UAP(len);
    610 	return (sys_utrace(l, &ua, retval));
    611 }
    612 
    613 int
    614 netbsd32___getlogin(struct lwp *l, const struct netbsd32___getlogin_args *uap, register_t *retval)
    615 {
    616 	/* {
    617 		syscallarg(netbsd32_charp) namebuf;
    618 		syscallarg(u_int) namelen;
    619 	} */
    620 	struct sys___getlogin_args ua;
    621 
    622 	NETBSD32TOP_UAP(namebuf, char);
    623 	NETBSD32TO64_UAP(namelen);
    624 	return (sys___getlogin(l, &ua, retval));
    625 }
    626 
    627 int
    628 netbsd32_setlogin(struct lwp *l, const struct netbsd32_setlogin_args *uap, register_t *retval)
    629 {
    630 	/* {
    631 		syscallarg(const netbsd32_charp) namebuf;
    632 	} */
    633 	struct sys___setlogin_args ua;
    634 
    635 	NETBSD32TOP_UAP(namebuf, char);
    636 	return (sys___setlogin(l, &ua, retval));
    637 }
    638 
    639 int
    640 netbsd32_acct(struct lwp *l, const struct netbsd32_acct_args *uap, register_t *retval)
    641 {
    642 	/* {
    643 		syscallarg(const netbsd32_charp) path;
    644 	} */
    645 	struct sys_acct_args ua;
    646 
    647 	NETBSD32TOP_UAP(path, const char);
    648 	return (sys_acct(l, &ua, retval));
    649 }
    650 
    651 int
    652 netbsd32_revoke(struct lwp *l, const struct netbsd32_revoke_args *uap, register_t *retval)
    653 {
    654 	/* {
    655 		syscallarg(const netbsd32_charp) path;
    656 	} */
    657 	struct sys_revoke_args ua;
    658 
    659 	NETBSD32TOP_UAP(path, const char);
    660 
    661 	return (sys_revoke(l, &ua, retval));
    662 }
    663 
    664 int
    665 netbsd32_symlink(struct lwp *l, const struct netbsd32_symlink_args *uap, register_t *retval)
    666 {
    667 	/* {
    668 		syscallarg(const netbsd32_charp) path;
    669 		syscallarg(const netbsd32_charp) link;
    670 	} */
    671 	struct sys_symlink_args ua;
    672 
    673 	NETBSD32TOP_UAP(path, const char);
    674 	NETBSD32TOP_UAP(link, const char);
    675 
    676 	return (sys_symlink(l, &ua, retval));
    677 }
    678 
    679 int
    680 netbsd32_readlink(struct lwp *l, const struct netbsd32_readlink_args *uap, register_t *retval)
    681 {
    682 	/* {
    683 		syscallarg(const netbsd32_charp) path;
    684 		syscallarg(netbsd32_charp) buf;
    685 		syscallarg(netbsd32_size_t) count;
    686 	} */
    687 	struct sys_readlink_args ua;
    688 
    689 	NETBSD32TOP_UAP(path, const char);
    690 	NETBSD32TOP_UAP(buf, char);
    691 	NETBSD32TOX_UAP(count, size_t);
    692 
    693 	return (sys_readlink(l, &ua, retval));
    694 }
    695 
    696 int
    697 netbsd32_umask(struct lwp *l, const struct netbsd32_umask_args *uap, register_t *retval)
    698 {
    699 	/* {
    700 		syscallarg(mode_t) newmask;
    701 	} */
    702 	struct sys_umask_args ua;
    703 
    704 	NETBSD32TO64_UAP(newmask);
    705 	return (sys_umask(l, &ua, retval));
    706 }
    707 
    708 int
    709 netbsd32_chroot(struct lwp *l, const struct netbsd32_chroot_args *uap, register_t *retval)
    710 {
    711 	/* {
    712 		syscallarg(const netbsd32_charp) path;
    713 	} */
    714 	struct sys_chroot_args ua;
    715 
    716 	NETBSD32TOP_UAP(path, const char);
    717 	return (sys_chroot(l, &ua, retval));
    718 }
    719 
    720 int
    721 netbsd32_sbrk(struct lwp *l, const struct netbsd32_sbrk_args *uap, register_t *retval)
    722 {
    723 	/* {
    724 		syscallarg(int) incr;
    725 	} */
    726 	struct sys_sbrk_args ua;
    727 
    728 	NETBSD32TO64_UAP(incr);
    729 	return (sys_sbrk(l, &ua, retval));
    730 }
    731 
    732 int
    733 netbsd32_sstk(struct lwp *l, const struct netbsd32_sstk_args *uap, register_t *retval)
    734 {
    735 	/* {
    736 		syscallarg(int) incr;
    737 	} */
    738 	struct sys_sstk_args ua;
    739 
    740 	NETBSD32TO64_UAP(incr);
    741 	return (sys_sstk(l, &ua, retval));
    742 }
    743 
    744 int
    745 netbsd32_munmap(struct lwp *l, const struct netbsd32_munmap_args *uap, register_t *retval)
    746 {
    747 	/* {
    748 		syscallarg(netbsd32_voidp) addr;
    749 		syscallarg(netbsd32_size_t) len;
    750 	} */
    751 	struct sys_munmap_args ua;
    752 
    753 	NETBSD32TOP_UAP(addr, void);
    754 	NETBSD32TOX_UAP(len, size_t);
    755 	return (sys_munmap(l, &ua, retval));
    756 }
    757 
    758 int
    759 netbsd32_mprotect(struct lwp *l, const struct netbsd32_mprotect_args *uap, register_t *retval)
    760 {
    761 	/* {
    762 		syscallarg(netbsd32_voidp) addr;
    763 		syscallarg(netbsd32_size_t) len;
    764 		syscallarg(int) prot;
    765 	} */
    766 	struct sys_mprotect_args ua;
    767 
    768 	NETBSD32TOP_UAP(addr, void);
    769 	NETBSD32TOX_UAP(len, size_t);
    770 	NETBSD32TO64_UAP(prot);
    771 	return (sys_mprotect(l, &ua, retval));
    772 }
    773 
    774 int
    775 netbsd32_madvise(struct lwp *l, const struct netbsd32_madvise_args *uap, register_t *retval)
    776 {
    777 	/* {
    778 		syscallarg(netbsd32_voidp) addr;
    779 		syscallarg(netbsd32_size_t) len;
    780 		syscallarg(int) behav;
    781 	} */
    782 	struct sys_madvise_args ua;
    783 
    784 	NETBSD32TOP_UAP(addr, void);
    785 	NETBSD32TOX_UAP(len, size_t);
    786 	NETBSD32TO64_UAP(behav);
    787 	return (sys_madvise(l, &ua, retval));
    788 }
    789 
    790 int
    791 netbsd32_mincore(struct lwp *l, const struct netbsd32_mincore_args *uap, register_t *retval)
    792 {
    793 	/* {
    794 		syscallarg(netbsd32_voidp) addr;
    795 		syscallarg(netbsd32_size_t) len;
    796 		syscallarg(netbsd32_charp) vec;
    797 	} */
    798 	struct sys_mincore_args ua;
    799 
    800 	NETBSD32TOP_UAP(addr, void *);
    801 	NETBSD32TOX_UAP(len, size_t);
    802 	NETBSD32TOP_UAP(vec, char);
    803 	return (sys_mincore(l, &ua, retval));
    804 }
    805 
    806 /* XXX MOVE ME XXX ? */
    807 int
    808 netbsd32_getgroups(struct lwp *l, const struct netbsd32_getgroups_args *uap, register_t *retval)
    809 {
    810 	/* {
    811 		syscallarg(int) gidsetsize;
    812 		syscallarg(netbsd32_gid_tp) gidset;
    813 	} */
    814 	struct sys_getgroups_args ua;
    815 
    816 	/* Since sizeof (gid_t) == sizeof (netbsd32_gid_t) ... */
    817 
    818 	NETBSD32TO64_UAP(gidsetsize);
    819 	NETBSD32TOP_UAP(gidset, gid_t);
    820 	return (sys_getgroups(l, &ua, retval));
    821 }
    822 
    823 int
    824 netbsd32_setgroups(struct lwp *l, const struct netbsd32_setgroups_args *uap, register_t *retval)
    825 {
    826 	/* {
    827 		syscallarg(int) gidsetsize;
    828 		syscallarg(const netbsd32_gid_tp) gidset;
    829 	} */
    830 	struct sys_setgroups_args ua;
    831 
    832 	NETBSD32TO64_UAP(gidsetsize);
    833 	NETBSD32TOP_UAP(gidset, gid_t);
    834 	return (sys_setgroups(l, &ua, retval));
    835 }
    836 
    837 int
    838 netbsd32_setpgid(struct lwp *l, const struct netbsd32_setpgid_args *uap, register_t *retval)
    839 {
    840 	/* {
    841 		syscallarg(int) pid;
    842 		syscallarg(int) pgid;
    843 	} */
    844 	struct sys_setpgid_args ua;
    845 
    846 	NETBSD32TO64_UAP(pid);
    847 	NETBSD32TO64_UAP(pgid);
    848 	return (sys_setpgid(l, &ua, retval));
    849 }
    850 
    851 int
    852 netbsd32_fcntl(struct lwp *l, const struct netbsd32_fcntl_args *uap, register_t *retval)
    853 {
    854 	/* {
    855 		syscallarg(int) fd;
    856 		syscallarg(int) cmd;
    857 		syscallarg(netbsd32_voidp) arg;
    858 	} */
    859 	struct sys_fcntl_args ua;
    860 
    861 	NETBSD32TO64_UAP(fd);
    862 	NETBSD32TO64_UAP(cmd);
    863 	NETBSD32TOP_UAP(arg, void);
    864 	/* we can do this because `struct flock' doesn't change */
    865 	return (sys_fcntl(l, &ua, retval));
    866 }
    867 
    868 int
    869 netbsd32_dup2(struct lwp *l, const struct netbsd32_dup2_args *uap, register_t *retval)
    870 {
    871 	/* {
    872 		syscallarg(int) from;
    873 		syscallarg(int) to;
    874 	} */
    875 	struct sys_dup2_args ua;
    876 
    877 	NETBSD32TO64_UAP(from);
    878 	NETBSD32TO64_UAP(to);
    879 	return (sys_dup2(l, &ua, retval));
    880 }
    881 
    882 int
    883 netbsd32_fsync(struct lwp *l, const struct netbsd32_fsync_args *uap, register_t *retval)
    884 {
    885 	/* {
    886 		syscallarg(int) fd;
    887 	} */
    888 	struct sys_fsync_args ua;
    889 
    890 	NETBSD32TO64_UAP(fd);
    891 	return (sys_fsync(l, &ua, retval));
    892 }
    893 
    894 int
    895 netbsd32_setpriority(struct lwp *l, const struct netbsd32_setpriority_args *uap, register_t *retval)
    896 {
    897 	/* {
    898 		syscallarg(int) which;
    899 		syscallarg(int) who;
    900 		syscallarg(int) prio;
    901 	} */
    902 	struct sys_setpriority_args ua;
    903 
    904 	NETBSD32TO64_UAP(which);
    905 	NETBSD32TO64_UAP(who);
    906 	NETBSD32TO64_UAP(prio);
    907 	return (sys_setpriority(l, &ua, retval));
    908 }
    909 
    910 int
    911 netbsd32___socket30(struct lwp *l, const struct netbsd32___socket30_args *uap, register_t *retval)
    912 {
    913 	/* {
    914 		syscallarg(int) domain;
    915 		syscallarg(int) type;
    916 		syscallarg(int) protocol;
    917 	} */
    918 	struct sys___socket30_args ua;
    919 
    920 	NETBSD32TO64_UAP(domain);
    921 	NETBSD32TO64_UAP(type);
    922 	NETBSD32TO64_UAP(protocol);
    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 	NETBSD32TO64_UAP(s);
    937 	NETBSD32TOP_UAP(name, struct sockaddr);
    938 	NETBSD32TO64_UAP(namelen);
    939 	return (sys_connect(l, &ua, retval));
    940 }
    941 
    942 int
    943 netbsd32_getpriority(struct lwp *l, const struct netbsd32_getpriority_args *uap, register_t *retval)
    944 {
    945 	/* {
    946 		syscallarg(int) which;
    947 		syscallarg(int) who;
    948 	} */
    949 	struct sys_getpriority_args ua;
    950 
    951 	NETBSD32TO64_UAP(which);
    952 	NETBSD32TO64_UAP(who);
    953 	return (sys_getpriority(l, &ua, retval));
    954 }
    955 
    956 int
    957 netbsd32_bind(struct lwp *l, const struct netbsd32_bind_args *uap, register_t *retval)
    958 {
    959 	/* {
    960 		syscallarg(int) s;
    961 		syscallarg(const netbsd32_sockaddrp_t) name;
    962 		syscallarg(int) namelen;
    963 	} */
    964 	struct sys_bind_args ua;
    965 
    966 	NETBSD32TO64_UAP(s);
    967 	NETBSD32TOP_UAP(name, struct sockaddr);
    968 	NETBSD32TO64_UAP(namelen);
    969 	return (sys_bind(l, &ua, retval));
    970 }
    971 
    972 int
    973 netbsd32_setsockopt(struct lwp *l, const struct netbsd32_setsockopt_args *uap, register_t *retval)
    974 {
    975 	/* {
    976 		syscallarg(int) s;
    977 		syscallarg(int) level;
    978 		syscallarg(int) name;
    979 		syscallarg(const netbsd32_voidp) val;
    980 		syscallarg(int) valsize;
    981 	} */
    982 	struct sys_setsockopt_args ua;
    983 
    984 	NETBSD32TO64_UAP(s);
    985 	NETBSD32TO64_UAP(level);
    986 	NETBSD32TO64_UAP(name);
    987 	NETBSD32TOP_UAP(val, void);
    988 	NETBSD32TO64_UAP(valsize);
    989 	/* may be more efficient to do this inline. */
    990 	return (sys_setsockopt(l, &ua, retval));
    991 }
    992 
    993 int
    994 netbsd32_listen(struct lwp *l, const struct netbsd32_listen_args *uap, register_t *retval)
    995 {
    996 	/* {
    997 		syscallarg(int) s;
    998 		syscallarg(int) backlog;
    999 	} */
   1000 	struct sys_listen_args ua;
   1001 
   1002 	NETBSD32TO64_UAP(s);
   1003 	NETBSD32TO64_UAP(backlog);
   1004 	return (sys_listen(l, &ua, retval));
   1005 }
   1006 
   1007 int
   1008 netbsd32_fchown(struct lwp *l, const struct netbsd32_fchown_args *uap, register_t *retval)
   1009 {
   1010 	/* {
   1011 		syscallarg(int) fd;
   1012 		syscallarg(uid_t) uid;
   1013 		syscallarg(gid_t) gid;
   1014 	} */
   1015 	struct sys_fchown_args ua;
   1016 
   1017 	NETBSD32TO64_UAP(fd);
   1018 	NETBSD32TO64_UAP(uid);
   1019 	NETBSD32TO64_UAP(gid);
   1020 	return (sys_fchown(l, &ua, retval));
   1021 }
   1022 
   1023 int
   1024 netbsd32_fchmod(struct lwp *l, const struct netbsd32_fchmod_args *uap, register_t *retval)
   1025 {
   1026 	/* {
   1027 		syscallarg(int) fd;
   1028 		syscallarg(mode_t) mode;
   1029 	} */
   1030 	struct sys_fchmod_args ua;
   1031 
   1032 	NETBSD32TO64_UAP(fd);
   1033 	NETBSD32TO64_UAP(mode);
   1034 	return (sys_fchmod(l, &ua, retval));
   1035 }
   1036 
   1037 int
   1038 netbsd32_setreuid(struct lwp *l, const struct netbsd32_setreuid_args *uap, register_t *retval)
   1039 {
   1040 	/* {
   1041 		syscallarg(uid_t) ruid;
   1042 		syscallarg(uid_t) euid;
   1043 	} */
   1044 	struct sys_setreuid_args ua;
   1045 
   1046 	NETBSD32TO64_UAP(ruid);
   1047 	NETBSD32TO64_UAP(euid);
   1048 	return (sys_setreuid(l, &ua, retval));
   1049 }
   1050 
   1051 int
   1052 netbsd32_setregid(struct lwp *l, const struct netbsd32_setregid_args *uap, register_t *retval)
   1053 {
   1054 	/* {
   1055 		syscallarg(gid_t) rgid;
   1056 		syscallarg(gid_t) egid;
   1057 	} */
   1058 	struct sys_setregid_args ua;
   1059 
   1060 	NETBSD32TO64_UAP(rgid);
   1061 	NETBSD32TO64_UAP(egid);
   1062 	return (sys_setregid(l, &ua, retval));
   1063 }
   1064 
   1065 int
   1066 netbsd32_getsockopt(struct lwp *l, const struct netbsd32_getsockopt_args *uap, register_t *retval)
   1067 {
   1068 	/* {
   1069 		syscallarg(int) s;
   1070 		syscallarg(int) level;
   1071 		syscallarg(int) name;
   1072 		syscallarg(netbsd32_voidp) val;
   1073 		syscallarg(netbsd32_intp) avalsize;
   1074 	} */
   1075 	struct sys_getsockopt_args ua;
   1076 
   1077 	NETBSD32TO64_UAP(s);
   1078 	NETBSD32TO64_UAP(level);
   1079 	NETBSD32TO64_UAP(name);
   1080 	NETBSD32TOP_UAP(val, void);
   1081 	NETBSD32TOP_UAP(avalsize, socklen_t);
   1082 	return (sys_getsockopt(l, &ua, retval));
   1083 }
   1084 
   1085 int
   1086 netbsd32_rename(struct lwp *l, const struct netbsd32_rename_args *uap, register_t *retval)
   1087 {
   1088 	/* {
   1089 		syscallarg(const netbsd32_charp) from;
   1090 		syscallarg(const netbsd32_charp) to;
   1091 	} */
   1092 	struct sys_rename_args ua;
   1093 
   1094 	NETBSD32TOP_UAP(from, const char);
   1095 	NETBSD32TOP_UAP(to, const char);
   1096 
   1097 	return (sys_rename(l, &ua, retval));
   1098 }
   1099 
   1100 int
   1101 netbsd32_flock(struct lwp *l, const struct netbsd32_flock_args *uap, register_t *retval)
   1102 {
   1103 	/* {
   1104 		syscallarg(int) fd;
   1105 		syscallarg(int) how;
   1106 	} */
   1107 	struct sys_flock_args ua;
   1108 
   1109 	NETBSD32TO64_UAP(fd);
   1110 	NETBSD32TO64_UAP(how);
   1111 
   1112 	return (sys_flock(l, &ua, retval));
   1113 }
   1114 
   1115 int
   1116 netbsd32_mkfifo(struct lwp *l, const struct netbsd32_mkfifo_args *uap, register_t *retval)
   1117 {
   1118 	/* {
   1119 		syscallarg(const netbsd32_charp) path;
   1120 		syscallarg(mode_t) mode;
   1121 	} */
   1122 	struct sys_mkfifo_args ua;
   1123 
   1124 	NETBSD32TOP_UAP(path, const char);
   1125 	NETBSD32TO64_UAP(mode);
   1126 	return (sys_mkfifo(l, &ua, retval));
   1127 }
   1128 
   1129 int
   1130 netbsd32_shutdown(struct lwp *l, const struct netbsd32_shutdown_args *uap, register_t *retval)
   1131 {
   1132 	/* {
   1133 		syscallarg(int) s;
   1134 		syscallarg(int) how;
   1135 	} */
   1136 	struct sys_shutdown_args ua;
   1137 
   1138 	NETBSD32TO64_UAP(s);
   1139 	NETBSD32TO64_UAP(how);
   1140 	return (sys_shutdown(l, &ua, retval));
   1141 }
   1142 
   1143 int
   1144 netbsd32_socketpair(struct lwp *l, const struct netbsd32_socketpair_args *uap, register_t *retval)
   1145 {
   1146 	/* {
   1147 		syscallarg(int) domain;
   1148 		syscallarg(int) type;
   1149 		syscallarg(int) protocol;
   1150 		syscallarg(netbsd32_intp) rsv;
   1151 	} */
   1152 	struct sys_socketpair_args ua;
   1153 
   1154 	NETBSD32TO64_UAP(domain);
   1155 	NETBSD32TO64_UAP(type);
   1156 	NETBSD32TO64_UAP(protocol);
   1157 	NETBSD32TOP_UAP(rsv, int);
   1158 	/* Since we're just copying out two `int's we can do this */
   1159 	return (sys_socketpair(l, &ua, retval));
   1160 }
   1161 
   1162 int
   1163 netbsd32_mkdir(struct lwp *l, const struct netbsd32_mkdir_args *uap, register_t *retval)
   1164 {
   1165 	/* {
   1166 		syscallarg(const netbsd32_charp) path;
   1167 		syscallarg(mode_t) mode;
   1168 	} */
   1169 	struct sys_mkdir_args ua;
   1170 
   1171 	NETBSD32TOP_UAP(path, const char);
   1172 	NETBSD32TO64_UAP(mode);
   1173 	return (sys_mkdir(l, &ua, retval));
   1174 }
   1175 
   1176 int
   1177 netbsd32_rmdir(struct lwp *l, const struct netbsd32_rmdir_args *uap, register_t *retval)
   1178 {
   1179 	/* {
   1180 		syscallarg(const netbsd32_charp) path;
   1181 	} */
   1182 	struct sys_rmdir_args ua;
   1183 
   1184 	NETBSD32TOP_UAP(path, const char);
   1185 	return (sys_rmdir(l, &ua, retval));
   1186 }
   1187 
   1188 int
   1189 netbsd32___quotactl(struct lwp *l, const struct netbsd32___quotactl_args *uap, register_t *retval)
   1190 {
   1191 	/* {
   1192 		syscallarg(const netbsd32_charp) path;
   1193 		syscallarg(netbsd32_voidp) args;
   1194 	} */
   1195 	struct netbsd32_quotactlargs args32;
   1196 	struct quotactl_args args;
   1197 	int error;
   1198 
   1199 	error = copyin(SCARG_P32(uap, args), &args32, sizeof(args32));
   1200 	if (error) {
   1201 		return error;
   1202 	}
   1203 
   1204 	args.qc_op = args32.qc_op;
   1205 	switch (args.qc_op) {
   1206 	    case QUOTACTL_STAT:
   1207 		args.u.stat.qc_ret = NETBSD32PTR64(args32.u.stat.qc_ret);
   1208 		break;
   1209 	    case QUOTACTL_IDTYPESTAT:
   1210 		args.u.idtypestat.qc_idtype = args32.u.idtypestat.qc_idtype;
   1211 		args.u.idtypestat.qc_info =
   1212 			NETBSD32PTR64(args32.u.idtypestat.qc_info);
   1213 		break;
   1214 	    case QUOTACTL_OBJTYPESTAT:
   1215 		args.u.objtypestat.qc_objtype =
   1216 			args32.u.objtypestat.qc_objtype;
   1217 		args.u.objtypestat.qc_info =
   1218 			NETBSD32PTR64(args32.u.objtypestat.qc_info);
   1219 		break;
   1220 	    case QUOTACTL_GET:
   1221 		args.u.get.qc_key = NETBSD32PTR64(args32.u.get.qc_key);
   1222 		args.u.get.qc_ret = NETBSD32PTR64(args32.u.get.qc_ret);
   1223 		break;
   1224 	    case QUOTACTL_PUT:
   1225 		args.u.put.qc_key = NETBSD32PTR64(args32.u.put.qc_key);
   1226 		args.u.put.qc_val = NETBSD32PTR64(args32.u.put.qc_val);
   1227 		break;
   1228 	    case QUOTACTL_DELETE:
   1229 		args.u.delete.qc_key = NETBSD32PTR64(args32.u.delete.qc_key);
   1230 		break;
   1231 	    case QUOTACTL_CURSOROPEN:
   1232 		args.u.cursoropen.qc_cursor =
   1233 			NETBSD32PTR64(args32.u.cursoropen.qc_cursor);
   1234 		break;
   1235 	    case QUOTACTL_CURSORCLOSE:
   1236 		args.u.cursorclose.qc_cursor =
   1237 			NETBSD32PTR64(args32.u.cursorclose.qc_cursor);
   1238 		break;
   1239 	    case QUOTACTL_CURSORSKIPIDTYPE:
   1240 		args.u.cursorskipidtype.qc_cursor =
   1241 			NETBSD32PTR64(args32.u.cursorskipidtype.qc_cursor);
   1242 		args.u.cursorskipidtype.qc_idtype =
   1243 			args32.u.cursorskipidtype.qc_idtype;
   1244 		break;
   1245 	    case QUOTACTL_CURSORGET:
   1246 		args.u.cursorget.qc_cursor =
   1247 			NETBSD32PTR64(args32.u.cursorget.qc_cursor);
   1248 		args.u.cursorget.qc_keys =
   1249 			NETBSD32PTR64(args32.u.cursorget.qc_keys);
   1250 		args.u.cursorget.qc_vals =
   1251 			NETBSD32PTR64(args32.u.cursorget.qc_vals);
   1252 		args.u.cursorget.qc_maxnum =
   1253 			args32.u.cursorget.qc_maxnum;
   1254 		args.u.cursorget.qc_ret =
   1255 			NETBSD32PTR64(args32.u.cursorget.qc_ret);
   1256 		break;
   1257 	    case QUOTACTL_CURSORATEND:
   1258 		args.u.cursoratend.qc_cursor =
   1259 			NETBSD32PTR64(args32.u.cursoratend.qc_cursor);
   1260 		args.u.cursoratend.qc_ret =
   1261 			NETBSD32PTR64(args32.u.cursoratend.qc_ret);
   1262 		break;
   1263 	    case QUOTACTL_CURSORREWIND:
   1264 		args.u.cursorrewind.qc_cursor =
   1265 			NETBSD32PTR64(args32.u.cursorrewind.qc_cursor);
   1266 		break;
   1267 	    case QUOTACTL_QUOTAON:
   1268 		args.u.quotaon.qc_idtype = args32.u.quotaon.qc_idtype;
   1269 		args.u.quotaon.qc_quotafile =
   1270 			NETBSD32PTR64(args32.u.quotaon.qc_quotafile);
   1271 		break;
   1272 	    case QUOTACTL_QUOTAOFF:
   1273 		args.u.quotaoff.qc_idtype = args32.u.quotaoff.qc_idtype;
   1274 		break;
   1275 	    default:
   1276 		return EINVAL;
   1277 	}
   1278 
   1279 	return do_sys_quotactl(SCARG_P32(uap, path), &args);
   1280 }
   1281 
   1282 int
   1283 netbsd32___getfh30(struct lwp *l, const struct netbsd32___getfh30_args *uap, register_t *retval)
   1284 {
   1285 	/* {
   1286 		syscallarg(const netbsd32_charp) fname;
   1287 		syscallarg(netbsd32_fhandlep_t) fhp;
   1288 		syscallarg(netbsd32_size_tp) fh_size;
   1289 	} */
   1290 	struct vnode *vp;
   1291 	fhandle_t *fh;
   1292 	int error;
   1293 	struct pathbuf *pb;
   1294 	struct nameidata nd;
   1295 	netbsd32_size_t sz32;
   1296 	size_t sz;
   1297 
   1298 	/*
   1299 	 * Must be super user
   1300 	 */
   1301 	error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FILEHANDLE,
   1302 	    0, NULL, NULL, NULL);
   1303 	if (error)
   1304 		return (error);
   1305 	fh = NULL;
   1306 
   1307 	error = pathbuf_copyin(SCARG_P32(uap, fname), &pb);
   1308 	if (error) {
   1309 		return error;
   1310 	}
   1311 
   1312 	NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | TRYEMULROOT, pb);
   1313 	error = namei(&nd);
   1314 	if (error) {
   1315 		pathbuf_destroy(pb);
   1316 		return error;
   1317 	}
   1318 	vp = nd.ni_vp;
   1319 	pathbuf_destroy(pb);
   1320 
   1321 	error = copyin(SCARG_P32(uap, fh_size), &sz32,
   1322 	    sizeof(netbsd32_size_t));
   1323 	if (error) {
   1324 		vput(vp);
   1325 		return error;
   1326 	}
   1327 	fh = kmem_alloc(sz32, KM_SLEEP);
   1328 	if (fh == NULL)
   1329 		return EINVAL;
   1330 	sz = sz32;
   1331 	error = vfs_composefh(vp, fh, &sz);
   1332 	vput(vp);
   1333 
   1334 	if (error == 0) {
   1335 		const netbsd32_size_t nsz32 = sz;
   1336 		error = copyout(&nsz32, SCARG_P32(uap, fh_size),
   1337 		    sizeof(netbsd32_size_t));
   1338 		if (!error) {
   1339 			error = copyout(fh, SCARG_P32(uap, fhp), sz);
   1340 		}
   1341 	} else if (error == E2BIG) {
   1342 		error = copyout(&sz, SCARG_P32(uap, fh_size), sizeof(size_t));
   1343 	}
   1344 	kmem_free(fh, sz32);
   1345 	return (error);
   1346 }
   1347 
   1348 int
   1349 netbsd32_pread(struct lwp *l, const struct netbsd32_pread_args *uap, register_t *retval)
   1350 {
   1351 	/* {
   1352 		syscallarg(int) fd;
   1353 		syscallarg(netbsd32_voidp) buf;
   1354 		syscallarg(netbsd32_size_t) nbyte;
   1355 		syscallarg(int) PAD;
   1356 		syscallarg(off_t) offset;
   1357 	} */
   1358 	struct sys_pread_args ua;
   1359 
   1360 	NETBSD32TO64_UAP(fd);
   1361 	NETBSD32TOP_UAP(buf, void);
   1362 	NETBSD32TOX_UAP(nbyte, size_t);
   1363 	NETBSD32TO64_UAP(PAD);
   1364 	NETBSD32TO64_UAP(offset);
   1365 	return sys_pread(l, &ua, retval);
   1366 }
   1367 
   1368 int
   1369 netbsd32_pwrite(struct lwp *l, const struct netbsd32_pwrite_args *uap, register_t *retval)
   1370 {
   1371 	/* {
   1372 		syscallarg(int) fd;
   1373 		syscallarg(const netbsd32_voidp) buf;
   1374 		syscallarg(netbsd32_size_t) nbyte;
   1375 		syscallarg(int) PAD;
   1376 		syscallarg(off_t) offset;
   1377 	} */
   1378 	struct sys_pwrite_args ua;
   1379 
   1380 	NETBSD32TO64_UAP(fd);
   1381 	NETBSD32TOP_UAP(buf, void);
   1382 	NETBSD32TOX_UAP(nbyte, size_t);
   1383 	NETBSD32TO64_UAP(PAD);
   1384 	NETBSD32TO64_UAP(offset);
   1385 	return sys_pwrite(l, &ua, retval);
   1386 }
   1387 
   1388 int
   1389 netbsd32_setgid(struct lwp *l, const struct netbsd32_setgid_args *uap, register_t *retval)
   1390 {
   1391 	/* {
   1392 		syscallarg(gid_t) gid;
   1393 	} */
   1394 	struct sys_setgid_args ua;
   1395 
   1396 	NETBSD32TO64_UAP(gid);
   1397 	return (sys_setgid(l, &ua, retval));
   1398 }
   1399 
   1400 int
   1401 netbsd32_setegid(struct lwp *l, const struct netbsd32_setegid_args *uap, register_t *retval)
   1402 {
   1403 	/* {
   1404 		syscallarg(gid_t) egid;
   1405 	} */
   1406 	struct sys_setegid_args ua;
   1407 
   1408 	NETBSD32TO64_UAP(egid);
   1409 	return (sys_setegid(l, &ua, retval));
   1410 }
   1411 
   1412 int
   1413 netbsd32_seteuid(struct lwp *l, const struct netbsd32_seteuid_args *uap, register_t *retval)
   1414 {
   1415 	/* {
   1416 		syscallarg(gid_t) euid;
   1417 	} */
   1418 	struct sys_seteuid_args ua;
   1419 
   1420 	NETBSD32TO64_UAP(euid);
   1421 	return (sys_seteuid(l, &ua, retval));
   1422 }
   1423 
   1424 int
   1425 netbsd32_pathconf(struct lwp *l, const struct netbsd32_pathconf_args *uap, register_t *retval)
   1426 {
   1427 	/* {
   1428 		syscallarg(int) fd;
   1429 		syscallarg(int) name;
   1430 	} */
   1431 	struct sys_pathconf_args ua;
   1432 
   1433 	NETBSD32TOP_UAP(path, const char);
   1434 	NETBSD32TO64_UAP(name);
   1435 	return sys_pathconf(l, &ua, retval);
   1436 }
   1437 
   1438 int
   1439 netbsd32_fpathconf(struct lwp *l, const struct netbsd32_fpathconf_args *uap, register_t *retval)
   1440 {
   1441 	/* {
   1442 		syscallarg(int) fd;
   1443 		syscallarg(int) name;
   1444 	} */
   1445 	struct sys_fpathconf_args ua;
   1446 
   1447 	NETBSD32TO64_UAP(fd);
   1448 	NETBSD32TO64_UAP(name);
   1449 	return sys_fpathconf(l, &ua, retval);
   1450 }
   1451 
   1452 int
   1453 netbsd32_getrlimit(struct lwp *l, const struct netbsd32_getrlimit_args *uap, register_t *retval)
   1454 {
   1455 	/* {
   1456 		syscallarg(int) which;
   1457 		syscallarg(netbsd32_rlimitp_t) rlp;
   1458 	} */
   1459 	int which = SCARG(uap, which);
   1460 
   1461 	if ((u_int)which >= RLIM_NLIMITS)
   1462 		return (EINVAL);
   1463 	return (copyout(&l->l_proc->p_rlimit[which],
   1464 	    SCARG_P32(uap, rlp), sizeof(struct rlimit)));
   1465 }
   1466 
   1467 int
   1468 netbsd32_setrlimit(struct lwp *l, const struct netbsd32_setrlimit_args *uap, register_t *retval)
   1469 {
   1470 	/* {
   1471 		syscallarg(int) which;
   1472 		syscallarg(const netbsd32_rlimitp_t) rlp;
   1473 	} */
   1474 		int which = SCARG(uap, which);
   1475 	struct rlimit alim;
   1476 	int error;
   1477 
   1478 	error = copyin(SCARG_P32(uap, rlp), &alim, sizeof(struct rlimit));
   1479 	if (error)
   1480 		return (error);
   1481 
   1482 	switch (which) {
   1483 	case RLIMIT_DATA:
   1484 		if (LIMITCHECK(alim.rlim_cur, MAXDSIZ32))
   1485 			alim.rlim_cur = MAXDSIZ32;
   1486 		if (LIMITCHECK(alim.rlim_max, MAXDSIZ32))
   1487 			alim.rlim_max = MAXDSIZ32;
   1488 		break;
   1489 
   1490 	case RLIMIT_STACK:
   1491 		if (LIMITCHECK(alim.rlim_cur, MAXSSIZ32))
   1492 			alim.rlim_cur = MAXSSIZ32;
   1493 		if (LIMITCHECK(alim.rlim_max, MAXSSIZ32))
   1494 			alim.rlim_max = MAXSSIZ32;
   1495 	default:
   1496 		break;
   1497 	}
   1498 
   1499 	return (dosetrlimit(l, l->l_proc, which, &alim));
   1500 }
   1501 
   1502 int
   1503 netbsd32_mmap(struct lwp *l, const struct netbsd32_mmap_args *uap, register_t *retval)
   1504 {
   1505 	/* {
   1506 		syscallarg(netbsd32_voidp) addr;
   1507 		syscallarg(netbsd32_size_t) len;
   1508 		syscallarg(int) prot;
   1509 		syscallarg(int) flags;
   1510 		syscallarg(int) fd;
   1511 		syscallarg(netbsd32_long) PAD;
   1512 		syscallarg(off_t) pos;
   1513 	} */
   1514 	struct sys_mmap_args ua;
   1515 	int error;
   1516 
   1517 	NETBSD32TOP_UAP(addr, void);
   1518 	NETBSD32TOX_UAP(len, size_t);
   1519 	NETBSD32TO64_UAP(prot);
   1520 	NETBSD32TO64_UAP(flags);
   1521 	NETBSD32TO64_UAP(fd);
   1522 	NETBSD32TOX_UAP(PAD, long);
   1523 	NETBSD32TOX_UAP(pos, off_t);
   1524 	error = sys_mmap(l, &ua, retval);
   1525 	if ((u_long)*retval > (u_long)UINT_MAX) {
   1526 		printf("netbsd32_mmap: retval out of range: 0x%lx",
   1527 		    (u_long)*retval);
   1528 		/* Should try to recover and return an error here. */
   1529 	}
   1530 	return (error);
   1531 }
   1532 
   1533 int
   1534 netbsd32_mremap(struct lwp *l, const struct netbsd32_mremap_args *uap, register_t *retval)
   1535 {
   1536 	/* {
   1537 		syscallarg(void *) old_address;
   1538 		syscallarg(size_t) old_size;
   1539 		syscallarg(void *) new_address;
   1540 		syscallarg(size_t) new_size;
   1541 		syscallarg(int) flags;
   1542 	} */
   1543 	struct sys_mremap_args ua;
   1544 
   1545 	NETBSD32TOP_UAP(old_address, void);
   1546 	NETBSD32TOX_UAP(old_size, size_t);
   1547 	NETBSD32TOP_UAP(new_address, void);
   1548 	NETBSD32TOX_UAP(new_size, size_t);
   1549 	NETBSD32TO64_UAP(flags);
   1550 
   1551 	return sys_mremap(l, &ua, retval);
   1552 }
   1553 
   1554 int
   1555 netbsd32_lseek(struct lwp *l, const struct netbsd32_lseek_args *uap, register_t *retval)
   1556 {
   1557 	/* {
   1558 		syscallarg(int) fd;
   1559 		syscallarg(int) PAD;
   1560 		syscallarg(off_t) offset;
   1561 		syscallarg(int) whence;
   1562 	} */
   1563 	struct sys_lseek_args ua;
   1564 	union {
   1565 	    register_t retval64[2];
   1566 	    register32_t retval32[4];
   1567 	} newpos;
   1568 	int rv;
   1569 
   1570 	NETBSD32TO64_UAP(fd);
   1571 	NETBSD32TO64_UAP(PAD);
   1572 	NETBSD32TO64_UAP(offset);
   1573 	NETBSD32TO64_UAP(whence);
   1574 	rv = sys_lseek(l, &ua, newpos.retval64);
   1575 
   1576 	/*
   1577 	 * We have to split the 64 bit value into 2 halves which will
   1578 	 * end up in separate 32 bit registers.
   1579 	 * This should DTRT on big and little-endian systems provided that
   1580 	 * gcc's 'strict aliasing' tests don't decide that the retval32[]
   1581 	 * entries can't have been assigned to, so need not be read!
   1582 	 */
   1583 	retval[0] = newpos.retval32[0];
   1584 	retval[1] = newpos.retval32[1];
   1585 
   1586 	return rv;
   1587 }
   1588 
   1589 int
   1590 netbsd32_truncate(struct lwp *l, const struct netbsd32_truncate_args *uap, register_t *retval)
   1591 {
   1592 	/* {
   1593 		syscallarg(const netbsd32_charp) path;
   1594 		syscallarg(int) PAD;
   1595 		syscallarg(off_t) length;
   1596 	} */
   1597 	struct sys_truncate_args ua;
   1598 
   1599 	NETBSD32TOP_UAP(path, const char);
   1600 	NETBSD32TO64_UAP(PAD);
   1601 	NETBSD32TO64_UAP(length);
   1602 	return (sys_truncate(l, &ua, retval));
   1603 }
   1604 
   1605 int
   1606 netbsd32_ftruncate(struct lwp *l, const struct netbsd32_ftruncate_args *uap, register_t *retval)
   1607 {
   1608 	/* {
   1609 		syscallarg(int) fd;
   1610 		syscallarg(int) PAD;
   1611 		syscallarg(off_t) length;
   1612 	} */
   1613 	struct sys_ftruncate_args ua;
   1614 
   1615 	NETBSD32TO64_UAP(fd);
   1616 	NETBSD32TO64_UAP(PAD);
   1617 	NETBSD32TO64_UAP(length);
   1618 	return (sys_ftruncate(l, &ua, retval));
   1619 }
   1620 
   1621 int
   1622 netbsd32_mlock(struct lwp *l, const struct netbsd32_mlock_args *uap, register_t *retval)
   1623 {
   1624 	/* {
   1625 		syscallarg(const netbsd32_voidp) addr;
   1626 		syscallarg(netbsd32_size_t) len;
   1627 	} */
   1628 	struct sys_mlock_args ua;
   1629 
   1630 	NETBSD32TOP_UAP(addr, const void);
   1631 	NETBSD32TO64_UAP(len);
   1632 	return (sys_mlock(l, &ua, retval));
   1633 }
   1634 
   1635 int
   1636 netbsd32_munlock(struct lwp *l, const struct netbsd32_munlock_args *uap, register_t *retval)
   1637 {
   1638 	/* {
   1639 		syscallarg(const netbsd32_voidp) addr;
   1640 		syscallarg(netbsd32_size_t) len;
   1641 	} */
   1642 	struct sys_munlock_args ua;
   1643 
   1644 	NETBSD32TOP_UAP(addr, const void);
   1645 	NETBSD32TO64_UAP(len);
   1646 	return (sys_munlock(l, &ua, retval));
   1647 }
   1648 
   1649 int
   1650 netbsd32_undelete(struct lwp *l, const struct netbsd32_undelete_args *uap, register_t *retval)
   1651 {
   1652 	/* {
   1653 		syscallarg(const netbsd32_charp) path;
   1654 	} */
   1655 	struct sys_undelete_args ua;
   1656 
   1657 	NETBSD32TOP_UAP(path, const char);
   1658 	return (sys_undelete(l, &ua, retval));
   1659 }
   1660 
   1661 int
   1662 netbsd32_getpgid(struct lwp *l, const struct netbsd32_getpgid_args *uap, register_t *retval)
   1663 {
   1664 	/* {
   1665 		syscallarg(pid_t) pid;
   1666 	} */
   1667 	struct sys_getpgid_args ua;
   1668 
   1669 	NETBSD32TO64_UAP(pid);
   1670 	return (sys_getpgid(l, &ua, retval));
   1671 }
   1672 
   1673 int
   1674 netbsd32_reboot(struct lwp *l, const struct netbsd32_reboot_args *uap, register_t *retval)
   1675 {
   1676 	/* {
   1677 		syscallarg(int) opt;
   1678 		syscallarg(netbsd32_charp) bootstr;
   1679 	} */
   1680 	struct sys_reboot_args ua;
   1681 
   1682 	NETBSD32TO64_UAP(opt);
   1683 	NETBSD32TOP_UAP(bootstr, char);
   1684 	return (sys_reboot(l, &ua, retval));
   1685 }
   1686 
   1687 #include <sys/poll.h>
   1688 int
   1689 netbsd32_poll(struct lwp *l, const struct netbsd32_poll_args *uap, register_t *retval)
   1690 {
   1691 	/* {
   1692 		syscallarg(netbsd32_pollfdp_t) fds;
   1693 		syscallarg(u_int) nfds;
   1694 		syscallarg(int) timeout;
   1695 	} */
   1696 	struct sys_poll_args ua;
   1697 
   1698 	NETBSD32TOP_UAP(fds, struct pollfd);
   1699 	NETBSD32TO64_UAP(nfds);
   1700 	NETBSD32TO64_UAP(timeout);
   1701 
   1702 	return (sys_poll(l, &ua, retval));
   1703 }
   1704 
   1705 int
   1706 netbsd32_fdatasync(struct lwp *l, const struct netbsd32_fdatasync_args *uap, register_t *retval)
   1707 {
   1708 	/* {
   1709 		syscallarg(int) fd;
   1710 	} */
   1711 	struct sys_fdatasync_args ua;
   1712 
   1713 	NETBSD32TO64_UAP(fd);
   1714 	return (sys_fdatasync(l, &ua, retval));
   1715 }
   1716 
   1717 int
   1718 netbsd32___posix_rename(struct lwp *l, const struct netbsd32___posix_rename_args *uap, register_t *retval)
   1719 {
   1720 	/* {
   1721 		syscallarg(const netbsd32_charp) from;
   1722 		syscallarg(const netbsd32_charp) to;
   1723 	} */
   1724 	struct sys___posix_rename_args ua;
   1725 
   1726 	NETBSD32TOP_UAP(from, const char);
   1727 	NETBSD32TOP_UAP(to, const char);
   1728 	return (sys___posix_rename(l, &ua, retval));
   1729 }
   1730 
   1731 int
   1732 netbsd32_swapctl(struct lwp *l, const struct netbsd32_swapctl_args *uap, register_t *retval)
   1733 {
   1734 	/* {
   1735 		syscallarg(int) cmd;
   1736 		syscallarg(const netbsd32_voidp) arg;
   1737 		syscallarg(int) misc;
   1738 	} */
   1739 	struct sys_swapctl_args ua;
   1740 
   1741 	NETBSD32TO64_UAP(cmd);
   1742 	NETBSD32TOP_UAP(arg, void);
   1743 	NETBSD32TO64_UAP(misc);
   1744 	return (sys_swapctl(l, &ua, retval));
   1745 }
   1746 
   1747 int
   1748 netbsd32_minherit(struct lwp *l, const struct netbsd32_minherit_args *uap, register_t *retval)
   1749 {
   1750 	/* {
   1751 		syscallarg(netbsd32_voidp) addr;
   1752 		syscallarg(netbsd32_size_t) len;
   1753 		syscallarg(int) inherit;
   1754 	} */
   1755 	struct sys_minherit_args ua;
   1756 
   1757 	NETBSD32TOP_UAP(addr, void);
   1758 	NETBSD32TOX_UAP(len, size_t);
   1759 	NETBSD32TO64_UAP(inherit);
   1760 	return (sys_minherit(l, &ua, retval));
   1761 }
   1762 
   1763 int
   1764 netbsd32_lchmod(struct lwp *l, const struct netbsd32_lchmod_args *uap, register_t *retval)
   1765 {
   1766 	/* {
   1767 		syscallarg(const netbsd32_charp) path;
   1768 		syscallarg(mode_t) mode;
   1769 	} */
   1770 	struct sys_lchmod_args ua;
   1771 
   1772 	NETBSD32TOP_UAP(path, const char);
   1773 	NETBSD32TO64_UAP(mode);
   1774 	return (sys_lchmod(l, &ua, retval));
   1775 }
   1776 
   1777 int
   1778 netbsd32_lchown(struct lwp *l, const struct netbsd32_lchown_args *uap, register_t *retval)
   1779 {
   1780 	/* {
   1781 		syscallarg(const netbsd32_charp) path;
   1782 		syscallarg(uid_t) uid;
   1783 		syscallarg(gid_t) gid;
   1784 	} */
   1785 	struct sys_lchown_args ua;
   1786 
   1787 	NETBSD32TOP_UAP(path, const char);
   1788 	NETBSD32TO64_UAP(uid);
   1789 	NETBSD32TO64_UAP(gid);
   1790 	return (sys_lchown(l, &ua, retval));
   1791 }
   1792 
   1793 int
   1794 netbsd32___msync13(struct lwp *l, const struct netbsd32___msync13_args *uap, register_t *retval)
   1795 {
   1796 	/* {
   1797 		syscallarg(netbsd32_voidp) addr;
   1798 		syscallarg(netbsd32_size_t) len;
   1799 		syscallarg(int) flags;
   1800 	} */
   1801 	struct sys___msync13_args ua;
   1802 
   1803 	NETBSD32TOP_UAP(addr, void);
   1804 	NETBSD32TOX_UAP(len, size_t);
   1805 	NETBSD32TO64_UAP(flags);
   1806 	return (sys___msync13(l, &ua, retval));
   1807 }
   1808 
   1809 int
   1810 netbsd32___posix_chown(struct lwp *l, const struct netbsd32___posix_chown_args *uap, register_t *retval)
   1811 {
   1812 	/* {
   1813 		syscallarg(const netbsd32_charp) path;
   1814 		syscallarg(uid_t) uid;
   1815 		syscallarg(gid_t) gid;
   1816 	} */
   1817 	struct sys___posix_chown_args ua;
   1818 
   1819 	NETBSD32TOP_UAP(path, const char);
   1820 	NETBSD32TO64_UAP(uid);
   1821 	NETBSD32TO64_UAP(gid);
   1822 	return (sys___posix_chown(l, &ua, retval));
   1823 }
   1824 
   1825 int
   1826 netbsd32___posix_fchown(struct lwp *l, const struct netbsd32___posix_fchown_args *uap, register_t *retval)
   1827 {
   1828 	/* {
   1829 		syscallarg(int) fd;
   1830 		syscallarg(uid_t) uid;
   1831 		syscallarg(gid_t) gid;
   1832 	} */
   1833 	struct sys___posix_fchown_args ua;
   1834 
   1835 	NETBSD32TO64_UAP(fd);
   1836 	NETBSD32TO64_UAP(uid);
   1837 	NETBSD32TO64_UAP(gid);
   1838 	return (sys___posix_fchown(l, &ua, retval));
   1839 }
   1840 
   1841 int
   1842 netbsd32___posix_lchown(struct lwp *l, const struct netbsd32___posix_lchown_args *uap, register_t *retval)
   1843 {
   1844 	/* {
   1845 		syscallarg(const netbsd32_charp) path;
   1846 		syscallarg(uid_t) uid;
   1847 		syscallarg(gid_t) gid;
   1848 	} */
   1849 	struct sys___posix_lchown_args ua;
   1850 
   1851 	NETBSD32TOP_UAP(path, const char);
   1852 	NETBSD32TO64_UAP(uid);
   1853 	NETBSD32TO64_UAP(gid);
   1854 	return (sys___posix_lchown(l, &ua, retval));
   1855 }
   1856 
   1857 int
   1858 netbsd32_getsid(struct lwp *l, const struct netbsd32_getsid_args *uap, register_t *retval)
   1859 {
   1860 	/* {
   1861 		syscallarg(pid_t) pid;
   1862 	} */
   1863 	struct sys_getsid_args ua;
   1864 
   1865 	NETBSD32TO64_UAP(pid);
   1866 	return (sys_getsid(l, &ua, retval));
   1867 }
   1868 
   1869 int
   1870 netbsd32_fktrace(struct lwp *l, const struct netbsd32_fktrace_args *uap, register_t *retval)
   1871 {
   1872 	/* {
   1873 		syscallarg(int) fd;
   1874 		syscallarg(int) ops;
   1875 		syscallarg(int) facs;
   1876 		syscallarg(int) pid;
   1877 	} */
   1878 	struct sys_fktrace_args ua;
   1879 
   1880 	NETBSD32TOX_UAP(fd, int);
   1881 	NETBSD32TO64_UAP(ops);
   1882 	NETBSD32TO64_UAP(facs);
   1883 	NETBSD32TO64_UAP(pid);
   1884 	return (sys_fktrace(l, &ua, retval));
   1885 }
   1886 
   1887 int
   1888 netbsd32___sigpending14(struct lwp *l, const struct netbsd32___sigpending14_args *uap, register_t *retval)
   1889 {
   1890 	/* {
   1891 		syscallarg(sigset_t *) set;
   1892 	} */
   1893 	struct sys___sigpending14_args ua;
   1894 
   1895 	NETBSD32TOP_UAP(set, sigset_t);
   1896 	return (sys___sigpending14(l, &ua, retval));
   1897 }
   1898 
   1899 int
   1900 netbsd32___sigprocmask14(struct lwp *l, const struct netbsd32___sigprocmask14_args *uap, register_t *retval)
   1901 {
   1902 	/* {
   1903 		syscallarg(int) how;
   1904 		syscallarg(const sigset_t *) set;
   1905 		syscallarg(sigset_t *) oset;
   1906 	} */
   1907 	struct sys___sigprocmask14_args ua;
   1908 
   1909 	NETBSD32TO64_UAP(how);
   1910 	NETBSD32TOP_UAP(set, sigset_t);
   1911 	NETBSD32TOP_UAP(oset, sigset_t);
   1912 	return (sys___sigprocmask14(l, &ua, retval));
   1913 }
   1914 
   1915 int
   1916 netbsd32___sigsuspend14(struct lwp *l, const struct netbsd32___sigsuspend14_args *uap, register_t *retval)
   1917 {
   1918 	/* {
   1919 		syscallarg(const sigset_t *) set;
   1920 	} */
   1921 	struct sys___sigsuspend14_args ua;
   1922 
   1923 	NETBSD32TOP_UAP(set, sigset_t);
   1924 	return (sys___sigsuspend14(l, &ua, retval));
   1925 }
   1926 
   1927 int
   1928 netbsd32_fchroot(struct lwp *l, const struct netbsd32_fchroot_args *uap, register_t *retval)
   1929 {
   1930 	/* {
   1931 		syscallarg(int) fd;
   1932 	} */
   1933 	struct sys_fchroot_args ua;
   1934 
   1935 	NETBSD32TO64_UAP(fd);
   1936 	return (sys_fchroot(l, &ua, retval));
   1937 }
   1938 
   1939 /*
   1940  * Open a file given a file handle.
   1941  *
   1942  * Check permissions, allocate an open file structure,
   1943  * and call the device open routine if any.
   1944  */
   1945 int
   1946 netbsd32___fhopen40(struct lwp *l, const struct netbsd32___fhopen40_args *uap, register_t *retval)
   1947 {
   1948 	/* {
   1949 		syscallarg(const netbsd32_pointer_t *) fhp;
   1950 		syscallarg(netbsd32_size_t) fh_size;
   1951 		syscallarg(int) flags;
   1952 	} */
   1953 	struct sys___fhopen40_args ua;
   1954 
   1955 	NETBSD32TOP_UAP(fhp, fhandle_t);
   1956 	NETBSD32TO64_UAP(fh_size);
   1957 	NETBSD32TO64_UAP(flags);
   1958 	return (sys___fhopen40(l, &ua, retval));
   1959 }
   1960 
   1961 /* virtual memory syscalls */
   1962 int
   1963 netbsd32_ovadvise(struct lwp *l, const struct netbsd32_ovadvise_args *uap, register_t *retval)
   1964 {
   1965 	/* {
   1966 		syscallarg(int) anom;
   1967 	} */
   1968 	struct sys_ovadvise_args ua;
   1969 
   1970 	NETBSD32TO64_UAP(anom);
   1971 	return (sys_ovadvise(l, &ua, retval));
   1972 }
   1973 
   1974 void
   1975 netbsd32_adjust_limits(struct proc *p)
   1976 {
   1977 	static const struct {
   1978 		int id;
   1979 		rlim_t lim;
   1980 	} lm[] = {
   1981 		{ RLIMIT_DATA,	MAXDSIZ32 },
   1982 		{ RLIMIT_STACK, MAXSSIZ32 },
   1983 	};
   1984 	size_t i;
   1985 	struct plimit *lim;
   1986 	struct rlimit *rlim;
   1987 
   1988 	/*
   1989 	 * We can only reduce the current limits, we cannot stop external
   1990 	 * processes from changing them (eg via sysctl) later on.
   1991 	 * So there is no point trying to lock out such changes here.
   1992 	 *
   1993 	 * If we assume that rlim_cur/max are accessed using atomic
   1994 	 * operations, we don't need to lock against any other updates
   1995 	 * that might happen if the plimit structure is shared writable
   1996 	 * between multiple processes.
   1997 	 */
   1998 
   1999 	/* Scan to determine is any limits are out of range */
   2000 	lim = p->p_limit;
   2001 	for (i = 0; ; i++) {
   2002 		if (i >= __arraycount(lm))
   2003 			/* All in range */
   2004 			return;
   2005 		rlim = lim->pl_rlimit + lm[i].id;
   2006 		if (LIMITCHECK(rlim->rlim_cur, lm[i].lim))
   2007 			break;
   2008 		if (LIMITCHECK(rlim->rlim_max, lm[i].lim))
   2009 			break;
   2010 	}
   2011 
   2012 	lim_privatise(p);
   2013 
   2014 	lim = p->p_limit;
   2015 	for (i = 0; i < __arraycount(lm); i++) {
   2016 		rlim = lim->pl_rlimit + lm[i].id;
   2017 		if (LIMITCHECK(rlim->rlim_cur, lm[i].lim))
   2018 			rlim->rlim_cur = lm[i].lim;
   2019 		if (LIMITCHECK(rlim->rlim_max, lm[i].lim))
   2020 			rlim->rlim_max = lm[i].lim;
   2021 	}
   2022 }
   2023 
   2024 int
   2025 netbsd32_uuidgen(struct lwp *l, const struct netbsd32_uuidgen_args *uap, register_t *retval)
   2026 {
   2027 	/* {
   2028 		syscallarg(netbsd32_uuidp_t) store;
   2029 		syscallarg(int) count;
   2030 	} */
   2031 	struct sys_uuidgen_args ua;
   2032 
   2033 	NETBSD32TOP_UAP(store, struct uuid);
   2034 	NETBSD32TO64_UAP(count);
   2035 	return (sys_uuidgen(l, &ua, retval));
   2036 }
   2037 
   2038 int
   2039 netbsd32_extattrctl(struct lwp *l, const struct netbsd32_extattrctl_args *uap, register_t *retval)
   2040 {
   2041 	/* {
   2042 		syscallarg(const netbsd32_charp) path;
   2043 		syscallarg(int) cmd;
   2044 		syscallarg(const netbsd32_charp) filename;
   2045 		syscallarg(int) attrnamespace;
   2046 		syscallarg(const netbsd32_charp) attrname;
   2047 	} */
   2048 	struct sys_extattrctl_args ua;
   2049 
   2050 	NETBSD32TOP_UAP(path, const char);
   2051 	NETBSD32TO64_UAP(cmd);
   2052 	NETBSD32TOP_UAP(filename, const char);
   2053 	NETBSD32TO64_UAP(attrnamespace);
   2054 	NETBSD32TOP_UAP(attrname, const char);
   2055 	return sys_extattrctl(l, &ua, retval);
   2056 }
   2057 
   2058 int
   2059 netbsd32_extattr_set_fd(struct lwp *l, const struct netbsd32_extattr_set_fd_args *uap, register_t *retval)
   2060 {
   2061 	/* {
   2062 		syscallarg(int) fd;
   2063 		syscallarg(int) attrnamespace;
   2064 		syscallarg(const netbsd32_charp) attrname;
   2065 		syscallarg(const netbsd32_voidp) data;
   2066 		syscallarg(netbsd32_size_t) nbytes;
   2067 	} */
   2068 	struct sys_extattr_set_fd_args ua;
   2069 
   2070 	NETBSD32TO64_UAP(fd);
   2071 	NETBSD32TO64_UAP(attrnamespace);
   2072 	NETBSD32TOP_UAP(attrname, const char);
   2073 	NETBSD32TOP_UAP(data, const void);
   2074 	NETBSD32TOX_UAP(nbytes, size_t);
   2075 	return sys_extattr_set_fd(l, &ua, retval);
   2076 }
   2077 
   2078 int
   2079 netbsd32_extattr_set_file(struct lwp *l, const struct netbsd32_extattr_set_file_args *uap, register_t *retval)
   2080 {
   2081 	/* {
   2082 		syscallarg(const netbsd32_charp) path;
   2083 		syscallarg(int) attrnamespace;
   2084 		syscallarg(const netbsd32_charp) attrname;
   2085 		syscallarg(const netbsd32_voidp) data;
   2086 		syscallarg(netbsd32_size_t) nbytes;
   2087 	} */
   2088 	struct sys_extattr_set_file_args ua;
   2089 
   2090 	NETBSD32TOP_UAP(path, const char);
   2091 	NETBSD32TO64_UAP(attrnamespace);
   2092 	NETBSD32TOP_UAP(attrname, const char);
   2093 	NETBSD32TOP_UAP(data, const void);
   2094 	NETBSD32TOX_UAP(nbytes, size_t);
   2095 	return sys_extattr_set_file(l, &ua, retval);
   2096 }
   2097 
   2098 int
   2099 netbsd32_extattr_set_link(struct lwp *l, const struct netbsd32_extattr_set_link_args *uap, register_t *retval)
   2100 {
   2101 	/* {
   2102 		syscallarg(const netbsd32_charp) path;
   2103 		syscallarg(int) attrnamespace;
   2104 		syscallarg(const netbsd32_charp) attrname;
   2105 		syscallarg(const netbsd32_voidp) data;
   2106 		syscallarg(netbsd32_size_t) nbytes;
   2107 	} */
   2108 	struct sys_extattr_set_link_args ua;
   2109 
   2110 	NETBSD32TOP_UAP(path, const char);
   2111 	NETBSD32TO64_UAP(attrnamespace);
   2112 	NETBSD32TOP_UAP(attrname, const char);
   2113 	NETBSD32TOP_UAP(data, const void);
   2114 	NETBSD32TOX_UAP(nbytes, size_t);
   2115 	return sys_extattr_set_link(l, &ua, retval);
   2116 }
   2117 
   2118 int
   2119 netbsd32_extattr_get_fd(struct lwp *l, const struct netbsd32_extattr_get_fd_args *uap, register_t *retval)
   2120 {
   2121 	/* {
   2122 		syscallarg(int) fd;
   2123 		syscallarg(int) attrnamespace;
   2124 		syscallarg(const netbsd32_charp) attrname;
   2125 		syscallarg(netbsd32_voidp) data;
   2126 		syscallarg(netbsd32_size_t) nbytes;
   2127 	} */
   2128 	struct sys_extattr_get_fd_args ua;
   2129 
   2130 	NETBSD32TO64_UAP(fd);
   2131 	NETBSD32TO64_UAP(attrnamespace);
   2132 	NETBSD32TOP_UAP(attrname, const char);
   2133 	NETBSD32TOP_UAP(data, void);
   2134 	NETBSD32TOX_UAP(nbytes, size_t);
   2135 	return sys_extattr_get_fd(l, &ua, retval);
   2136 }
   2137 
   2138 int
   2139 netbsd32_extattr_get_file(struct lwp *l, const struct netbsd32_extattr_get_file_args *uap, register_t *retval)
   2140 {
   2141 	/* {
   2142 		syscallarg(const netbsd32_charp) path;
   2143 		syscallarg(int) attrnamespace;
   2144 		syscallarg(const netbsd32_charp) attrname;
   2145 		syscallarg(netbsd32_voidp) data;
   2146 		syscallarg(netbsd32_size_t) nbytes;
   2147 	} */
   2148 	struct sys_extattr_get_file_args ua;
   2149 
   2150 	NETBSD32TOP_UAP(path, const char);
   2151 	NETBSD32TO64_UAP(attrnamespace);
   2152 	NETBSD32TOP_UAP(attrname, const char);
   2153 	NETBSD32TOP_UAP(data, void);
   2154 	NETBSD32TOX_UAP(nbytes, size_t);
   2155 	return sys_extattr_get_file(l, &ua, retval);
   2156 }
   2157 
   2158 int
   2159 netbsd32_extattr_get_link(struct lwp *l, const struct netbsd32_extattr_get_link_args *uap, register_t *retval)
   2160 {
   2161 	/* {
   2162 		syscallarg(const netbsd32_charp) path;
   2163 		syscallarg(int) attrnamespace;
   2164 		syscallarg(const netbsd32_charp) attrname;
   2165 		syscallarg(netbsd32_voidp) data;
   2166 		syscallarg(netbsd32_size_t) nbytes;
   2167 	} */
   2168 	struct sys_extattr_get_link_args ua;
   2169 
   2170 	NETBSD32TOP_UAP(path, const char);
   2171 	NETBSD32TO64_UAP(attrnamespace);
   2172 	NETBSD32TOP_UAP(attrname, const char);
   2173 	NETBSD32TOP_UAP(data, void);
   2174 	NETBSD32TOX_UAP(nbytes, size_t);
   2175 	return sys_extattr_get_link(l, &ua, retval);
   2176 }
   2177 
   2178 int
   2179 netbsd32_extattr_delete_fd(struct lwp *l, const struct netbsd32_extattr_delete_fd_args *uap, register_t *retval)
   2180 {
   2181 	/* {
   2182 		syscallarg(int) fd;
   2183 		syscallarg(int) attrnamespace;
   2184 		syscallarg(const netbsd32_charp) attrname;
   2185 	} */
   2186 	struct sys_extattr_delete_fd_args ua;
   2187 
   2188 	NETBSD32TO64_UAP(fd);
   2189 	NETBSD32TO64_UAP(attrnamespace);
   2190 	NETBSD32TOP_UAP(attrname, const char);
   2191 	return sys_extattr_delete_fd(l, &ua, retval);
   2192 }
   2193 
   2194 int
   2195 netbsd32_extattr_delete_file(struct lwp *l, const struct netbsd32_extattr_delete_file_args *uap, register_t *retval)
   2196 {
   2197 	/* {
   2198 		syscallarg(const netbsd32_charp) path;
   2199 		syscallarg(int) attrnamespace;
   2200 		syscallarg(const netbsd32_charp) attrname;
   2201 	} */
   2202 	struct sys_extattr_delete_file_args ua;
   2203 
   2204 	NETBSD32TOP_UAP(path, const char);
   2205 	NETBSD32TO64_UAP(attrnamespace);
   2206 	NETBSD32TOP_UAP(attrname, const char);
   2207 	return sys_extattr_delete_file(l, &ua, retval);
   2208 }
   2209 
   2210 int
   2211 netbsd32_extattr_delete_link(struct lwp *l, const struct netbsd32_extattr_delete_link_args *uap, register_t *retval)
   2212 {
   2213 	/* {
   2214 		syscallarg(const netbsd32_charp) path;
   2215 		syscallarg(int) attrnamespace;
   2216 		syscallarg(const netbsd32_charp) attrname;
   2217 	} */
   2218 	struct sys_extattr_delete_link_args ua;
   2219 
   2220 	NETBSD32TOP_UAP(path, const char);
   2221 	NETBSD32TO64_UAP(attrnamespace);
   2222 	NETBSD32TOP_UAP(attrname, const char);
   2223 	return sys_extattr_delete_link(l, &ua, retval);
   2224 }
   2225 
   2226 int
   2227 netbsd32_extattr_list_fd(struct lwp *l, const struct netbsd32_extattr_list_fd_args *uap, register_t *retval)
   2228 {
   2229 	/* {
   2230 		syscallarg(int) fd;
   2231 		syscallarg(int) attrnamespace;
   2232 		syscallarg(netbsd32_voidp) data;
   2233 		syscallarg(netbsd32_size_t) nbytes;
   2234 	} */
   2235 	struct sys_extattr_list_fd_args ua;
   2236 
   2237 	NETBSD32TO64_UAP(fd);
   2238 	NETBSD32TO64_UAP(attrnamespace);
   2239 	NETBSD32TOP_UAP(data, void);
   2240 	NETBSD32TOX_UAP(nbytes, size_t);
   2241 	return sys_extattr_list_fd(l, &ua, retval);
   2242 }
   2243 
   2244 int
   2245 netbsd32_extattr_list_file(struct lwp *l, const struct netbsd32_extattr_list_file_args *uap, register_t *retval)
   2246 {
   2247 	/* {
   2248 		syscallarg(const netbsd32_charp) path;
   2249 		syscallarg(int) attrnamespace;
   2250 		syscallarg(netbsd32_voidp) data;
   2251 		syscallarg(netbsd32_size_t) nbytes;
   2252 	} */
   2253 	struct sys_extattr_list_file_args ua;
   2254 
   2255 	NETBSD32TOP_UAP(path, const char);
   2256 	NETBSD32TO64_UAP(attrnamespace);
   2257 	NETBSD32TOP_UAP(data, void);
   2258 	NETBSD32TOX_UAP(nbytes, size_t);
   2259 	return sys_extattr_list_file(l, &ua, retval);
   2260 }
   2261 
   2262 int
   2263 netbsd32_extattr_list_link(struct lwp *l, const struct netbsd32_extattr_list_link_args *uap, register_t *retval)
   2264 {
   2265 	/* {
   2266 		syscallarg(const netbsd32_charp) path;
   2267 		syscallarg(int) attrnamespace;
   2268 		syscallarg(netbsd32_voidp) data;
   2269 		syscallarg(netbsd32_size_t) nbytes;
   2270 	} */
   2271 	struct sys_extattr_list_link_args ua;
   2272 
   2273 	NETBSD32TOP_UAP(path, const char);
   2274 	NETBSD32TO64_UAP(attrnamespace);
   2275 	NETBSD32TOP_UAP(data, void);
   2276 	NETBSD32TOX_UAP(nbytes, size_t);
   2277 	return sys_extattr_list_link(l, &ua, retval);
   2278 }
   2279 
   2280 int
   2281 netbsd32_mlockall(struct lwp *l, const struct netbsd32_mlockall_args *uap, register_t *retval)
   2282 {
   2283 	/* {
   2284 		syscallarg(int) flags;
   2285 	} */
   2286 	struct sys_mlockall_args ua;
   2287 
   2288 	NETBSD32TO64_UAP(flags);
   2289 	return (sys_mlockall(l, &ua, retval));
   2290 }
   2291 
   2292 int
   2293 netbsd32___clone(struct lwp *l, const struct netbsd32___clone_args *uap, register_t *retval)
   2294 {
   2295 	/*  {
   2296 		syscallarg(int) flags;
   2297 		syscallarg(netbsd32_voidp) stack;
   2298 	} */
   2299 	struct sys___clone_args ua;
   2300 
   2301 	NETBSD32TO64_UAP(flags);
   2302 	NETBSD32TOP_UAP(stack, void);
   2303 	return sys___clone(l, &ua, retval);
   2304 }
   2305 
   2306 int
   2307 netbsd32_fsync_range(struct lwp *l, const struct netbsd32_fsync_range_args *uap, register_t *retval)
   2308 {
   2309 	/* {
   2310 		syscallarg(int) fd;
   2311 		syscallarg(int) flags;
   2312 		syscallarg(off_t) start;
   2313 		syscallarg(off_t) length;
   2314 	} */
   2315 	struct sys_fsync_range_args ua;
   2316 
   2317 	NETBSD32TO64_UAP(fd);
   2318 	NETBSD32TO64_UAP(flags);
   2319 	NETBSD32TO64_UAP(start);
   2320 	NETBSD32TO64_UAP(length);
   2321 	return (sys_fsync_range(l, &ua, retval));
   2322 }
   2323 
   2324 int
   2325 netbsd32_rasctl(struct lwp *l, const struct netbsd32_rasctl_args *uap, register_t *retval)
   2326 {
   2327 	/* {
   2328 		syscallarg(netbsd32_voidp) addr;
   2329 		syscallarg(netbsd32_size_t) len;
   2330 		syscallarg(int) op;
   2331 	} */
   2332 	struct sys_rasctl_args ua;
   2333 
   2334 	NETBSD32TOP_UAP(addr, void *);
   2335 	NETBSD32TOX_UAP(len, size_t);
   2336 	NETBSD32TO64_UAP(op);
   2337 	return sys_rasctl(l, &ua, retval);
   2338 }
   2339 
   2340 int
   2341 netbsd32_setxattr(struct lwp *l, const struct netbsd32_setxattr_args *uap, register_t *retval)
   2342 {
   2343 	/* {
   2344 		syscallarg(const netbsd32_charp) path;
   2345 		syscallarg(const netbsd32_charp) name;
   2346 		syscallarg(netbsd32_voidp) value;
   2347 		syscallarg(netbsd32_size_t) size;
   2348 		syscallarg(int) flags;
   2349 	} */
   2350 	struct sys_setxattr_args ua;
   2351 	NETBSD32TOP_UAP(path, const char);
   2352 	NETBSD32TOP_UAP(name, const char);
   2353 	NETBSD32TOP_UAP(value, void);
   2354 	NETBSD32TOX_UAP(size, size_t);
   2355 	NETBSD32TO64_UAP(flags);
   2356 	return sys_setxattr(l, &ua, retval);
   2357 }
   2358 
   2359 int
   2360 netbsd32_lsetxattr(struct lwp *l, const struct netbsd32_lsetxattr_args *uap, register_t *retval)
   2361 {
   2362 	/* {
   2363 		syscallarg(const netbsd32_charp) path;
   2364 		syscallarg(const netbsd32_charp) name;
   2365 		syscallarg(netbsd32_voidp) value;
   2366 		syscallarg(netbsd32_size_t) size;
   2367 		syscallarg(int) flags;
   2368 	} */
   2369 	struct sys_lsetxattr_args ua;
   2370 	NETBSD32TOP_UAP(path, const char);
   2371 	NETBSD32TOP_UAP(name, const char);
   2372 	NETBSD32TOP_UAP(value, void);
   2373 	NETBSD32TOX_UAP(size, size_t);
   2374 	NETBSD32TO64_UAP(flags);
   2375 	return sys_lsetxattr(l, &ua, retval);
   2376 }
   2377 
   2378 int
   2379 netbsd32_fsetxattr(struct lwp *l, const struct netbsd32_fsetxattr_args *uap, register_t *retval)
   2380 {
   2381 	/* {
   2382 		syscallarg(int) fd;
   2383 		syscallarg(const netbsd32_charp) name;
   2384 		syscallarg(netbsd32_voidp) value;
   2385 		syscallarg(netbsd32_size_t) size;
   2386 		syscallarg(int) flags;
   2387 	} */
   2388 	struct sys_fsetxattr_args ua;
   2389 	NETBSD32TO64_UAP(fd);
   2390 	NETBSD32TOP_UAP(name, const char);
   2391 	NETBSD32TOP_UAP(value, void);
   2392 	NETBSD32TOX_UAP(size, size_t);
   2393 	NETBSD32TO64_UAP(flags);
   2394 	return sys_fsetxattr(l, &ua, retval);
   2395 }
   2396 
   2397 int
   2398 netbsd32_getxattr(struct lwp *l, const struct netbsd32_getxattr_args *uap, register_t *retval)
   2399 {
   2400 	/* {
   2401 		syscallarg(const netbsd32_charp) path;
   2402 		syscallarg(const netbsd32_charp) name;
   2403 		syscallarg(netbsd32_voidp) value;
   2404 		syscallarg(netbsd32_size_t) size;
   2405 	} */
   2406 	struct sys_getxattr_args ua;
   2407 	NETBSD32TOP_UAP(path, const char);
   2408 	NETBSD32TOP_UAP(name, const char);
   2409 	NETBSD32TOP_UAP(value, void);
   2410 	NETBSD32TOX_UAP(size, size_t);
   2411 	return sys_getxattr(l, &ua, retval);
   2412 }
   2413 
   2414 int
   2415 netbsd32_lgetxattr(struct lwp *l, const struct netbsd32_lgetxattr_args *uap, register_t *retval)
   2416 {
   2417 	/* {
   2418 		syscallarg(const netbsd32_charp) path;
   2419 		syscallarg(const netbsd32_charp) name;
   2420 		syscallarg(netbsd32_voidp) value;
   2421 		syscallarg(netbsd32_size_t) size;
   2422 	} */
   2423 	struct sys_lgetxattr_args ua;
   2424 	NETBSD32TOP_UAP(path, const char);
   2425 	NETBSD32TOP_UAP(name, const char);
   2426 	NETBSD32TOP_UAP(value, void);
   2427 	NETBSD32TOX_UAP(size, size_t);
   2428 	return sys_lgetxattr(l, &ua, retval);
   2429 }
   2430 
   2431 int
   2432 netbsd32_fgetxattr(struct lwp *l, const struct netbsd32_fgetxattr_args *uap, register_t *retval)
   2433 {
   2434 	/* {
   2435 		syscallarg(int) fd;
   2436 		syscallarg(const netbsd32_charp) name;
   2437 		syscallarg(netbsd32_voidp) value;
   2438 		syscallarg(netbsd32_size_t) size;
   2439 	} */
   2440 	struct sys_fgetxattr_args ua;
   2441 	NETBSD32TO64_UAP(fd);
   2442 	NETBSD32TOP_UAP(name, const char);
   2443 	NETBSD32TOP_UAP(value, void);
   2444 	NETBSD32TOX_UAP(size, size_t);
   2445 	return sys_fgetxattr(l, &ua, retval);
   2446 }
   2447 
   2448 int
   2449 netbsd32_listxattr(struct lwp *l, const struct netbsd32_listxattr_args *uap, register_t *retval)
   2450 {
   2451 	/* {
   2452 		syscallarg(const netbsd32_charp) path;
   2453 		syscallarg(netbsd32_charp) list;
   2454 		syscallarg(netbsd32_size_t) size;
   2455 	} */
   2456 	struct sys_listxattr_args ua;
   2457 	NETBSD32TOP_UAP(path, const char);
   2458 	NETBSD32TOP_UAP(list, char);
   2459 	NETBSD32TOX_UAP(size, size_t);
   2460 	return sys_listxattr(l, &ua, retval);
   2461 }
   2462 
   2463 int
   2464 netbsd32_llistxattr(struct lwp *l, const struct netbsd32_llistxattr_args *uap, register_t *retval)
   2465 {
   2466 	/* {
   2467 		syscallarg(const netbsd32_charp) path;
   2468 		syscallarg(netbsd32_charp) list;
   2469 		syscallarg(netbsd32_size_t) size;
   2470 	} */
   2471 	struct sys_llistxattr_args ua;
   2472 	NETBSD32TOP_UAP(path, const char);
   2473 	NETBSD32TOP_UAP(list, char);
   2474 	NETBSD32TOX_UAP(size, size_t);
   2475 	return sys_llistxattr(l, &ua, retval);
   2476 }
   2477 
   2478 int
   2479 netbsd32_flistxattr(struct lwp *l, const struct netbsd32_flistxattr_args *uap, register_t *retval)
   2480 {
   2481 	/* {
   2482 		syscallarg(int) fd;
   2483 		syscallarg(netbsd32_charp) list;
   2484 		syscallarg(netbsd32_size_t) size;
   2485 	} */
   2486 	struct sys_flistxattr_args ua;
   2487 	NETBSD32TO64_UAP(fd);
   2488 	NETBSD32TOP_UAP(list, char);
   2489 	NETBSD32TOX_UAP(size, size_t);
   2490 	return sys_flistxattr(l, &ua, retval);
   2491 }
   2492 
   2493 int
   2494 netbsd32_removexattr(struct lwp *l, const struct netbsd32_removexattr_args *uap, register_t *retval)
   2495 {
   2496 	/* {
   2497 		syscallarg(const netbsd32_charp) path;
   2498 		syscallarg(const netbsd32_charp) name;
   2499 	} */
   2500 	struct sys_removexattr_args ua;
   2501 	NETBSD32TOP_UAP(path, const char);
   2502 	NETBSD32TOP_UAP(name, const char);
   2503 	return sys_removexattr(l, &ua, retval);
   2504 }
   2505 
   2506 int
   2507 netbsd32_lremovexattr(struct lwp *l, const struct netbsd32_lremovexattr_args *uap, register_t *retval)
   2508 {
   2509 	/* {
   2510 		syscallarg(const netbsd32_charp) path;
   2511 		syscallarg(const netbsd32_charp) name;
   2512 	} */
   2513 	struct sys_lremovexattr_args ua;
   2514 	NETBSD32TOP_UAP(path, const char);
   2515 	NETBSD32TOP_UAP(name, const char);
   2516 	return sys_lremovexattr(l, &ua, retval);
   2517 }
   2518 
   2519 int
   2520 netbsd32_fremovexattr(struct lwp *l, const struct netbsd32_fremovexattr_args *uap, register_t *retval)
   2521 {
   2522 	/* {
   2523 		syscallarg(int) fd;
   2524 		syscallarg(const netbsd32_charp) name;
   2525 	} */
   2526 	struct sys_fremovexattr_args ua;
   2527 	NETBSD32TO64_UAP(fd);
   2528 	NETBSD32TOP_UAP(name, const char);
   2529 	return sys_fremovexattr(l, &ua, retval);
   2530 }
   2531 
   2532 int
   2533 netbsd32___posix_fadvise50(struct lwp *l,
   2534 	const struct netbsd32___posix_fadvise50_args *uap, register_t *retval)
   2535 {
   2536 	/* {
   2537 		syscallarg(int) fd;
   2538 		syscallarg(int) PAD;
   2539 		syscallarg(off_t) offset;
   2540 		syscallarg(off_t) len;
   2541 		syscallarg(int) advice;
   2542 	} */
   2543 
   2544 	*retval = do_posix_fadvise(SCARG(uap, fd), SCARG(uap, offset),
   2545 	    SCARG(uap, len), SCARG(uap, advice));
   2546 
   2547 	return 0;
   2548 }
   2549 
   2550 int
   2551 netbsd32__sched_setparam(struct lwp *l,
   2552 			 const struct netbsd32__sched_setparam_args *uap,
   2553 			 register_t *retval)
   2554 {
   2555 	/* {
   2556 		syscallarg(pid_t) pid;
   2557 		syscallarg(lwpid_t) lid;
   2558 		syscallarg(int) policy;
   2559 		syscallarg(const netbsd32_sched_paramp_t) params;
   2560 	} */
   2561 	struct sys__sched_setparam_args ua;
   2562 
   2563 	NETBSD32TO64_UAP(pid);
   2564 	NETBSD32TO64_UAP(lid);
   2565 	NETBSD32TO64_UAP(policy);
   2566 	NETBSD32TOP_UAP(params, const struct sched_param *);
   2567 	return sys__sched_setparam(l, &ua, retval);
   2568 }
   2569 
   2570 int
   2571 netbsd32__sched_getparam(struct lwp *l,
   2572 			 const struct netbsd32__sched_getparam_args *uap,
   2573 			 register_t *retval)
   2574 {
   2575 	/* {
   2576 		syscallarg(pid_t) pid;
   2577 		syscallarg(lwpid_t) lid;
   2578 		syscallarg(netbsd32_intp) policy;
   2579 		syscallarg(netbsd32_sched_paramp_t) params;
   2580 	} */
   2581 	struct sys__sched_getparam_args ua;
   2582 
   2583 	NETBSD32TO64_UAP(pid);
   2584 	NETBSD32TO64_UAP(lid);
   2585 	NETBSD32TOP_UAP(policy, int *);
   2586 	NETBSD32TOP_UAP(params, struct sched_param *);
   2587 	return sys__sched_getparam(l, &ua, retval);
   2588 }
   2589 
   2590 int
   2591 netbsd32__sched_setaffinity(struct lwp *l,
   2592 			    const struct netbsd32__sched_setaffinity_args *uap,
   2593 			    register_t *retval)
   2594 {
   2595 	/* {
   2596 		syscallarg(pid_t) pid;
   2597 		syscallarg(lwpid_t) lid;
   2598 		syscallarg(netbsd_size_t) size;
   2599 		syscallarg(const netbsd32_cpusetp_t) cpuset;
   2600 	} */
   2601 	struct sys__sched_setaffinity_args ua;
   2602 
   2603 	NETBSD32TO64_UAP(pid);
   2604 	NETBSD32TO64_UAP(lid);
   2605 	NETBSD32TOX_UAP(size, size_t);
   2606 	NETBSD32TOP_UAP(cpuset, const cpuset_t *);
   2607 	return sys__sched_setaffinity(l, &ua, retval);
   2608 }
   2609 
   2610 int
   2611 netbsd32__sched_getaffinity(struct lwp *l,
   2612 			    const struct netbsd32__sched_getaffinity_args *uap,
   2613 			    register_t *retval)
   2614 {
   2615 	/* {
   2616 		syscallarg(pid_t) pid;
   2617 		syscallarg(lwpid_t) lid;
   2618 		syscallarg(netbsd_size_t) size;
   2619 		syscallarg(netbsd32_cpusetp_t) cpuset;
   2620 	} */
   2621 	struct sys__sched_getaffinity_args ua;
   2622 
   2623 	NETBSD32TO64_UAP(pid);
   2624 	NETBSD32TO64_UAP(lid);
   2625 	NETBSD32TOX_UAP(size, size_t);
   2626 	NETBSD32TOP_UAP(cpuset, cpuset_t *);
   2627 	return sys__sched_getaffinity(l, &ua, retval);
   2628 }
   2629 
   2630 int
   2631 netbsd32_pipe2(struct lwp *l, const struct netbsd32_pipe2_args *uap,
   2632 	       register_t *retval)
   2633 {
   2634 	/* {
   2635 		syscallarg(netbsd32_intp) fildes;
   2636 		syscallarg(int) flags;
   2637 	} */
   2638 	int fd[2], error;
   2639 
   2640 	error = pipe1(l, retval, SCARG(uap, flags));
   2641 	if (error != 0)
   2642 		return error;
   2643 
   2644 	fd[0] = retval[0];
   2645 	fd[1] = retval[1];
   2646 
   2647 	error = copyout(fd, SCARG_P32(uap, fildes), sizeof(fd));
   2648 	if (error != 0)
   2649 		return error;
   2650 
   2651 	retval[0] = 0;
   2652 	return 0;
   2653 }
   2654 
   2655 int
   2656 netbsd32_dup3(struct lwp *l, const struct netbsd32_dup3_args *uap,
   2657 	      register_t *retval)
   2658 {
   2659 	/* {
   2660 		syscallarg(int) from;
   2661 		syscallarg(int) to;
   2662 		syscallarg(int) flags;
   2663 	} */
   2664 	struct sys_dup3_args ua;
   2665 
   2666 	NETBSD32TO64_UAP(from);
   2667 	NETBSD32TO64_UAP(to);
   2668 	NETBSD32TO64_UAP(flags);
   2669 
   2670 	return sys_dup3(l, &ua, retval);
   2671 }
   2672 
   2673 int
   2674 netbsd32_kqueue1(struct lwp *l, const struct netbsd32_kqueue1_args *uap,
   2675 		 register_t *retval)
   2676 {
   2677 	/* {
   2678 		syscallarg(int) flags;
   2679 	} */
   2680 	struct sys_kqueue1_args ua;
   2681 
   2682 	NETBSD32TO64_UAP(flags);
   2683 
   2684 	return sys_kqueue1(l, &ua, retval);
   2685 }
   2686 
   2687 int
   2688 netbsd32_paccept(struct lwp *l, const struct netbsd32_paccept_args *uap,
   2689 		 register_t *retval)
   2690 {
   2691 	/* {
   2692 		syscallarg(int) s;
   2693 		syscallarg(netbsd32_sockaddrp_t) name;
   2694 		syscallarg(netbsd32_socklenp_t) anamelen;
   2695 		syscallarg(const netbsd32_sigsetp_t) mask;
   2696 		syscallarg(int) flags;
   2697 	} */
   2698 	struct sys_paccept_args ua;
   2699 
   2700 	NETBSD32TO64_UAP(s);
   2701 	NETBSD32TOP_UAP(name, struct sockaddr *);
   2702 	NETBSD32TOP_UAP(anamelen, socklen_t *);
   2703 	NETBSD32TOP_UAP(mask, const sigset_t *);
   2704 	NETBSD32TO64_UAP(flags);
   2705 
   2706 	return sys_paccept(l, &ua, retval);
   2707 }
   2708 
   2709 int
   2710 netbsd32_linkat(struct lwp *l, const struct netbsd32_linkat_args *uap,
   2711 		 register_t *retval)
   2712 {
   2713 	/* {
   2714 		syscallarg(int) fd1;
   2715 		syscallarg(const netbsd32_charp) name1;
   2716 		syscallarg(int) fd2;
   2717 		syscallarg(const netbsd32_charp) name2;
   2718 		syscallarg(int) flags;
   2719 	} */
   2720 	struct sys_linkat_args ua;
   2721 
   2722 	NETBSD32TO64_UAP(fd1);
   2723 	NETBSD32TOP_UAP(name1, const char);
   2724 	NETBSD32TO64_UAP(fd2);
   2725 	NETBSD32TOP_UAP(name2, const char);
   2726 	NETBSD32TO64_UAP(flags);
   2727 
   2728 	return sys_linkat(l, &ua, retval);
   2729 }
   2730 
   2731 int
   2732 netbsd32_renameat(struct lwp *l, const struct netbsd32_renameat_args *uap,
   2733 		 register_t *retval)
   2734 {
   2735 	/* {
   2736 		syscallarg(int) fromfd;
   2737 		syscallarg(const netbsd32_charp) from;
   2738 		syscallarg(int) tofd;
   2739 		syscallarg(const netbsd32_charp) to;
   2740 	} */
   2741 	struct sys_renameat_args ua;
   2742 
   2743 	NETBSD32TO64_UAP(fromfd);
   2744 	NETBSD32TOP_UAP(from, const char);
   2745 	NETBSD32TO64_UAP(tofd);
   2746 	NETBSD32TOP_UAP(to, const char);
   2747 
   2748 	return sys_renameat(l, &ua, retval);
   2749 }
   2750 
   2751 int
   2752 netbsd32_mkfifoat(struct lwp *l, const struct netbsd32_mkfifoat_args *uap,
   2753 		 register_t *retval)
   2754 {
   2755 	/* {
   2756 		syscallarg(int) fd;
   2757 		syscallarg(const netbsd32_charp) path;
   2758 		syscallarg(mode_t) mode;
   2759 	} */
   2760 	struct sys_mkfifoat_args ua;
   2761 
   2762 	NETBSD32TO64_UAP(fd);
   2763 	NETBSD32TOP_UAP(path, const char);
   2764 	NETBSD32TO64_UAP(mode);
   2765 
   2766 	return sys_mkfifoat(l, &ua, retval);
   2767 }
   2768 
   2769 int
   2770 netbsd32_mknodat(struct lwp *l, const struct netbsd32_mknodat_args *uap,
   2771 		 register_t *retval)
   2772 {
   2773 	/* {
   2774 		syscallarg(int) fd;
   2775 		syscallarg(netbsd32_charp) path;
   2776 		syscallarg(mode_t) mode;
   2777 		syscallarg(uint32_t) dev;
   2778 	} */
   2779 	struct sys_mknodat_args ua;
   2780 
   2781 	NETBSD32TO64_UAP(fd);
   2782 	NETBSD32TOP_UAP(path, const char);
   2783 	NETBSD32TO64_UAP(mode);
   2784 	NETBSD32TO64_UAP(dev);
   2785 
   2786 	return sys_mknodat(l, &ua, retval);
   2787 }
   2788 
   2789 int
   2790 netbsd32_mkdirat(struct lwp *l, const struct netbsd32_mkdirat_args *uap,
   2791 		 register_t *retval)
   2792 {
   2793 	/* {
   2794 		syscallarg(int) fd;
   2795 		syscallarg(netbsd32_charp) path;
   2796 		syscallarg(mode_t) mode;
   2797 	} */
   2798 	struct sys_mkdirat_args ua;
   2799 
   2800 	NETBSD32TO64_UAP(fd);
   2801 	NETBSD32TOP_UAP(path, const char);
   2802 	NETBSD32TO64_UAP(mode);
   2803 
   2804 	return sys_mkdirat(l, &ua, retval);
   2805 }
   2806 
   2807 int
   2808 netbsd32_faccessat(struct lwp *l, const struct netbsd32_faccessat_args *uap,
   2809 		 register_t *retval)
   2810 {
   2811 	/* {
   2812 		syscallarg(int) fd;
   2813 		syscallarg(netbsd32_charp) path;
   2814 		syscallarg(int) amode;
   2815 		syscallarg(int) flag;
   2816 	} */
   2817 	struct sys_faccessat_args ua;
   2818 
   2819 	NETBSD32TO64_UAP(fd);
   2820 	NETBSD32TOP_UAP(path, const char);
   2821 	NETBSD32TO64_UAP(amode);
   2822 	NETBSD32TO64_UAP(flag);
   2823 
   2824 	return sys_faccessat(l, &ua, retval);
   2825 }
   2826 
   2827 int
   2828 netbsd32_fchmodat(struct lwp *l, const struct netbsd32_fchmodat_args *uap,
   2829 		 register_t *retval)
   2830 {
   2831 	/* {
   2832 		syscallarg(int) fd;
   2833 		syscallarg(netbsd32_charp) path;
   2834 		syscallarg(mode_t) mode;
   2835 		syscallarg(int) flag;
   2836 	} */
   2837 	struct sys_fchmodat_args ua;
   2838 
   2839 	NETBSD32TO64_UAP(fd);
   2840 	NETBSD32TOP_UAP(path, const char);
   2841 	NETBSD32TO64_UAP(mode);
   2842 	NETBSD32TO64_UAP(flag);
   2843 
   2844 	return sys_fchmodat(l, &ua, retval);
   2845 }
   2846 
   2847 int
   2848 netbsd32_fchownat(struct lwp *l, const struct netbsd32_fchownat_args *uap,
   2849 		 register_t *retval)
   2850 {
   2851 	/* {
   2852 		syscallarg(int) fd;
   2853 		syscallarg(netbsd32_charp) path;
   2854 		syscallarg(uid_t) owner;
   2855 		syscallarg(gid_t) group;
   2856 		syscallarg(int) flag;
   2857 	} */
   2858 	struct sys_fchownat_args ua;
   2859 
   2860 	NETBSD32TO64_UAP(fd);
   2861 	NETBSD32TOP_UAP(path, const char);
   2862 	NETBSD32TO64_UAP(owner);
   2863 	NETBSD32TO64_UAP(group);
   2864 	NETBSD32TO64_UAP(flag);
   2865 
   2866 	return sys_fchownat(l, &ua, retval);
   2867 }
   2868 
   2869 int
   2870 netbsd32_fstatat(struct lwp *l, const struct netbsd32_fstatat_args *uap,
   2871 		 register_t *retval)
   2872 {
   2873 	/* {
   2874 		syscallarg(int) fd;
   2875 		syscallarg(netbsd32_charp) path;
   2876 		syscallarg(netbsd32_statp_t) buf;
   2877 		syscallarg(int) flag;
   2878 	} */
   2879 	struct sys_fstatat_args ua;
   2880 
   2881 	NETBSD32TO64_UAP(fd);
   2882 	NETBSD32TOP_UAP(path, const char);
   2883 	NETBSD32TOP_UAP(buf, const struct stat);
   2884 	NETBSD32TO64_UAP(flag);
   2885 
   2886 	return sys_fstatat(l, &ua, retval);
   2887 }
   2888 
   2889 int
   2890 netbsd32_utimensat(struct lwp *l, const struct netbsd32_utimensat_args *uap,
   2891 		 register_t *retval)
   2892 {
   2893 	/* {
   2894 		syscallarg(int) fd;
   2895 		syscallarg(netbsd32_charp) path;
   2896 		syscallarg(netbsd32_timespecp_t) tptr;
   2897 		syscallarg(int) flag;
   2898 	} */
   2899 	struct sys_utimensat_args ua;
   2900 
   2901 	NETBSD32TO64_UAP(fd);
   2902 	NETBSD32TOP_UAP(path, const char);
   2903 	NETBSD32TOP_UAP(tptr, const struct timespec);
   2904 	NETBSD32TO64_UAP(flag);
   2905 
   2906 	return sys_utimensat(l, &ua, retval);
   2907 }
   2908 
   2909 int
   2910 netbsd32_openat(struct lwp *l, const struct netbsd32_openat_args *uap,
   2911 		 register_t *retval)
   2912 {
   2913 	/* {
   2914 		syscallarg(int) fd;
   2915 		syscallarg(netbsd32_charp) path;
   2916 		syscallarg(int) oflags;
   2917 		syscallarg(mode_t) mode;
   2918 	} */
   2919 	struct sys_openat_args ua;
   2920 
   2921 	NETBSD32TO64_UAP(fd);
   2922 	NETBSD32TOP_UAP(path, const char);
   2923 	NETBSD32TO64_UAP(oflags);
   2924 	NETBSD32TO64_UAP(mode);
   2925 
   2926 	return sys_openat(l, &ua, retval);
   2927 }
   2928 
   2929 int
   2930 netbsd32_readlinkat(struct lwp *l, const struct netbsd32_readlinkat_args *uap,
   2931 		 register_t *retval)
   2932 {
   2933 	/* {
   2934 		syscallarg(int) fd;
   2935 		syscallarg(netbsd32_charp) path;
   2936 		syscallarg(netbsd32_charp) buf;
   2937 		syscallarg(netbsd32_size_t) bufsize;
   2938 	} */
   2939 	struct sys_readlinkat_args ua;
   2940 
   2941 	NETBSD32TO64_UAP(fd);
   2942 	NETBSD32TOP_UAP(path, const char *);
   2943 	NETBSD32TOP_UAP(buf, char *);
   2944 	NETBSD32TOX_UAP(bufsize, size_t);
   2945 
   2946 	return sys_readlinkat(l, &ua, retval);
   2947 }
   2948 
   2949 int
   2950 netbsd32_symlinkat(struct lwp *l, const struct netbsd32_symlinkat_args *uap,
   2951 		 register_t *retval)
   2952 {
   2953 	/* {
   2954 		syscallarg(netbsd32_charp) path1;
   2955 		syscallarg(int) fd;
   2956 		syscallarg(netbsd32_charp) path2;
   2957 	} */
   2958 	struct sys_symlinkat_args ua;
   2959 
   2960 	NETBSD32TOP_UAP(path1, const char *);
   2961 	NETBSD32TO64_UAP(fd);
   2962 	NETBSD32TOP_UAP(path2, const char *);
   2963 
   2964 	return sys_symlinkat(l, &ua, retval);
   2965 }
   2966 
   2967 int
   2968 netbsd32_unlinkat(struct lwp *l, const struct netbsd32_unlinkat_args *uap,
   2969 		 register_t *retval)
   2970 {
   2971 	/* {
   2972 		syscallarg(int) fd;
   2973 		syscallarg(netbsd32_charp) path;
   2974 		syscallarg(int) flag;
   2975 	} */
   2976 	struct sys_unlinkat_args ua;
   2977 
   2978 	NETBSD32TO64_UAP(fd);
   2979 	NETBSD32TOP_UAP(path, const char *);
   2980 	NETBSD32TO64_UAP(flag);
   2981 
   2982 	return sys_unlinkat(l, &ua, retval);
   2983 }
   2984 
   2985 int
   2986 netbsd32_futimens(struct lwp *l, const struct netbsd32_futimens_args *uap,
   2987 		 register_t *retval)
   2988 {
   2989 	/* {
   2990 		syscallarg(int) fd;
   2991 		syscallarg(netbsd32_timespecp_t) tptr;
   2992 	} */
   2993 	struct sys_futimens_args ua;
   2994 
   2995 	NETBSD32TO64_UAP(fd);
   2996 	NETBSD32TOP_UAP(tptr, const struct timespec *);
   2997 
   2998 	return sys_futimens(l, &ua, retval);
   2999 }
   3000 
   3001 /*
   3002  * MI indirect system call support.
   3003  * Only used if the MD netbsd32_syscall.c doesn't intercept the calls.
   3004  */
   3005 
   3006 #define NETBSD32_SYSCALL
   3007 #undef SYS_NSYSENT
   3008 #define SYS_NSYSENT NETBSD32_SYS_NSYSENT
   3009 
   3010 #define SYS_SYSCALL netbsd32_syscall
   3011 #include "../../kern/sys_syscall.c"
   3012 #undef SYS_SYSCALL
   3013 
   3014 #define SYS_SYSCALL netbsd32____syscall
   3015 #include "../../kern/sys_syscall.c"
   3016 #undef SYS_SYSCALL
   3017