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