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