Home | History | Annotate | Line # | Download | only in netbsd32
netbsd32_compat_43.c revision 1.39
      1  1.39       dsl /*	$NetBSD: netbsd32_compat_43.c,v 1.39 2007/03/18 21:38:33 dsl Exp $	*/
      2   1.1       mrg 
      3   1.1       mrg /*
      4  1.19       mrg  * Copyright (c) 1998, 2001 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  * 3. The name of the author may not be used to endorse or promote products
     16   1.1       mrg  *    derived from this software without specific prior written permission.
     17   1.1       mrg  *
     18   1.1       mrg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19   1.1       mrg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20   1.1       mrg  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21   1.1       mrg  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22   1.7       mrg  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     23   1.1       mrg  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     24   1.1       mrg  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     25   1.1       mrg  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     26   1.7       mrg  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27   1.1       mrg  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28   1.1       mrg  * SUCH DAMAGE.
     29   1.1       mrg  */
     30  1.20     lukem 
     31  1.20     lukem #include <sys/cdefs.h>
     32  1.39       dsl __KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_43.c,v 1.39 2007/03/18 21:38:33 dsl Exp $");
     33  1.13      fvdl 
     34  1.17       mrg #if defined(_KERNEL_OPT)
     35  1.13      fvdl #include "opt_compat_43.h"
     36  1.13      fvdl #endif
     37   1.1       mrg 
     38   1.1       mrg #include <sys/param.h>
     39   1.1       mrg #include <sys/systm.h>
     40   1.1       mrg #include <sys/fcntl.h>
     41   1.1       mrg #include <sys/malloc.h>
     42   1.1       mrg #include <sys/mount.h>
     43  1.32       chs #include <sys/socket.h>
     44   1.1       mrg #include <sys/proc.h>
     45   1.1       mrg #include <sys/stat.h>
     46   1.1       mrg #include <sys/syscallargs.h>
     47   1.1       mrg #include <sys/time.h>
     48   1.1       mrg #include <sys/ucred.h>
     49  1.10       mrg #include <uvm/uvm_extern.h>
     50   1.1       mrg #include <sys/sysctl.h>
     51   1.3       mrg #include <sys/swap.h>
     52   1.1       mrg 
     53   1.5       mrg #include <compat/netbsd32/netbsd32.h>
     54   1.5       mrg #include <compat/netbsd32/netbsd32_syscallargs.h>
     55   1.1       mrg 
     56  1.31  christos #include <compat/sys/stat.h>
     57  1.31  christos #include <compat/sys/signal.h>
     58  1.31  christos #include <compat/sys/signalvar.h>
     59  1.33  christos #include <compat/sys/socket.h>
     60  1.31  christos 
     61  1.24   thorpej int compat_43_netbsd32_sethostid __P((struct lwp *, void *, register_t *));
     62  1.24   thorpej int compat_43_netbsd32_killpg __P((struct lwp *, void *, register_t *retval));
     63  1.24   thorpej int compat_43_netbsd32_sigblock __P((struct lwp *, void *, register_t *retval));
     64  1.24   thorpej int compat_43_netbsd32_sigblock __P((struct lwp *, void *, register_t *retval));
     65  1.24   thorpej int compat_43_netbsd32_sigsetmask __P((struct lwp *, void *, register_t *retval));
     66   1.9       eeh 
     67  1.30     perry void
     68   1.5       mrg netbsd32_from_stat43(sp43, sp32)
     69   1.1       mrg 	struct stat43 *sp43;
     70   1.5       mrg 	struct netbsd32_stat43 *sp32;
     71   1.1       mrg {
     72   1.1       mrg 
     73   1.1       mrg 	sp32->st_dev = sp43->st_dev;
     74   1.1       mrg 	sp32->st_ino = sp43->st_ino;
     75   1.1       mrg 	sp32->st_mode = sp43->st_mode;
     76   1.1       mrg 	sp32->st_nlink = sp43->st_nlink;
     77   1.1       mrg 	sp32->st_uid = sp43->st_uid;
     78   1.1       mrg 	sp32->st_gid = sp43->st_gid;
     79   1.1       mrg 	sp32->st_rdev = sp43->st_rdev;
     80   1.1       mrg 	sp32->st_size = sp43->st_size;
     81   1.1       mrg 	sp32->st_atimespec.tv_sec = sp43->st_atimespec.tv_sec;
     82   1.1       mrg 	sp32->st_atimespec.tv_nsec = sp43->st_atimespec.tv_nsec;
     83   1.1       mrg 	sp32->st_mtimespec.tv_sec = sp43->st_mtimespec.tv_sec;
     84   1.1       mrg 	sp32->st_mtimespec.tv_nsec = sp43->st_mtimespec.tv_nsec;
     85   1.1       mrg 	sp32->st_ctimespec.tv_sec = sp43->st_ctimespec.tv_sec;
     86   1.1       mrg 	sp32->st_ctimespec.tv_nsec = sp43->st_ctimespec.tv_nsec;
     87   1.1       mrg 	sp32->st_blksize = sp43->st_blksize;
     88   1.1       mrg 	sp32->st_blocks = sp43->st_blocks;
     89   1.1       mrg 	sp32->st_flags = sp43->st_flags;
     90   1.1       mrg 	sp32->st_gen = sp43->st_gen;
     91   1.1       mrg }
     92   1.1       mrg 
     93   1.1       mrg /* file system syscalls */
     94   1.1       mrg int
     95  1.24   thorpej compat_43_netbsd32_ocreat(l, v, retval)
     96  1.24   thorpej 	struct lwp *l;
     97   1.1       mrg 	void *v;
     98   1.1       mrg 	register_t *retval;
     99   1.1       mrg {
    100  1.24   thorpej 	struct proc *p = l->l_proc;
    101   1.8       eeh 	struct compat_43_netbsd32_ocreat_args /* {
    102   1.5       mrg 		syscallarg(const netbsd32_charp) path;
    103   1.1       mrg 		syscallarg(mode_t) mode;
    104   1.1       mrg 	} */ *uap = v;
    105   1.1       mrg 	struct sys_open_args  ua;
    106  1.36  christos 	void *sg;
    107   1.1       mrg 
    108   1.6       mrg 	NETBSD32TOP_UAP(path, const char);
    109   1.6       mrg 	NETBSD32TO64_UAP(mode);
    110   1.1       mrg 	SCARG(&ua, flags) = O_WRONLY | O_CREAT | O_TRUNC;
    111  1.21  christos 	sg = stackgap_init(p, 0);
    112  1.34  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(&ua, path));
    113   1.1       mrg 
    114  1.24   thorpej 	return (sys_open(l, &ua, retval));
    115   1.1       mrg }
    116   1.1       mrg 
    117   1.1       mrg int
    118  1.24   thorpej compat_43_netbsd32_olseek(l, v, retval)
    119  1.24   thorpej 	struct lwp *l;
    120   1.1       mrg 	void *v;
    121   1.1       mrg 	register_t *retval;
    122   1.1       mrg {
    123   1.8       eeh 	struct compat_43_netbsd32_olseek_args /* {
    124   1.1       mrg 		syscallarg(int) fd;
    125   1.5       mrg 		syscallarg(netbsd32_long) offset;
    126   1.1       mrg 		syscallarg(int) whence;
    127   1.1       mrg 	} */ *uap = v;
    128   1.1       mrg 	struct sys_lseek_args ua;
    129   1.1       mrg 	int rv;
    130   1.1       mrg 	off_t rt;
    131   1.1       mrg 
    132   1.1       mrg 	SCARG(&ua, fd) = SCARG(uap, fd);
    133   1.6       mrg 	NETBSD32TOX_UAP(offset, long);
    134   1.6       mrg 	NETBSD32TO64_UAP(whence);
    135  1.24   thorpej 	rv = sys_lseek(l, &ua, (register_t *)&rt);
    136  1.18       eeh 	*retval = rt;
    137   1.1       mrg 
    138   1.1       mrg 	return (rv);
    139   1.1       mrg }
    140   1.1       mrg 
    141   1.1       mrg int
    142  1.24   thorpej compat_43_netbsd32_stat43(l, v, retval)
    143  1.24   thorpej 	struct lwp *l;
    144   1.1       mrg 	void *v;
    145   1.1       mrg 	register_t *retval;
    146   1.1       mrg {
    147  1.24   thorpej 	struct proc *p = l->l_proc;
    148   1.8       eeh 	struct compat_43_netbsd32_stat43_args /* {
    149   1.5       mrg 		syscallarg(const netbsd32_charp) path;
    150   1.5       mrg 		syscallarg(netbsd32_stat43p_t) ub;
    151   1.1       mrg 	} */ *uap = v;
    152  1.15       mrg 	struct stat43 sb43, *sgsbp;
    153  1.15       mrg 	struct netbsd32_stat43 sb32;
    154   1.1       mrg 	struct compat_43_sys_stat_args ua;
    155  1.36  christos 	void *sg = stackgap_init(p, 0);
    156  1.15       mrg 	int rv, error;
    157   1.1       mrg 
    158   1.6       mrg 	NETBSD32TOP_UAP(path, const char);
    159  1.21  christos 	SCARG(&ua, ub) = sgsbp = stackgap_alloc(p, &sg, sizeof(sb43));
    160  1.34  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(&ua, path));
    161  1.24   thorpej 	rv = compat_43_sys_stat(l, &ua, retval);
    162   1.1       mrg 
    163  1.15       mrg 	error = copyin(sgsbp, &sb43, sizeof(sb43));
    164  1.15       mrg 	if (error)
    165  1.15       mrg 		return error;
    166  1.15       mrg 	netbsd32_from_stat43(&sb43, &sb32);
    167  1.39       dsl 	error = copyout(&sb32, SCARG_P32(uap, ub), sizeof(sb32));
    168  1.15       mrg 	if (error)
    169  1.15       mrg 		return error;
    170   1.1       mrg 
    171   1.1       mrg 	return (rv);
    172   1.1       mrg }
    173   1.1       mrg 
    174   1.1       mrg int
    175  1.24   thorpej compat_43_netbsd32_lstat43(l, v, retval)
    176  1.24   thorpej 	struct lwp *l;
    177   1.1       mrg 	void *v;
    178   1.1       mrg 	register_t *retval;
    179   1.1       mrg {
    180  1.24   thorpej 	struct proc *p = l->l_proc;
    181   1.8       eeh 	struct compat_43_netbsd32_lstat43_args /* {
    182   1.5       mrg 		syscallarg(const netbsd32_charp) path;
    183   1.5       mrg 		syscallarg(netbsd32_stat43p_t) ub;
    184   1.1       mrg 	} */ *uap = v;
    185  1.15       mrg 	struct stat43 sb43, *sgsbp;
    186  1.15       mrg 	struct netbsd32_stat43 sb32;
    187   1.1       mrg 	struct compat_43_sys_lstat_args ua;
    188  1.36  christos 	void *sg = stackgap_init(p, 0);
    189  1.15       mrg 	int rv, error;
    190   1.1       mrg 
    191   1.6       mrg 	NETBSD32TOP_UAP(path, const char);
    192  1.21  christos 	SCARG(&ua, ub) = sgsbp = stackgap_alloc(p, &sg, sizeof(sb43));
    193  1.34  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(&ua, path));
    194  1.24   thorpej 	rv = compat_43_sys_stat(l, &ua, retval);
    195   1.1       mrg 
    196  1.15       mrg 	error = copyin(sgsbp, &sb43, sizeof(sb43));
    197  1.15       mrg 	if (error)
    198  1.15       mrg 		return error;
    199  1.15       mrg 	netbsd32_from_stat43(&sb43, &sb32);
    200  1.39       dsl 	error = copyout(&sb32, SCARG_P32(uap, ub), sizeof(sb32));
    201  1.15       mrg 	if (error)
    202  1.15       mrg 		return error;
    203   1.1       mrg 
    204   1.1       mrg 	return (rv);
    205   1.1       mrg }
    206   1.1       mrg 
    207   1.1       mrg int
    208  1.24   thorpej compat_43_netbsd32_fstat43(l, v, retval)
    209  1.24   thorpej 	struct lwp *l;
    210   1.1       mrg 	void *v;
    211   1.1       mrg 	register_t *retval;
    212   1.1       mrg {
    213  1.24   thorpej 	struct proc *p = l->l_proc;
    214   1.8       eeh 	struct compat_43_netbsd32_fstat43_args /* {
    215   1.1       mrg 		syscallarg(int) fd;
    216   1.5       mrg 		syscallarg(netbsd32_stat43p_t) sb;
    217   1.1       mrg 	} */ *uap = v;
    218  1.15       mrg 	struct stat43 sb43, *sgsbp;
    219  1.15       mrg 	struct netbsd32_stat43 sb32;
    220   1.1       mrg 	struct compat_43_sys_fstat_args ua;
    221  1.36  christos 	void *sg = stackgap_init(p, 0);
    222  1.15       mrg 	int rv, error;
    223   1.1       mrg 
    224   1.6       mrg 	NETBSD32TO64_UAP(fd);
    225  1.21  christos 	SCARG(&ua, sb) = sgsbp = stackgap_alloc(p, &sg, sizeof(sb43));
    226  1.24   thorpej 	rv = compat_43_sys_fstat(l, &ua, retval);
    227   1.1       mrg 
    228  1.15       mrg 	error = copyin(sgsbp, &sb43, sizeof(sb43));
    229  1.15       mrg 	if (error)
    230  1.15       mrg 		return error;
    231  1.15       mrg 	netbsd32_from_stat43(&sb43, &sb32);
    232  1.39       dsl 	error = copyout(&sb32, SCARG_P32(uap, sb), sizeof(sb32));
    233  1.15       mrg 	if (error)
    234  1.15       mrg 		return error;
    235   1.1       mrg 
    236   1.1       mrg 	return (rv);
    237   1.1       mrg }
    238   1.1       mrg 
    239   1.1       mrg int
    240  1.24   thorpej compat_43_netbsd32_otruncate(l, v, retval)
    241  1.24   thorpej 	struct lwp *l;
    242   1.1       mrg 	void *v;
    243   1.1       mrg 	register_t *retval;
    244   1.1       mrg {
    245   1.8       eeh 	struct compat_43_netbsd32_otruncate_args /* {
    246   1.5       mrg 		syscallarg(const netbsd32_charp) path;
    247   1.5       mrg 		syscallarg(netbsd32_long) length;
    248   1.1       mrg 	} */ *uap = v;
    249   1.1       mrg 	struct sys_truncate_args ua;
    250   1.1       mrg 
    251   1.6       mrg 	NETBSD32TOP_UAP(path, const char);
    252   1.6       mrg 	NETBSD32TO64_UAP(length);
    253  1.24   thorpej 	return (sys_ftruncate(l, &ua, retval));
    254   1.1       mrg }
    255   1.1       mrg 
    256   1.1       mrg int
    257  1.24   thorpej compat_43_netbsd32_oftruncate(l, v, retval)
    258  1.24   thorpej 	struct lwp *l;
    259   1.1       mrg 	void *v;
    260   1.1       mrg 	register_t *retval;
    261   1.1       mrg {
    262   1.8       eeh 	struct compat_43_netbsd32_oftruncate_args /* {
    263   1.1       mrg 		syscallarg(int) fd;
    264   1.5       mrg 		syscallarg(netbsd32_long) length;
    265   1.1       mrg 	} */ *uap = v;
    266   1.1       mrg 	struct sys_ftruncate_args ua;
    267   1.1       mrg 
    268   1.6       mrg 	NETBSD32TO64_UAP(fd);
    269   1.6       mrg 	NETBSD32TO64_UAP(length);
    270  1.24   thorpej 	return (sys_ftruncate(l, &ua, retval));
    271   1.1       mrg }
    272   1.1       mrg 
    273   1.1       mrg int
    274  1.24   thorpej compat_43_netbsd32_ogetdirentries(l, v, retval)
    275  1.24   thorpej 	struct lwp *l;
    276   1.1       mrg 	void *v;
    277   1.1       mrg 	register_t *retval;
    278   1.1       mrg {
    279   1.8       eeh 	struct compat_43_netbsd32_ogetdirentries_args /* {
    280   1.1       mrg 		syscallarg(int) fd;
    281   1.5       mrg 		syscallarg(netbsd32_charp) buf;
    282   1.1       mrg 		syscallarg(u_int) count;
    283   1.5       mrg 		syscallarg(netbsd32_longp) basep;
    284   1.1       mrg 	} */ *uap = v;
    285   1.1       mrg 	struct compat_43_sys_getdirentries_args ua;
    286   1.1       mrg 
    287   1.6       mrg 	NETBSD32TO64_UAP(fd);
    288   1.6       mrg 	NETBSD32TOP_UAP(buf, char);
    289   1.6       mrg 	NETBSD32TO64_UAP(count);
    290   1.6       mrg 	NETBSD32TOP_UAP(basep, long);
    291  1.24   thorpej 	return (compat_43_sys_getdirentries(l, &ua, retval));
    292   1.1       mrg }
    293   1.1       mrg 
    294   1.1       mrg /* kernel syscalls */
    295   1.1       mrg int
    296  1.24   thorpej compat_43_netbsd32_ogetkerninfo(l, v, retval)
    297  1.24   thorpej 	struct lwp *l;
    298   1.1       mrg 	void *v;
    299   1.1       mrg 	register_t *retval;
    300   1.1       mrg {
    301   1.8       eeh 	struct compat_43_netbsd32_ogetkerninfo_args /* {
    302   1.1       mrg 		syscallarg(int) op;
    303   1.5       mrg 		syscallarg(netbsd32_charp) where;
    304   1.5       mrg 		syscallarg(netbsd32_intp) size;
    305   1.1       mrg 		syscallarg(int) arg;
    306   1.1       mrg 	} */ *uap = v;
    307   1.1       mrg 	struct compat_43_sys_getkerninfo_args ua;
    308   1.1       mrg 
    309   1.6       mrg 	NETBSD32TO64_UAP(op);
    310   1.6       mrg 	NETBSD32TOP_UAP(where, char);
    311   1.6       mrg 	NETBSD32TOP_UAP(size, int);
    312   1.6       mrg 	NETBSD32TO64_UAP(arg);
    313  1.24   thorpej 	return (compat_43_sys_getkerninfo(l, &ua, retval));
    314   1.1       mrg }
    315   1.1       mrg 
    316   1.1       mrg int
    317  1.24   thorpej compat_43_netbsd32_ogethostname(l, v, retval)
    318  1.24   thorpej 	struct lwp* l;
    319   1.1       mrg 	void *v;
    320   1.1       mrg 	register_t *retval;
    321   1.1       mrg {
    322   1.8       eeh 	struct compat_43_netbsd32_ogethostname_args /* {
    323   1.5       mrg 		syscallarg(netbsd32_charp) hostname;
    324   1.1       mrg 		syscallarg(u_int) len;
    325   1.1       mrg 	} */ *uap = v;
    326  1.29    atatat 	int name[2];
    327   1.1       mrg 	size_t sz;
    328   1.1       mrg 
    329  1.29    atatat 	name[0] = CTL_KERN;
    330  1.29    atatat 	name[1] = KERN_HOSTNAME;
    331   1.1       mrg 	sz = SCARG(uap, len);
    332  1.29    atatat 	return (old_sysctl(&name[0], 2,
    333  1.39       dsl 	    SCARG_P32(uap, hostname), &sz, 0, 0, l));
    334   1.1       mrg }
    335   1.1       mrg 
    336   1.1       mrg int
    337  1.24   thorpej compat_43_netbsd32_osethostname(l, v, retval)
    338  1.24   thorpej 	struct lwp* l;
    339   1.1       mrg 	void *v;
    340   1.1       mrg 	register_t *retval;
    341   1.1       mrg {
    342   1.8       eeh 	struct compat_43_netbsd32_osethostname_args /* {
    343   1.5       mrg 		syscallarg(netbsd32_charp) hostname;
    344   1.1       mrg 		syscallarg(u_int) len;
    345   1.1       mrg 	} */ *uap = v;
    346  1.29    atatat 	int name[2];
    347   1.1       mrg 
    348  1.29    atatat 	name[0] = CTL_KERN;
    349  1.29    atatat 	name[1] = KERN_HOSTNAME;
    350  1.39       dsl 	return old_sysctl(&name[0], 2, 0, 0, (char *)SCARG_P32(uap,
    351  1.39       dsl 	    hostname), SCARG(uap, len), l);
    352   1.1       mrg }
    353   1.1       mrg 
    354   1.1       mrg int
    355  1.24   thorpej compat_43_netbsd32_sethostid(l, v, retval)
    356  1.24   thorpej 	struct lwp* l;
    357   1.4       eeh 	void *v;
    358   1.4       eeh 	register_t *retval;
    359   1.4       eeh {
    360   1.8       eeh 	struct compat_43_netbsd32_sethostid_args /* {
    361   1.4       eeh 		syscallarg(int32_t) hostid;
    362   1.4       eeh 	} */ *uap = v;
    363   1.4       eeh 	struct compat_43_sys_sethostid_args ua;
    364   1.4       eeh 
    365   1.6       mrg 	NETBSD32TO64_UAP(hostid);
    366  1.24   thorpej 	return (compat_43_sys_sethostid(l, &ua, retval));
    367   1.4       eeh }
    368   1.4       eeh 
    369   1.4       eeh int
    370  1.24   thorpej compat_43_netbsd32_ogetrlimit(l, v, retval)
    371  1.24   thorpej 	struct lwp* l;
    372   1.1       mrg 	void *v;
    373   1.1       mrg 	register_t *retval;
    374   1.1       mrg {
    375   1.8       eeh 	struct compat_43_netbsd32_ogetrlimit_args /* {
    376   1.1       mrg 		syscallarg(int) which;
    377   1.5       mrg 		syscallarg(netbsd32_orlimitp_t) rlp;
    378   1.1       mrg 	} */ *uap = v;
    379   1.1       mrg 	struct compat_43_sys_getrlimit_args ua;
    380   1.1       mrg 
    381   1.6       mrg 	NETBSD32TO64_UAP(which);
    382   1.6       mrg 	NETBSD32TOP_UAP(rlp, struct orlimit);
    383  1.24   thorpej 	return (compat_43_sys_getrlimit(l, &ua, retval));
    384   1.1       mrg }
    385   1.1       mrg 
    386   1.1       mrg int
    387  1.24   thorpej compat_43_netbsd32_osetrlimit(l, v, retval)
    388  1.24   thorpej 	struct lwp* l;
    389   1.1       mrg 	void *v;
    390   1.1       mrg 	register_t *retval;
    391   1.1       mrg {
    392   1.8       eeh 	struct compat_43_netbsd32_osetrlimit_args /* {
    393   1.1       mrg 		syscallarg(int) which;
    394   1.5       mrg 		syscallarg(netbsd32_orlimitp_t) rlp;
    395   1.1       mrg 	} */ *uap = v;
    396   1.1       mrg 	struct compat_43_sys_setrlimit_args ua;
    397   1.1       mrg 
    398   1.6       mrg 	NETBSD32TO64_UAP(which);
    399   1.6       mrg 	NETBSD32TOP_UAP(rlp, struct orlimit);
    400  1.24   thorpej 	return (compat_43_sys_setrlimit(l, &ua, retval));
    401   1.1       mrg }
    402   1.1       mrg 
    403   1.4       eeh int
    404  1.24   thorpej compat_43_netbsd32_killpg(l, v, retval)
    405  1.24   thorpej 	struct lwp* l;
    406   1.4       eeh 	void *v;
    407   1.4       eeh 	register_t *retval;
    408   1.4       eeh {
    409   1.8       eeh 	struct compat_43_netbsd32_killpg_args /* {
    410   1.4       eeh 		syscallarg(int) pgid;
    411   1.4       eeh 		syscallarg(int) signum;
    412   1.4       eeh 	} */ *uap = v;
    413   1.4       eeh 	struct compat_43_sys_killpg_args ua;
    414   1.4       eeh 
    415   1.6       mrg 	NETBSD32TO64_UAP(pgid);
    416   1.6       mrg 	NETBSD32TO64_UAP(signum);
    417  1.24   thorpej 	return (compat_43_sys_killpg(l, &ua, retval));
    418   1.4       eeh }
    419   1.4       eeh 
    420   1.1       mrg /* virtual memory syscalls */
    421   1.1       mrg int
    422  1.24   thorpej compat_43_netbsd32_ommap(l, v, retval)
    423  1.24   thorpej 	struct lwp* l;
    424   1.1       mrg 	void *v;
    425   1.1       mrg 	register_t *retval;
    426   1.1       mrg {
    427   1.8       eeh 	struct compat_43_netbsd32_ommap_args /* {
    428  1.37  christos 		syscallarg(netbsd32_caddr_t) addr;
    429   1.5       mrg 		syscallarg(netbsd32_size_t) len;
    430   1.1       mrg 		syscallarg(int) prot;
    431   1.1       mrg 		syscallarg(int) flags;
    432   1.1       mrg 		syscallarg(int) fd;
    433   1.5       mrg 		syscallarg(netbsd32_long) pos;
    434   1.1       mrg 	} */ *uap = v;
    435   1.1       mrg 	struct compat_43_sys_mmap_args ua;
    436   1.1       mrg 
    437  1.38       dsl 	NETBSD32TOP_UAP(addr, void *);
    438   1.6       mrg 	NETBSD32TOX_UAP(len, size_t);
    439   1.6       mrg 	NETBSD32TO64_UAP(prot);
    440   1.6       mrg 	NETBSD32TO64_UAP(flags);
    441   1.6       mrg 	NETBSD32TO64_UAP(fd);
    442   1.6       mrg 	NETBSD32TOX_UAP(pos, long);
    443  1.24   thorpej 	return (compat_43_sys_mmap(l, &ua, retval));
    444   1.4       eeh }
    445   1.4       eeh 
    446   1.1       mrg /* network syscalls */
    447   1.1       mrg int
    448  1.24   thorpej compat_43_netbsd32_oaccept(l, v, retval)
    449  1.24   thorpej 	struct lwp* l;
    450   1.1       mrg 	void *v;
    451   1.1       mrg 	register_t *retval;
    452   1.1       mrg {
    453   1.8       eeh 	struct compat_43_netbsd32_oaccept_args /* {
    454   1.1       mrg 		syscallarg(int) s;
    455  1.37  christos 		syscallarg(netbsd32_caddr_t) name;
    456   1.5       mrg 		syscallarg(netbsd32_intp) anamelen;
    457   1.1       mrg 	} */ *uap = v;
    458   1.1       mrg 	struct compat_43_sys_accept_args ua;
    459   1.1       mrg 
    460   1.6       mrg 	NETBSD32TOX_UAP(s, int);
    461  1.38       dsl 	NETBSD32TOP_UAP(name, void *);
    462   1.6       mrg 	NETBSD32TOP_UAP(anamelen, int);
    463  1.24   thorpej 	return (compat_43_sys_accept(l, &ua, retval));
    464   1.1       mrg }
    465   1.1       mrg 
    466   1.1       mrg int
    467  1.24   thorpej compat_43_netbsd32_osend(l, v, retval)
    468  1.24   thorpej 	struct lwp* l;
    469   1.1       mrg 	void *v;
    470   1.1       mrg 	register_t *retval;
    471   1.1       mrg {
    472   1.8       eeh 	struct compat_43_netbsd32_osend_args /* {
    473   1.1       mrg 		syscallarg(int) s;
    474  1.37  christos 		syscallarg(netbsd32_caddr_t) buf;
    475   1.1       mrg 		syscallarg(int) len;
    476   1.1       mrg 		syscallarg(int) flags;
    477   1.1       mrg 	} */ *uap = v;
    478   1.1       mrg 	struct compat_43_sys_send_args ua;
    479   1.1       mrg 
    480   1.6       mrg 	NETBSD32TO64_UAP(s);
    481  1.38       dsl 	NETBSD32TOP_UAP(buf, void *);
    482   1.6       mrg 	NETBSD32TO64_UAP(len);
    483   1.6       mrg 	NETBSD32TO64_UAP(flags);
    484  1.24   thorpej 	return (compat_43_sys_send(l, &ua, retval));
    485   1.1       mrg }
    486   1.1       mrg 
    487   1.1       mrg int
    488  1.24   thorpej compat_43_netbsd32_orecv(l, v, retval)
    489  1.24   thorpej 	struct lwp* l;
    490   1.1       mrg 	void *v;
    491   1.1       mrg 	register_t *retval;
    492   1.1       mrg {
    493   1.8       eeh 	struct compat_43_netbsd32_orecv_args /* {
    494   1.1       mrg 		syscallarg(int) s;
    495  1.37  christos 		syscallarg(netbsd32_caddr_t) buf;
    496   1.1       mrg 		syscallarg(int) len;
    497   1.1       mrg 		syscallarg(int) flags;
    498   1.1       mrg 	} */ *uap = v;
    499   1.1       mrg 	struct compat_43_sys_recv_args ua;
    500   1.1       mrg 
    501   1.6       mrg 	NETBSD32TO64_UAP(s);
    502  1.38       dsl 	NETBSD32TOP_UAP(buf, void *);
    503   1.6       mrg 	NETBSD32TO64_UAP(len);
    504   1.6       mrg 	NETBSD32TO64_UAP(flags);
    505  1.24   thorpej 	return (compat_43_sys_recv(l, &ua, retval));
    506   1.1       mrg }
    507   1.1       mrg 
    508   1.1       mrg /*
    509   1.1       mrg  * XXX convert these to use a common iovec code to the native
    510   1.1       mrg  * netbsd call.
    511   1.1       mrg  */
    512   1.1       mrg int
    513  1.24   thorpej compat_43_netbsd32_orecvmsg(l, v, retval)
    514  1.24   thorpej 	struct lwp* l;
    515   1.1       mrg 	void *v;
    516   1.1       mrg 	register_t *retval;
    517   1.1       mrg {
    518  1.24   thorpej 	struct proc *p = l->l_proc;
    519   1.8       eeh 	struct compat_43_netbsd32_orecvmsg_args /* {
    520   1.1       mrg 		syscallarg(int) s;
    521   1.5       mrg 		syscallarg(netbsd32_omsghdrp_t) msg;
    522   1.1       mrg 		syscallarg(int) flags;
    523   1.1       mrg 	} */ *uap = v;
    524   1.1       mrg 	struct compat_43_sys_recvmsg_args ua;
    525  1.16       mrg 	struct omsghdr omh, *sgsbp;
    526  1.16       mrg 	struct netbsd32_omsghdr omh32;
    527  1.16       mrg 	struct iovec iov, *sgsbp2;
    528  1.16       mrg 	struct netbsd32_iovec iov32, *iovec32p;
    529  1.36  christos 	void *sg = stackgap_init(p, 0);
    530  1.16       mrg 	int i, error, rv;
    531   1.1       mrg 
    532   1.6       mrg 	NETBSD32TO64_UAP(s);
    533   1.6       mrg 	NETBSD32TO64_UAP(flags);
    534   1.1       mrg 
    535  1.16       mrg 	/*
    536  1.16       mrg 	 * this is annoying:
    537  1.16       mrg 	 *	- copyin the msghdr32 struct
    538  1.16       mrg 	 *	- stackgap_alloc a msghdr struct
    539  1.16       mrg 	 *	- convert msghdr32 to msghdr:
    540  1.16       mrg 	 *		- stackgap_alloc enough space for iovec's
    541  1.16       mrg 	 *		- copy in each iov32, and convert to iov
    542  1.16       mrg 	 *		- copyout converted iov
    543  1.16       mrg 	 *	- copyout converted msghdr
    544  1.16       mrg 	 *	- do real syscall
    545  1.16       mrg 	 *	- copyin the msghdr struct
    546  1.16       mrg 	 *	- convert msghdr to msghdr32
    547  1.16       mrg 	 *		- copyin each iov and convert to iov32
    548  1.16       mrg 	 *		- copyout converted iov32
    549  1.16       mrg 	 *	- copyout converted msghdr32
    550  1.16       mrg 	 */
    551  1.39       dsl 	error = copyin(SCARG_P32(uap, msg), &omh32, sizeof(omh32));
    552  1.16       mrg 	if (error)
    553  1.16       mrg 		return (error);
    554  1.16       mrg 
    555  1.21  christos 	SCARG(&ua, msg) = sgsbp = stackgap_alloc(p, &sg, sizeof(omh));
    556  1.36  christos 	omh.msg_name = (void *)NETBSD32PTR64(omh32.msg_name);
    557  1.16       mrg 	omh.msg_namelen = omh32.msg_namelen;
    558  1.16       mrg 	omh.msg_iovlen = (size_t)omh32.msg_iovlen;
    559  1.21  christos 	omh.msg_iov = sgsbp2 = stackgap_alloc(p, &sg, sizeof(struct iovec) * omh.msg_iovlen);
    560  1.23       scw 	iovec32p = (struct netbsd32_iovec *)NETBSD32PTR64(omh32.msg_iov);
    561  1.16       mrg 	for (i = 0; i < omh.msg_iovlen; i++, sgsbp2++, iovec32p++) {
    562  1.16       mrg 		error = copyin(iovec32p, &iov32, sizeof(iov32));
    563  1.16       mrg 		if (error)
    564  1.16       mrg 			return (error);
    565  1.23       scw 		iov.iov_base =
    566  1.23       scw 		    (struct iovec *)NETBSD32PTR64(iovec32p->iov_base);
    567  1.16       mrg 		iov.iov_len = (size_t)iovec32p->iov_len;
    568  1.16       mrg 		error = copyout(&iov, sgsbp2, sizeof(iov));
    569  1.16       mrg 		if (error)
    570  1.16       mrg 			return (error);
    571   1.1       mrg 	}
    572  1.36  christos 	omh.msg_accrights = (void *)NETBSD32PTR64(omh32.msg_accrights);
    573  1.16       mrg 	omh.msg_accrightslen = omh32.msg_accrightslen;
    574  1.16       mrg 	error = copyout(&omh, sgsbp, sizeof(omh));
    575  1.16       mrg 	if (error)
    576  1.16       mrg 		return (error);
    577   1.1       mrg 
    578  1.24   thorpej 	rv = compat_43_sys_recvmsg(l, &ua, retval);
    579   1.1       mrg 
    580  1.16       mrg 	error = copyin(sgsbp, &omh, sizeof(omh));
    581  1.16       mrg 	if (error)
    582  1.16       mrg 		return error;
    583  1.38       dsl 	NETBSD32PTR32(omh32.msg_name, omh.msg_name);
    584  1.16       mrg 	omh32.msg_namelen = omh.msg_namelen;
    585  1.16       mrg 	omh32.msg_iovlen = (netbsd32_size_t)omh.msg_iovlen;
    586  1.38       dsl 	iovec32p = NETBSD32PTR64(omh32.msg_iov);
    587  1.16       mrg 	sgsbp2 = omh.msg_iov;
    588  1.16       mrg 	for (i = 0; i < omh.msg_iovlen; i++, sgsbp2++, iovec32p++) {
    589  1.16       mrg 		error = copyin(sgsbp2, &iov, sizeof(iov));
    590  1.16       mrg 		if (error)
    591  1.16       mrg 			return (error);
    592  1.38       dsl 		NETBSD32PTR32(iov32.iov_base, iov.iov_base);
    593  1.16       mrg 		iov32.iov_len = (netbsd32_size_t)iov.iov_len;
    594  1.16       mrg 		error = copyout(&iov32, iovec32p, sizeof(iov32));
    595  1.16       mrg 		if (error)
    596  1.16       mrg 			return (error);
    597  1.16       mrg 	}
    598  1.38       dsl 	NETBSD32PTR32(omh32.msg_accrights, omh.msg_accrights);
    599  1.16       mrg 	omh32.msg_accrightslen = omh.msg_accrightslen;
    600  1.16       mrg 
    601  1.39       dsl 	error = copyout(&omh32, SCARG_P32(uap, msg), sizeof(omh32));
    602  1.16       mrg 	if (error)
    603  1.16       mrg 		return error;
    604  1.16       mrg 
    605  1.16       mrg 	return (rv);
    606   1.1       mrg }
    607   1.1       mrg 
    608   1.1       mrg int
    609  1.24   thorpej compat_43_netbsd32_osendmsg(l, v, retval)
    610  1.24   thorpej 	struct lwp* l;
    611   1.1       mrg 	void *v;
    612   1.1       mrg 	register_t *retval;
    613   1.1       mrg {
    614  1.24   thorpej 	struct proc *p = l->l_proc;
    615   1.8       eeh 	struct compat_43_netbsd32_osendmsg_args /* {
    616   1.1       mrg 		syscallarg(int) s;
    617  1.37  christos 		syscallarg(netbsd32_caddr_t) msg;
    618   1.1       mrg 		syscallarg(int) flags;
    619   1.1       mrg 	} */ *uap = v;
    620  1.16       mrg 	struct compat_43_sys_recvmsg_args ua;
    621  1.16       mrg 	struct omsghdr omh, *sgsbp;
    622  1.16       mrg 	struct netbsd32_omsghdr omh32;
    623  1.16       mrg 	struct iovec iov, *sgsbp2;
    624  1.16       mrg 	struct netbsd32_iovec iov32, *iovec32p;
    625  1.36  christos 	void *sg = stackgap_init(p, 0);
    626  1.16       mrg 	int i, error, rv;
    627   1.1       mrg 
    628   1.6       mrg 	NETBSD32TO64_UAP(s);
    629   1.6       mrg 	NETBSD32TO64_UAP(flags);
    630   1.1       mrg 
    631  1.16       mrg 	/*
    632  1.16       mrg 	 * this is annoying:
    633  1.16       mrg 	 *	- copyin the msghdr32 struct
    634  1.16       mrg 	 *	- stackgap_alloc a msghdr struct
    635  1.16       mrg 	 *	- convert msghdr32 to msghdr:
    636  1.16       mrg 	 *		- stackgap_alloc enough space for iovec's
    637  1.16       mrg 	 *		- copy in each iov32, and convert to iov
    638  1.16       mrg 	 *		- copyout converted iov
    639  1.16       mrg 	 *	- copyout converted msghdr
    640  1.16       mrg 	 *	- do real syscall
    641  1.16       mrg 	 *	- copyin the msghdr struct
    642  1.16       mrg 	 *	- convert msghdr to msghdr32
    643  1.16       mrg 	 *		- copyin each iov and convert to iov32
    644  1.16       mrg 	 *		- copyout converted iov32
    645  1.16       mrg 	 *	- copyout converted msghdr32
    646  1.16       mrg 	 */
    647  1.39       dsl 	error = copyin(SCARG_P32(uap, msg), &omh32, sizeof(omh32));
    648  1.16       mrg 	if (error)
    649  1.16       mrg 		return (error);
    650  1.16       mrg 
    651  1.21  christos 	SCARG(&ua, msg) = sgsbp = stackgap_alloc(p, &sg, sizeof(omh));
    652  1.38       dsl 	omh.msg_name = NETBSD32PTR64(omh32.msg_name);
    653  1.16       mrg 	omh.msg_namelen = omh32.msg_namelen;
    654  1.16       mrg 	omh.msg_iovlen = (size_t)omh32.msg_iovlen;
    655  1.21  christos 	omh.msg_iov = sgsbp2 = stackgap_alloc(p, &sg, sizeof(struct iovec) * omh.msg_iovlen);
    656  1.38       dsl 	iovec32p = NETBSD32PTR64(omh32.msg_iov);
    657  1.16       mrg 	for (i = 0; i < omh.msg_iovlen; i++, sgsbp2++, iovec32p++) {
    658  1.16       mrg 		error = copyin(iovec32p, &iov32, sizeof(iov32));
    659  1.16       mrg 		if (error)
    660  1.16       mrg 			return (error);
    661  1.38       dsl 		iov.iov_base = NETBSD32PTR64(iovec32p->iov_base);
    662  1.16       mrg 		iov.iov_len = (size_t)iovec32p->iov_len;
    663  1.16       mrg 		error = copyout(&iov, sgsbp2, sizeof(iov));
    664  1.16       mrg 		if (error)
    665  1.16       mrg 			return (error);
    666   1.1       mrg 	}
    667  1.38       dsl 	omh.msg_accrights = NETBSD32PTR64(omh32.msg_accrights);
    668  1.16       mrg 	omh.msg_accrightslen = omh32.msg_accrightslen;
    669  1.16       mrg 	error = copyout(&omh, sgsbp, sizeof(omh));
    670  1.16       mrg 	if (error)
    671  1.16       mrg 		return (error);
    672   1.1       mrg 
    673  1.24   thorpej 	rv = compat_43_sys_sendmsg(l, &ua, retval);
    674   1.1       mrg 
    675  1.16       mrg 	error = copyin(sgsbp, &omh, sizeof(omh));
    676  1.16       mrg 	if (error)
    677  1.16       mrg 		return error;
    678  1.38       dsl 	NETBSD32PTR32(omh32.msg_name, omh.msg_name);
    679  1.16       mrg 	omh32.msg_namelen = omh.msg_namelen;
    680  1.16       mrg 	omh32.msg_iovlen = (netbsd32_size_t)omh.msg_iovlen;
    681  1.38       dsl 	iovec32p = NETBSD32PTR64(omh32.msg_iov);
    682  1.16       mrg 	sgsbp2 = omh.msg_iov;
    683  1.16       mrg 	for (i = 0; i < omh.msg_iovlen; i++, sgsbp2++, iovec32p++) {
    684  1.16       mrg 		error = copyin(sgsbp2, &iov, sizeof(iov));
    685  1.16       mrg 		if (error)
    686  1.16       mrg 			return (error);
    687  1.38       dsl 		NETBSD32PTR32(iov32.iov_base, iov.iov_base);
    688  1.16       mrg 		iov32.iov_len = (netbsd32_size_t)iov.iov_len;
    689  1.16       mrg 		error = copyout(&iov32, iovec32p, sizeof(iov32));
    690  1.16       mrg 		if (error)
    691  1.16       mrg 			return (error);
    692  1.16       mrg 	}
    693  1.38       dsl 	NETBSD32PTR32(omh32.msg_accrights, omh.msg_accrights);
    694  1.16       mrg 	omh32.msg_accrightslen = omh.msg_accrightslen;
    695  1.16       mrg 
    696  1.39       dsl 	error = copyout(&omh32, SCARG_P32(uap, msg), sizeof(omh32));
    697  1.16       mrg 	if (error)
    698  1.16       mrg 		return error;
    699  1.16       mrg 
    700  1.16       mrg 	return (rv);
    701   1.1       mrg }
    702   1.1       mrg 
    703   1.1       mrg int
    704  1.24   thorpej compat_43_netbsd32_orecvfrom(l, v, retval)
    705  1.24   thorpej 	struct lwp* l;
    706   1.1       mrg 	void *v;
    707   1.1       mrg 	register_t *retval;
    708   1.1       mrg {
    709   1.8       eeh 	struct compat_43_netbsd32_orecvfrom_args /* {
    710   1.1       mrg 		syscallarg(int) s;
    711  1.37  christos 		syscallarg(netbsd32_caddr_t) buf;
    712   1.5       mrg 		syscallarg(netbsd32_size_t) len;
    713   1.1       mrg 		syscallarg(int) flags;
    714  1.37  christos 		syscallarg(netbsd32_caddr_t) from;
    715   1.5       mrg 		syscallarg(netbsd32_intp) fromlenaddr;
    716   1.1       mrg 	} */ *uap = v;
    717   1.1       mrg 	struct compat_43_sys_recvfrom_args ua;
    718   1.1       mrg 
    719   1.6       mrg 	NETBSD32TO64_UAP(s);
    720  1.38       dsl 	NETBSD32TOP_UAP(buf, void *);
    721   1.6       mrg 	NETBSD32TOX_UAP(len, size_t);
    722   1.6       mrg 	NETBSD32TO64_UAP(flags);
    723  1.38       dsl 	NETBSD32TOP_UAP(from, void *);
    724   1.6       mrg 	NETBSD32TOP_UAP(fromlenaddr, int);
    725  1.24   thorpej 	return (compat_43_sys_recvfrom(l, &ua, retval));
    726   1.1       mrg }
    727   1.1       mrg 
    728   1.1       mrg int
    729  1.24   thorpej compat_43_netbsd32_ogetsockname(l, v, retval)
    730  1.24   thorpej 	struct lwp* l;
    731   1.1       mrg 	void *v;
    732   1.1       mrg 	register_t *retval;
    733   1.1       mrg {
    734   1.8       eeh 	struct compat_43_netbsd32_ogetsockname_args /* {
    735   1.1       mrg 		syscallarg(int) fdec;
    736  1.37  christos 		syscallarg(netbsd32_caddr_t) asa;
    737   1.5       mrg 		syscallarg(netbsd32_intp) alen;
    738   1.1       mrg 	} */ *uap = v;
    739   1.1       mrg 	struct compat_43_sys_getsockname_args ua;
    740   1.1       mrg 
    741   1.6       mrg 	NETBSD32TO64_UAP(fdec);
    742  1.38       dsl 	NETBSD32TOP_UAP(asa, void *);
    743  1.38       dsl 	NETBSD32TOP_UAP(alen, int *);
    744  1.24   thorpej 	return (compat_43_sys_getsockname(l, &ua, retval));
    745   1.1       mrg }
    746   1.1       mrg 
    747   1.1       mrg int
    748  1.24   thorpej compat_43_netbsd32_ogetpeername(l, v, retval)
    749  1.24   thorpej 	struct lwp* l;
    750   1.1       mrg 	void *v;
    751   1.1       mrg 	register_t *retval;
    752   1.1       mrg {
    753   1.8       eeh 	struct compat_43_netbsd32_ogetpeername_args /* {
    754   1.1       mrg 		syscallarg(int) fdes;
    755  1.37  christos 		syscallarg(netbsd32_caddr_t) asa;
    756   1.5       mrg 		syscallarg(netbsd32_intp) alen;
    757   1.1       mrg 	} */ *uap = v;
    758   1.1       mrg 	struct compat_43_sys_getpeername_args ua;
    759   1.1       mrg 
    760   1.6       mrg 	NETBSD32TO64_UAP(fdes);
    761  1.38       dsl 	NETBSD32TOP_UAP(asa, void *);
    762  1.38       dsl 	NETBSD32TOP_UAP(alen, int *);
    763  1.24   thorpej 	return (compat_43_sys_getpeername(l, &ua, retval));
    764   1.1       mrg }
    765   1.1       mrg 
    766   1.1       mrg /* signal syscalls */
    767   1.1       mrg int
    768  1.24   thorpej compat_43_netbsd32_osigvec(l, v, retval)
    769  1.24   thorpej 	struct lwp* l;
    770   1.1       mrg 	void *v;
    771   1.1       mrg 	register_t *retval;
    772   1.1       mrg {
    773  1.24   thorpej 	struct proc *p = l->l_proc;
    774   1.8       eeh 	struct compat_43_netbsd32_osigvec_args /* {
    775   1.1       mrg 		syscallarg(int) signum;
    776   1.5       mrg 		syscallarg(netbsd32_sigvecp_t) nsv;
    777   1.5       mrg 		syscallarg(netbsd32_sigvecp_t) osv;
    778   1.1       mrg 	} */ *uap = v;
    779   1.1       mrg 	struct compat_43_sys_sigvec_args ua;
    780  1.16       mrg 	struct netbsd32_sigvec sv32;
    781  1.28  christos 	struct sigvec sv;
    782  1.36  christos 	void *sg = stackgap_init(p, 0);
    783  1.16       mrg 	int rv, error;
    784   1.1       mrg 
    785   1.6       mrg 	NETBSD32TO64_UAP(signum);
    786  1.39       dsl 	if (SCARG_P32(uap, osv))
    787  1.28  christos 		SCARG(&ua, osv) = stackgap_alloc(p, &sg, sizeof(sv));
    788   1.1       mrg 	else
    789   1.1       mrg 		SCARG(&ua, osv) = NULL;
    790  1.39       dsl 	if (SCARG_P32(uap, nsv)) {
    791  1.28  christos 		SCARG(&ua, nsv) = stackgap_alloc(p, &sg, sizeof(sv));
    792  1.39       dsl 		error = copyin(SCARG_P32(uap, nsv), &sv32, sizeof(sv32));
    793  1.16       mrg 		if (error)
    794  1.16       mrg 			return (error);
    795  1.23       scw 		sv.sv_handler = (void *)NETBSD32PTR64(sv32.sv_handler);
    796  1.16       mrg 		sv.sv_mask = sv32.sv_mask;
    797  1.16       mrg 		sv.sv_flags = sv32.sv_flags;
    798  1.28  christos 		error = copyout(&sv, SCARG(&ua, nsv), sizeof(sv));
    799  1.16       mrg 		if (error)
    800  1.16       mrg 			return (error);
    801   1.1       mrg 	} else
    802   1.1       mrg 		SCARG(&ua, nsv) = NULL;
    803  1.24   thorpej 	rv = compat_43_sys_sigvec(l, &ua, retval);
    804   1.1       mrg 	if (rv)
    805   1.1       mrg 		return (rv);
    806   1.1       mrg 
    807  1.39       dsl 	if (SCARG_P32(uap, osv)) {
    808  1.28  christos 		error = copyin(SCARG(&ua, osv), &sv, sizeof(sv));
    809  1.16       mrg 		if (error)
    810  1.16       mrg 			return (error);
    811  1.38       dsl 		NETBSD32PTR32(sv32.sv_handler, sv.sv_handler);
    812  1.16       mrg 		sv32.sv_mask = sv.sv_mask;
    813  1.16       mrg 		sv32.sv_flags = sv.sv_flags;
    814  1.39       dsl 		error = copyout(&sv32, SCARG_P32(uap, osv), sizeof(sv32));
    815  1.16       mrg 		if (error)
    816  1.16       mrg 			return (error);
    817   1.1       mrg 	}
    818   1.1       mrg 
    819   1.1       mrg 	return (0);
    820   1.4       eeh }
    821   1.4       eeh 
    822   1.4       eeh int
    823  1.24   thorpej compat_43_netbsd32_sigblock(l, v, retval)
    824  1.24   thorpej 	struct lwp* l;
    825   1.4       eeh 	void *v;
    826   1.4       eeh 	register_t *retval;
    827   1.4       eeh {
    828   1.8       eeh 	struct compat_43_netbsd32_sigblock_args /* {
    829   1.4       eeh 		syscallarg(int) mask;
    830   1.4       eeh 	} */ *uap = v;
    831   1.4       eeh 	struct compat_43_sys_sigblock_args ua;
    832   1.4       eeh 
    833   1.6       mrg 	NETBSD32TO64_UAP(mask);
    834  1.24   thorpej 	return (compat_43_sys_sigblock(l, &ua, retval));
    835   1.4       eeh }
    836   1.4       eeh 
    837   1.4       eeh int
    838  1.24   thorpej compat_43_netbsd32_sigsetmask(l, v, retval)
    839  1.24   thorpej 	struct lwp* l;
    840   1.4       eeh 	void *v;
    841   1.4       eeh 	register_t *retval;
    842   1.4       eeh {
    843   1.8       eeh 	struct compat_43_netbsd32_sigsetmask_args /* {
    844   1.4       eeh 		syscallarg(int) mask;
    845   1.4       eeh 	} */ *uap = v;
    846   1.4       eeh 	struct compat_43_sys_sigsetmask_args ua;
    847   1.4       eeh 
    848   1.6       mrg 	NETBSD32TO64_UAP(mask);
    849  1.24   thorpej 	return (compat_43_sys_sigsetmask(l, &ua, retval));
    850   1.1       mrg }
    851   1.1       mrg 
    852   1.1       mrg int
    853  1.24   thorpej compat_43_netbsd32_osigstack(l, v, retval)
    854  1.24   thorpej 	struct lwp* l;
    855   1.1       mrg 	void *v;
    856   1.1       mrg 	register_t *retval;
    857   1.1       mrg {
    858  1.24   thorpej 	struct proc *p = l->l_proc;
    859   1.8       eeh 	struct compat_43_netbsd32_osigstack_args /* {
    860   1.5       mrg 		syscallarg(netbsd32_sigstackp_t) nss;
    861   1.5       mrg 		syscallarg(netbsd32_sigstackp_t) oss;
    862   1.1       mrg 	} */ *uap = v;
    863   1.1       mrg 	struct compat_43_sys_sigstack_args ua;
    864  1.16       mrg 	struct netbsd32_sigstack ss32;
    865  1.28  christos 	struct sigstack ss;
    866  1.36  christos 	void *sg = stackgap_init(p, 0);
    867  1.16       mrg 	int error, rv;
    868   1.1       mrg 
    869  1.39       dsl 	if (SCARG_P32(uap, oss))
    870  1.28  christos 		SCARG(&ua, oss) = stackgap_alloc(p, &sg, sizeof(ss));
    871   1.1       mrg 	else
    872   1.1       mrg 		SCARG(&ua, oss) = NULL;
    873  1.39       dsl 	if (SCARG_P32(uap, nss)) {
    874  1.28  christos 		SCARG(&ua, nss) = stackgap_alloc(p, &sg, sizeof(ss));
    875  1.39       dsl 		error = copyin(SCARG_P32(uap, nss), &ss32, sizeof(ss32));
    876  1.16       mrg 		if (error)
    877  1.16       mrg 			return (error);
    878  1.38       dsl 		ss.ss_sp = NETBSD32PTR64(ss32.ss_sp);
    879  1.16       mrg 		ss.ss_onstack = ss32.ss_onstack;
    880  1.28  christos 		error = copyout(&ss, SCARG(&ua, nss), sizeof(ss));
    881  1.16       mrg 		if (error)
    882  1.16       mrg 			return (error);
    883   1.1       mrg 	} else
    884   1.1       mrg 		SCARG(&ua, nss) = NULL;
    885   1.1       mrg 
    886  1.24   thorpej 	rv = compat_43_sys_sigstack(l, &ua, retval);
    887   1.1       mrg 	if (rv)
    888   1.1       mrg 		return (rv);
    889   1.1       mrg 
    890  1.39       dsl 	if (SCARG_P32(uap, oss)) {
    891  1.28  christos 		error = copyin(SCARG(&ua, oss), &ss, sizeof(ss));
    892  1.16       mrg 		if (error)
    893  1.16       mrg 			return (error);
    894  1.38       dsl 		NETBSD32PTR32(ss32.ss_sp, ss.ss_sp);
    895  1.16       mrg 		ss32.ss_onstack = ss.ss_onstack;
    896  1.39       dsl 		error = copyout(&ss32, SCARG_P32(uap, oss), sizeof(ss32));
    897  1.16       mrg 		if (error)
    898  1.16       mrg 			return (error);
    899   1.1       mrg 	}
    900   1.1       mrg 
    901   1.1       mrg 	return (0);
    902   1.1       mrg }
    903