Home | History | Annotate | Line # | Download | only in netbsd32
netbsd32_compat_43.c revision 1.35.2.1
      1  1.35.2.1     rmind /*	$NetBSD: netbsd32_compat_43.c,v 1.35.2.1 2007/03/12 05:52:31 rmind 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.35.2.1     rmind __KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_43.c,v 1.35.2.1 2007/03/12 05:52:31 rmind 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.35.2.1     rmind 	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.35.2.1     rmind 	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.23       scw 	error = copyout(&sb32, (char *)NETBSD32PTR64(SCARG(uap, ub)),
    168      1.23       scw 	    sizeof(sb32));
    169      1.15       mrg 	if (error)
    170      1.15       mrg 		return error;
    171       1.1       mrg 
    172       1.1       mrg 	return (rv);
    173       1.1       mrg }
    174       1.1       mrg 
    175       1.1       mrg int
    176      1.24   thorpej compat_43_netbsd32_lstat43(l, v, retval)
    177      1.24   thorpej 	struct lwp *l;
    178       1.1       mrg 	void *v;
    179       1.1       mrg 	register_t *retval;
    180       1.1       mrg {
    181      1.24   thorpej 	struct proc *p = l->l_proc;
    182       1.8       eeh 	struct compat_43_netbsd32_lstat43_args /* {
    183       1.5       mrg 		syscallarg(const netbsd32_charp) path;
    184       1.5       mrg 		syscallarg(netbsd32_stat43p_t) ub;
    185       1.1       mrg 	} */ *uap = v;
    186      1.15       mrg 	struct stat43 sb43, *sgsbp;
    187      1.15       mrg 	struct netbsd32_stat43 sb32;
    188       1.1       mrg 	struct compat_43_sys_lstat_args ua;
    189  1.35.2.1     rmind 	void *sg = stackgap_init(p, 0);
    190      1.15       mrg 	int rv, error;
    191       1.1       mrg 
    192       1.6       mrg 	NETBSD32TOP_UAP(path, const char);
    193      1.21  christos 	SCARG(&ua, ub) = sgsbp = stackgap_alloc(p, &sg, sizeof(sb43));
    194      1.34  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(&ua, path));
    195      1.24   thorpej 	rv = compat_43_sys_stat(l, &ua, retval);
    196       1.1       mrg 
    197      1.15       mrg 	error = copyin(sgsbp, &sb43, sizeof(sb43));
    198      1.15       mrg 	if (error)
    199      1.15       mrg 		return error;
    200      1.15       mrg 	netbsd32_from_stat43(&sb43, &sb32);
    201      1.23       scw 	error = copyout(&sb32, (char *)NETBSD32PTR64(SCARG(uap, ub)),
    202      1.23       scw 	    sizeof(sb32));
    203      1.15       mrg 	if (error)
    204      1.15       mrg 		return error;
    205       1.1       mrg 
    206       1.1       mrg 	return (rv);
    207       1.1       mrg }
    208       1.1       mrg 
    209       1.1       mrg int
    210      1.24   thorpej compat_43_netbsd32_fstat43(l, v, retval)
    211      1.24   thorpej 	struct lwp *l;
    212       1.1       mrg 	void *v;
    213       1.1       mrg 	register_t *retval;
    214       1.1       mrg {
    215      1.24   thorpej 	struct proc *p = l->l_proc;
    216       1.8       eeh 	struct compat_43_netbsd32_fstat43_args /* {
    217       1.1       mrg 		syscallarg(int) fd;
    218       1.5       mrg 		syscallarg(netbsd32_stat43p_t) sb;
    219       1.1       mrg 	} */ *uap = v;
    220      1.15       mrg 	struct stat43 sb43, *sgsbp;
    221      1.15       mrg 	struct netbsd32_stat43 sb32;
    222       1.1       mrg 	struct compat_43_sys_fstat_args ua;
    223  1.35.2.1     rmind 	void *sg = stackgap_init(p, 0);
    224      1.15       mrg 	int rv, error;
    225       1.1       mrg 
    226       1.6       mrg 	NETBSD32TO64_UAP(fd);
    227      1.21  christos 	SCARG(&ua, sb) = sgsbp = stackgap_alloc(p, &sg, sizeof(sb43));
    228      1.24   thorpej 	rv = compat_43_sys_fstat(l, &ua, retval);
    229       1.1       mrg 
    230      1.15       mrg 	error = copyin(sgsbp, &sb43, sizeof(sb43));
    231      1.15       mrg 	if (error)
    232      1.15       mrg 		return error;
    233      1.15       mrg 	netbsd32_from_stat43(&sb43, &sb32);
    234      1.23       scw 	error = copyout(&sb32, (char *)NETBSD32PTR64(SCARG(uap, sb)),
    235      1.23       scw 	    sizeof(sb32));
    236      1.15       mrg 	if (error)
    237      1.15       mrg 		return error;
    238       1.1       mrg 
    239       1.1       mrg 	return (rv);
    240       1.1       mrg }
    241       1.1       mrg 
    242       1.1       mrg int
    243      1.24   thorpej compat_43_netbsd32_otruncate(l, v, retval)
    244      1.24   thorpej 	struct lwp *l;
    245       1.1       mrg 	void *v;
    246       1.1       mrg 	register_t *retval;
    247       1.1       mrg {
    248       1.8       eeh 	struct compat_43_netbsd32_otruncate_args /* {
    249       1.5       mrg 		syscallarg(const netbsd32_charp) path;
    250       1.5       mrg 		syscallarg(netbsd32_long) length;
    251       1.1       mrg 	} */ *uap = v;
    252       1.1       mrg 	struct sys_truncate_args ua;
    253       1.1       mrg 
    254       1.6       mrg 	NETBSD32TOP_UAP(path, const char);
    255       1.6       mrg 	NETBSD32TO64_UAP(length);
    256      1.24   thorpej 	return (sys_ftruncate(l, &ua, retval));
    257       1.1       mrg }
    258       1.1       mrg 
    259       1.1       mrg int
    260      1.24   thorpej compat_43_netbsd32_oftruncate(l, v, retval)
    261      1.24   thorpej 	struct lwp *l;
    262       1.1       mrg 	void *v;
    263       1.1       mrg 	register_t *retval;
    264       1.1       mrg {
    265       1.8       eeh 	struct compat_43_netbsd32_oftruncate_args /* {
    266       1.1       mrg 		syscallarg(int) fd;
    267       1.5       mrg 		syscallarg(netbsd32_long) length;
    268       1.1       mrg 	} */ *uap = v;
    269       1.1       mrg 	struct sys_ftruncate_args ua;
    270       1.1       mrg 
    271       1.6       mrg 	NETBSD32TO64_UAP(fd);
    272       1.6       mrg 	NETBSD32TO64_UAP(length);
    273      1.24   thorpej 	return (sys_ftruncate(l, &ua, retval));
    274       1.1       mrg }
    275       1.1       mrg 
    276       1.1       mrg int
    277      1.24   thorpej compat_43_netbsd32_ogetdirentries(l, v, retval)
    278      1.24   thorpej 	struct lwp *l;
    279       1.1       mrg 	void *v;
    280       1.1       mrg 	register_t *retval;
    281       1.1       mrg {
    282       1.8       eeh 	struct compat_43_netbsd32_ogetdirentries_args /* {
    283       1.1       mrg 		syscallarg(int) fd;
    284       1.5       mrg 		syscallarg(netbsd32_charp) buf;
    285       1.1       mrg 		syscallarg(u_int) count;
    286       1.5       mrg 		syscallarg(netbsd32_longp) basep;
    287       1.1       mrg 	} */ *uap = v;
    288       1.1       mrg 	struct compat_43_sys_getdirentries_args ua;
    289       1.1       mrg 
    290       1.6       mrg 	NETBSD32TO64_UAP(fd);
    291       1.6       mrg 	NETBSD32TOP_UAP(buf, char);
    292       1.6       mrg 	NETBSD32TO64_UAP(count);
    293       1.6       mrg 	NETBSD32TOP_UAP(basep, long);
    294      1.24   thorpej 	return (compat_43_sys_getdirentries(l, &ua, retval));
    295       1.1       mrg }
    296       1.1       mrg 
    297       1.1       mrg /* kernel syscalls */
    298       1.1       mrg int
    299      1.24   thorpej compat_43_netbsd32_ogetkerninfo(l, v, retval)
    300      1.24   thorpej 	struct lwp *l;
    301       1.1       mrg 	void *v;
    302       1.1       mrg 	register_t *retval;
    303       1.1       mrg {
    304       1.8       eeh 	struct compat_43_netbsd32_ogetkerninfo_args /* {
    305       1.1       mrg 		syscallarg(int) op;
    306       1.5       mrg 		syscallarg(netbsd32_charp) where;
    307       1.5       mrg 		syscallarg(netbsd32_intp) size;
    308       1.1       mrg 		syscallarg(int) arg;
    309       1.1       mrg 	} */ *uap = v;
    310       1.1       mrg 	struct compat_43_sys_getkerninfo_args ua;
    311       1.1       mrg 
    312       1.6       mrg 	NETBSD32TO64_UAP(op);
    313       1.6       mrg 	NETBSD32TOP_UAP(where, char);
    314       1.6       mrg 	NETBSD32TOP_UAP(size, int);
    315       1.6       mrg 	NETBSD32TO64_UAP(arg);
    316      1.24   thorpej 	return (compat_43_sys_getkerninfo(l, &ua, retval));
    317       1.1       mrg }
    318       1.1       mrg 
    319       1.1       mrg int
    320      1.24   thorpej compat_43_netbsd32_ogethostname(l, v, retval)
    321      1.24   thorpej 	struct lwp* l;
    322       1.1       mrg 	void *v;
    323       1.1       mrg 	register_t *retval;
    324       1.1       mrg {
    325       1.8       eeh 	struct compat_43_netbsd32_ogethostname_args /* {
    326       1.5       mrg 		syscallarg(netbsd32_charp) hostname;
    327       1.1       mrg 		syscallarg(u_int) len;
    328       1.1       mrg 	} */ *uap = v;
    329      1.29    atatat 	int name[2];
    330       1.1       mrg 	size_t sz;
    331       1.1       mrg 
    332      1.29    atatat 	name[0] = CTL_KERN;
    333      1.29    atatat 	name[1] = KERN_HOSTNAME;
    334       1.1       mrg 	sz = SCARG(uap, len);
    335      1.29    atatat 	return (old_sysctl(&name[0], 2,
    336      1.29    atatat 	    (char *)NETBSD32PTR64(SCARG(uap, hostname)), &sz, 0, 0, l));
    337       1.1       mrg }
    338       1.1       mrg 
    339       1.1       mrg int
    340      1.24   thorpej compat_43_netbsd32_osethostname(l, v, retval)
    341      1.24   thorpej 	struct lwp* l;
    342       1.1       mrg 	void *v;
    343       1.1       mrg 	register_t *retval;
    344       1.1       mrg {
    345       1.8       eeh 	struct compat_43_netbsd32_osethostname_args /* {
    346       1.5       mrg 		syscallarg(netbsd32_charp) hostname;
    347       1.1       mrg 		syscallarg(u_int) len;
    348       1.1       mrg 	} */ *uap = v;
    349      1.29    atatat 	int name[2];
    350       1.1       mrg 
    351      1.29    atatat 	name[0] = CTL_KERN;
    352      1.29    atatat 	name[1] = KERN_HOSTNAME;
    353      1.29    atatat 	return (old_sysctl(&name[0], 2, 0, 0, (char *)NETBSD32PTR64(SCARG(uap,
    354      1.29    atatat 	    hostname)), SCARG(uap, len), l));
    355       1.1       mrg }
    356       1.1       mrg 
    357       1.1       mrg int
    358      1.24   thorpej compat_43_netbsd32_sethostid(l, v, retval)
    359      1.24   thorpej 	struct lwp* l;
    360       1.4       eeh 	void *v;
    361       1.4       eeh 	register_t *retval;
    362       1.4       eeh {
    363       1.8       eeh 	struct compat_43_netbsd32_sethostid_args /* {
    364       1.4       eeh 		syscallarg(int32_t) hostid;
    365       1.4       eeh 	} */ *uap = v;
    366       1.4       eeh 	struct compat_43_sys_sethostid_args ua;
    367       1.4       eeh 
    368       1.6       mrg 	NETBSD32TO64_UAP(hostid);
    369      1.24   thorpej 	return (compat_43_sys_sethostid(l, &ua, retval));
    370       1.4       eeh }
    371       1.4       eeh 
    372       1.4       eeh int
    373      1.24   thorpej compat_43_netbsd32_ogetrlimit(l, v, retval)
    374      1.24   thorpej 	struct lwp* l;
    375       1.1       mrg 	void *v;
    376       1.1       mrg 	register_t *retval;
    377       1.1       mrg {
    378       1.8       eeh 	struct compat_43_netbsd32_ogetrlimit_args /* {
    379       1.1       mrg 		syscallarg(int) which;
    380       1.5       mrg 		syscallarg(netbsd32_orlimitp_t) rlp;
    381       1.1       mrg 	} */ *uap = v;
    382       1.1       mrg 	struct compat_43_sys_getrlimit_args ua;
    383       1.1       mrg 
    384       1.6       mrg 	NETBSD32TO64_UAP(which);
    385       1.6       mrg 	NETBSD32TOP_UAP(rlp, struct orlimit);
    386      1.24   thorpej 	return (compat_43_sys_getrlimit(l, &ua, retval));
    387       1.1       mrg }
    388       1.1       mrg 
    389       1.1       mrg int
    390      1.24   thorpej compat_43_netbsd32_osetrlimit(l, v, retval)
    391      1.24   thorpej 	struct lwp* l;
    392       1.1       mrg 	void *v;
    393       1.1       mrg 	register_t *retval;
    394       1.1       mrg {
    395       1.8       eeh 	struct compat_43_netbsd32_osetrlimit_args /* {
    396       1.1       mrg 		syscallarg(int) which;
    397       1.5       mrg 		syscallarg(netbsd32_orlimitp_t) rlp;
    398       1.1       mrg 	} */ *uap = v;
    399       1.1       mrg 	struct compat_43_sys_setrlimit_args ua;
    400       1.1       mrg 
    401       1.6       mrg 	NETBSD32TO64_UAP(which);
    402       1.6       mrg 	NETBSD32TOP_UAP(rlp, struct orlimit);
    403      1.24   thorpej 	return (compat_43_sys_setrlimit(l, &ua, retval));
    404       1.1       mrg }
    405       1.1       mrg 
    406       1.4       eeh int
    407      1.24   thorpej compat_43_netbsd32_killpg(l, v, retval)
    408      1.24   thorpej 	struct lwp* l;
    409       1.4       eeh 	void *v;
    410       1.4       eeh 	register_t *retval;
    411       1.4       eeh {
    412       1.8       eeh 	struct compat_43_netbsd32_killpg_args /* {
    413       1.4       eeh 		syscallarg(int) pgid;
    414       1.4       eeh 		syscallarg(int) signum;
    415       1.4       eeh 	} */ *uap = v;
    416       1.4       eeh 	struct compat_43_sys_killpg_args ua;
    417       1.4       eeh 
    418       1.6       mrg 	NETBSD32TO64_UAP(pgid);
    419       1.6       mrg 	NETBSD32TO64_UAP(signum);
    420      1.24   thorpej 	return (compat_43_sys_killpg(l, &ua, retval));
    421       1.4       eeh }
    422       1.4       eeh 
    423       1.1       mrg /* virtual memory syscalls */
    424       1.1       mrg int
    425      1.24   thorpej compat_43_netbsd32_ommap(l, v, retval)
    426      1.24   thorpej 	struct lwp* l;
    427       1.1       mrg 	void *v;
    428       1.1       mrg 	register_t *retval;
    429       1.1       mrg {
    430       1.8       eeh 	struct compat_43_netbsd32_ommap_args /* {
    431       1.5       mrg 		syscallarg(netbsd32_caddr_t) addr;
    432       1.5       mrg 		syscallarg(netbsd32_size_t) len;
    433       1.1       mrg 		syscallarg(int) prot;
    434       1.1       mrg 		syscallarg(int) flags;
    435       1.1       mrg 		syscallarg(int) fd;
    436       1.5       mrg 		syscallarg(netbsd32_long) pos;
    437       1.1       mrg 	} */ *uap = v;
    438       1.1       mrg 	struct compat_43_sys_mmap_args ua;
    439       1.1       mrg 
    440  1.35.2.1     rmind 	NETBSD32TOX64_UAP(addr, void *);
    441       1.6       mrg 	NETBSD32TOX_UAP(len, size_t);
    442       1.6       mrg 	NETBSD32TO64_UAP(prot);
    443       1.6       mrg 	NETBSD32TO64_UAP(flags);
    444       1.6       mrg 	NETBSD32TO64_UAP(fd);
    445       1.6       mrg 	NETBSD32TOX_UAP(pos, long);
    446      1.24   thorpej 	return (compat_43_sys_mmap(l, &ua, retval));
    447       1.4       eeh }
    448       1.4       eeh 
    449       1.1       mrg /* network syscalls */
    450       1.1       mrg int
    451      1.24   thorpej compat_43_netbsd32_oaccept(l, v, retval)
    452      1.24   thorpej 	struct lwp* l;
    453       1.1       mrg 	void *v;
    454       1.1       mrg 	register_t *retval;
    455       1.1       mrg {
    456       1.8       eeh 	struct compat_43_netbsd32_oaccept_args /* {
    457       1.1       mrg 		syscallarg(int) s;
    458       1.5       mrg 		syscallarg(netbsd32_caddr_t) name;
    459       1.5       mrg 		syscallarg(netbsd32_intp) anamelen;
    460       1.1       mrg 	} */ *uap = v;
    461       1.1       mrg 	struct compat_43_sys_accept_args ua;
    462       1.1       mrg 
    463       1.6       mrg 	NETBSD32TOX_UAP(s, int);
    464  1.35.2.1     rmind 	NETBSD32TOX64_UAP(name, void *);
    465       1.6       mrg 	NETBSD32TOP_UAP(anamelen, int);
    466      1.24   thorpej 	return (compat_43_sys_accept(l, &ua, retval));
    467       1.1       mrg }
    468       1.1       mrg 
    469       1.1       mrg int
    470      1.24   thorpej compat_43_netbsd32_osend(l, v, retval)
    471      1.24   thorpej 	struct lwp* l;
    472       1.1       mrg 	void *v;
    473       1.1       mrg 	register_t *retval;
    474       1.1       mrg {
    475       1.8       eeh 	struct compat_43_netbsd32_osend_args /* {
    476       1.1       mrg 		syscallarg(int) s;
    477       1.5       mrg 		syscallarg(netbsd32_caddr_t) buf;
    478       1.1       mrg 		syscallarg(int) len;
    479       1.1       mrg 		syscallarg(int) flags;
    480       1.1       mrg 	} */ *uap = v;
    481       1.1       mrg 	struct compat_43_sys_send_args ua;
    482       1.1       mrg 
    483       1.6       mrg 	NETBSD32TO64_UAP(s);
    484  1.35.2.1     rmind 	NETBSD32TOX64_UAP(buf, void *);
    485       1.6       mrg 	NETBSD32TO64_UAP(len);
    486       1.6       mrg 	NETBSD32TO64_UAP(flags);
    487      1.24   thorpej 	return (compat_43_sys_send(l, &ua, retval));
    488       1.1       mrg }
    489       1.1       mrg 
    490       1.1       mrg int
    491      1.24   thorpej compat_43_netbsd32_orecv(l, v, retval)
    492      1.24   thorpej 	struct lwp* l;
    493       1.1       mrg 	void *v;
    494       1.1       mrg 	register_t *retval;
    495       1.1       mrg {
    496       1.8       eeh 	struct compat_43_netbsd32_orecv_args /* {
    497       1.1       mrg 		syscallarg(int) s;
    498       1.5       mrg 		syscallarg(netbsd32_caddr_t) buf;
    499       1.1       mrg 		syscallarg(int) len;
    500       1.1       mrg 		syscallarg(int) flags;
    501       1.1       mrg 	} */ *uap = v;
    502       1.1       mrg 	struct compat_43_sys_recv_args ua;
    503       1.1       mrg 
    504       1.6       mrg 	NETBSD32TO64_UAP(s);
    505  1.35.2.1     rmind 	NETBSD32TOX64_UAP(buf, void *);
    506       1.6       mrg 	NETBSD32TO64_UAP(len);
    507       1.6       mrg 	NETBSD32TO64_UAP(flags);
    508      1.24   thorpej 	return (compat_43_sys_recv(l, &ua, retval));
    509       1.1       mrg }
    510       1.1       mrg 
    511       1.1       mrg /*
    512       1.1       mrg  * XXX convert these to use a common iovec code to the native
    513       1.1       mrg  * netbsd call.
    514       1.1       mrg  */
    515       1.1       mrg int
    516      1.24   thorpej compat_43_netbsd32_orecvmsg(l, v, retval)
    517      1.24   thorpej 	struct lwp* l;
    518       1.1       mrg 	void *v;
    519       1.1       mrg 	register_t *retval;
    520       1.1       mrg {
    521      1.24   thorpej 	struct proc *p = l->l_proc;
    522       1.8       eeh 	struct compat_43_netbsd32_orecvmsg_args /* {
    523       1.1       mrg 		syscallarg(int) s;
    524       1.5       mrg 		syscallarg(netbsd32_omsghdrp_t) msg;
    525       1.1       mrg 		syscallarg(int) flags;
    526       1.1       mrg 	} */ *uap = v;
    527       1.1       mrg 	struct compat_43_sys_recvmsg_args ua;
    528      1.16       mrg 	struct omsghdr omh, *sgsbp;
    529      1.16       mrg 	struct netbsd32_omsghdr omh32;
    530      1.16       mrg 	struct iovec iov, *sgsbp2;
    531      1.16       mrg 	struct netbsd32_iovec iov32, *iovec32p;
    532  1.35.2.1     rmind 	void *sg = stackgap_init(p, 0);
    533      1.16       mrg 	int i, error, rv;
    534       1.1       mrg 
    535       1.6       mrg 	NETBSD32TO64_UAP(s);
    536       1.6       mrg 	NETBSD32TO64_UAP(flags);
    537       1.1       mrg 
    538      1.16       mrg 	/*
    539      1.16       mrg 	 * this is annoying:
    540      1.16       mrg 	 *	- copyin the msghdr32 struct
    541      1.16       mrg 	 *	- stackgap_alloc a msghdr struct
    542      1.16       mrg 	 *	- convert msghdr32 to msghdr:
    543      1.16       mrg 	 *		- stackgap_alloc enough space for iovec's
    544      1.16       mrg 	 *		- copy in each iov32, and convert to iov
    545      1.16       mrg 	 *		- copyout converted iov
    546      1.16       mrg 	 *	- copyout converted msghdr
    547      1.16       mrg 	 *	- do real syscall
    548      1.16       mrg 	 *	- copyin the msghdr struct
    549      1.16       mrg 	 *	- convert msghdr to msghdr32
    550      1.16       mrg 	 *		- copyin each iov and convert to iov32
    551      1.16       mrg 	 *		- copyout converted iov32
    552      1.16       mrg 	 *	- copyout converted msghdr32
    553      1.16       mrg 	 */
    554  1.35.2.1     rmind 	error = copyin((void *)NETBSD32PTR64(SCARG(uap, msg)), &omh32,
    555      1.23       scw 	    sizeof(omh32));
    556      1.16       mrg 	if (error)
    557      1.16       mrg 		return (error);
    558      1.16       mrg 
    559      1.21  christos 	SCARG(&ua, msg) = sgsbp = stackgap_alloc(p, &sg, sizeof(omh));
    560  1.35.2.1     rmind 	omh.msg_name = (void *)NETBSD32PTR64(omh32.msg_name);
    561      1.16       mrg 	omh.msg_namelen = omh32.msg_namelen;
    562      1.16       mrg 	omh.msg_iovlen = (size_t)omh32.msg_iovlen;
    563      1.21  christos 	omh.msg_iov = sgsbp2 = stackgap_alloc(p, &sg, sizeof(struct iovec) * omh.msg_iovlen);
    564      1.23       scw 	iovec32p = (struct netbsd32_iovec *)NETBSD32PTR64(omh32.msg_iov);
    565      1.16       mrg 	for (i = 0; i < omh.msg_iovlen; i++, sgsbp2++, iovec32p++) {
    566      1.16       mrg 		error = copyin(iovec32p, &iov32, sizeof(iov32));
    567      1.16       mrg 		if (error)
    568      1.16       mrg 			return (error);
    569      1.23       scw 		iov.iov_base =
    570      1.23       scw 		    (struct iovec *)NETBSD32PTR64(iovec32p->iov_base);
    571      1.16       mrg 		iov.iov_len = (size_t)iovec32p->iov_len;
    572      1.16       mrg 		error = copyout(&iov, sgsbp2, sizeof(iov));
    573      1.16       mrg 		if (error)
    574      1.16       mrg 			return (error);
    575       1.1       mrg 	}
    576  1.35.2.1     rmind 	omh.msg_accrights = (void *)NETBSD32PTR64(omh32.msg_accrights);
    577      1.16       mrg 	omh.msg_accrightslen = omh32.msg_accrightslen;
    578      1.16       mrg 	error = copyout(&omh, sgsbp, sizeof(omh));
    579      1.16       mrg 	if (error)
    580      1.16       mrg 		return (error);
    581       1.1       mrg 
    582      1.24   thorpej 	rv = compat_43_sys_recvmsg(l, &ua, retval);
    583       1.1       mrg 
    584      1.16       mrg 	error = copyin(sgsbp, &omh, sizeof(omh));
    585      1.16       mrg 	if (error)
    586      1.16       mrg 		return error;
    587      1.16       mrg 	omh32.msg_name = (netbsd32_caddr_t)(u_long)omh.msg_name;
    588      1.16       mrg 	omh32.msg_namelen = omh.msg_namelen;
    589      1.16       mrg 	omh32.msg_iovlen = (netbsd32_size_t)omh.msg_iovlen;
    590      1.23       scw 	iovec32p = (struct netbsd32_iovec *)NETBSD32PTR64(omh32.msg_iov);
    591      1.16       mrg 	sgsbp2 = omh.msg_iov;
    592      1.16       mrg 	for (i = 0; i < omh.msg_iovlen; i++, sgsbp2++, iovec32p++) {
    593      1.16       mrg 		error = copyin(sgsbp2, &iov, sizeof(iov));
    594      1.16       mrg 		if (error)
    595      1.16       mrg 			return (error);
    596      1.16       mrg 		iov32.iov_base = (netbsd32_iovecp_t)(u_long)iov.iov_base;
    597      1.16       mrg 		iov32.iov_len = (netbsd32_size_t)iov.iov_len;
    598      1.16       mrg 		error = copyout(&iov32, iovec32p, sizeof(iov32));
    599      1.16       mrg 		if (error)
    600      1.16       mrg 			return (error);
    601      1.16       mrg 	}
    602      1.16       mrg 	omh32.msg_accrights = (netbsd32_caddr_t)(u_long)omh.msg_accrights;
    603      1.16       mrg 	omh32.msg_accrightslen = omh.msg_accrightslen;
    604      1.16       mrg 
    605      1.23       scw 	error = copyout(&omh32, (char *)NETBSD32PTR64(SCARG(uap, msg)),
    606      1.23       scw 	    sizeof(omh32));
    607      1.16       mrg 	if (error)
    608      1.16       mrg 		return error;
    609      1.16       mrg 
    610      1.16       mrg 	return (rv);
    611       1.1       mrg }
    612       1.1       mrg 
    613       1.1       mrg int
    614      1.24   thorpej compat_43_netbsd32_osendmsg(l, v, retval)
    615      1.24   thorpej 	struct lwp* l;
    616       1.1       mrg 	void *v;
    617       1.1       mrg 	register_t *retval;
    618       1.1       mrg {
    619      1.24   thorpej 	struct proc *p = l->l_proc;
    620       1.8       eeh 	struct compat_43_netbsd32_osendmsg_args /* {
    621       1.1       mrg 		syscallarg(int) s;
    622       1.5       mrg 		syscallarg(netbsd32_caddr_t) msg;
    623       1.1       mrg 		syscallarg(int) flags;
    624       1.1       mrg 	} */ *uap = v;
    625      1.16       mrg 	struct compat_43_sys_recvmsg_args ua;
    626      1.16       mrg 	struct omsghdr omh, *sgsbp;
    627      1.16       mrg 	struct netbsd32_omsghdr omh32;
    628      1.16       mrg 	struct iovec iov, *sgsbp2;
    629      1.16       mrg 	struct netbsd32_iovec iov32, *iovec32p;
    630  1.35.2.1     rmind 	void *sg = stackgap_init(p, 0);
    631      1.16       mrg 	int i, error, rv;
    632       1.1       mrg 
    633       1.6       mrg 	NETBSD32TO64_UAP(s);
    634       1.6       mrg 	NETBSD32TO64_UAP(flags);
    635       1.1       mrg 
    636      1.16       mrg 	/*
    637      1.16       mrg 	 * this is annoying:
    638      1.16       mrg 	 *	- copyin the msghdr32 struct
    639      1.16       mrg 	 *	- stackgap_alloc a msghdr struct
    640      1.16       mrg 	 *	- convert msghdr32 to msghdr:
    641      1.16       mrg 	 *		- stackgap_alloc enough space for iovec's
    642      1.16       mrg 	 *		- copy in each iov32, and convert to iov
    643      1.16       mrg 	 *		- copyout converted iov
    644      1.16       mrg 	 *	- copyout converted msghdr
    645      1.16       mrg 	 *	- do real syscall
    646      1.16       mrg 	 *	- copyin the msghdr struct
    647      1.16       mrg 	 *	- convert msghdr to msghdr32
    648      1.16       mrg 	 *		- copyin each iov and convert to iov32
    649      1.16       mrg 	 *		- copyout converted iov32
    650      1.16       mrg 	 *	- copyout converted msghdr32
    651      1.16       mrg 	 */
    652  1.35.2.1     rmind 	error = copyin((void *)NETBSD32PTR64(SCARG(uap, msg)), &omh32,
    653      1.23       scw 	    sizeof(omh32));
    654      1.16       mrg 	if (error)
    655      1.16       mrg 		return (error);
    656      1.16       mrg 
    657      1.21  christos 	SCARG(&ua, msg) = sgsbp = stackgap_alloc(p, &sg, sizeof(omh));
    658  1.35.2.1     rmind 	omh.msg_name = (void *)NETBSD32PTR64(omh32.msg_name);
    659      1.16       mrg 	omh.msg_namelen = omh32.msg_namelen;
    660      1.16       mrg 	omh.msg_iovlen = (size_t)omh32.msg_iovlen;
    661      1.21  christos 	omh.msg_iov = sgsbp2 = stackgap_alloc(p, &sg, sizeof(struct iovec) * omh.msg_iovlen);
    662      1.23       scw 	iovec32p = (struct netbsd32_iovec *)NETBSD32PTR64(omh32.msg_iov);
    663      1.16       mrg 	for (i = 0; i < omh.msg_iovlen; i++, sgsbp2++, iovec32p++) {
    664      1.16       mrg 		error = copyin(iovec32p, &iov32, sizeof(iov32));
    665      1.16       mrg 		if (error)
    666      1.16       mrg 			return (error);
    667      1.23       scw 		iov.iov_base =
    668      1.23       scw 		    (struct iovec *)NETBSD32PTR64(iovec32p->iov_base);
    669      1.16       mrg 		iov.iov_len = (size_t)iovec32p->iov_len;
    670      1.16       mrg 		error = copyout(&iov, sgsbp2, sizeof(iov));
    671      1.16       mrg 		if (error)
    672      1.16       mrg 			return (error);
    673       1.1       mrg 	}
    674  1.35.2.1     rmind 	omh.msg_accrights = (void *)NETBSD32PTR64(omh32.msg_accrights);
    675      1.16       mrg 	omh.msg_accrightslen = omh32.msg_accrightslen;
    676      1.16       mrg 	error = copyout(&omh, sgsbp, sizeof(omh));
    677      1.16       mrg 	if (error)
    678      1.16       mrg 		return (error);
    679       1.1       mrg 
    680      1.24   thorpej 	rv = compat_43_sys_sendmsg(l, &ua, retval);
    681       1.1       mrg 
    682      1.16       mrg 	error = copyin(sgsbp, &omh, sizeof(omh));
    683      1.16       mrg 	if (error)
    684      1.16       mrg 		return error;
    685      1.16       mrg 	omh32.msg_name = (netbsd32_caddr_t)(u_long)omh.msg_name;
    686      1.16       mrg 	omh32.msg_namelen = omh.msg_namelen;
    687      1.16       mrg 	omh32.msg_iovlen = (netbsd32_size_t)omh.msg_iovlen;
    688      1.23       scw 	iovec32p = (struct netbsd32_iovec *)NETBSD32PTR64(omh32.msg_iov);
    689      1.16       mrg 	sgsbp2 = omh.msg_iov;
    690      1.16       mrg 	for (i = 0; i < omh.msg_iovlen; i++, sgsbp2++, iovec32p++) {
    691      1.16       mrg 		error = copyin(sgsbp2, &iov, sizeof(iov));
    692      1.16       mrg 		if (error)
    693      1.16       mrg 			return (error);
    694      1.16       mrg 		iov32.iov_base = (netbsd32_iovecp_t)(u_long)iov.iov_base;
    695      1.16       mrg 		iov32.iov_len = (netbsd32_size_t)iov.iov_len;
    696      1.16       mrg 		error = copyout(&iov32, iovec32p, sizeof(iov32));
    697      1.16       mrg 		if (error)
    698      1.16       mrg 			return (error);
    699      1.16       mrg 	}
    700      1.16       mrg 	omh32.msg_accrights = (netbsd32_caddr_t)(u_long)omh.msg_accrights;
    701      1.16       mrg 	omh32.msg_accrightslen = omh.msg_accrightslen;
    702      1.16       mrg 
    703      1.23       scw 	error = copyout(&omh32, (char *)NETBSD32PTR64(SCARG(uap, msg)),
    704      1.23       scw 	    sizeof(omh32));
    705      1.16       mrg 	if (error)
    706      1.16       mrg 		return error;
    707      1.16       mrg 
    708      1.16       mrg 	return (rv);
    709       1.1       mrg }
    710       1.1       mrg 
    711       1.1       mrg int
    712      1.24   thorpej compat_43_netbsd32_orecvfrom(l, v, retval)
    713      1.24   thorpej 	struct lwp* l;
    714       1.1       mrg 	void *v;
    715       1.1       mrg 	register_t *retval;
    716       1.1       mrg {
    717       1.8       eeh 	struct compat_43_netbsd32_orecvfrom_args /* {
    718       1.1       mrg 		syscallarg(int) s;
    719       1.5       mrg 		syscallarg(netbsd32_caddr_t) buf;
    720       1.5       mrg 		syscallarg(netbsd32_size_t) len;
    721       1.1       mrg 		syscallarg(int) flags;
    722       1.5       mrg 		syscallarg(netbsd32_caddr_t) from;
    723       1.5       mrg 		syscallarg(netbsd32_intp) fromlenaddr;
    724       1.1       mrg 	} */ *uap = v;
    725       1.1       mrg 	struct compat_43_sys_recvfrom_args ua;
    726       1.1       mrg 
    727       1.6       mrg 	NETBSD32TO64_UAP(s);
    728  1.35.2.1     rmind 	NETBSD32TOX64_UAP(buf, void *);
    729       1.6       mrg 	NETBSD32TOX_UAP(len, size_t);
    730       1.6       mrg 	NETBSD32TO64_UAP(flags);
    731  1.35.2.1     rmind 	NETBSD32TOX64_UAP(from, void *);
    732       1.6       mrg 	NETBSD32TOP_UAP(fromlenaddr, int);
    733      1.24   thorpej 	return (compat_43_sys_recvfrom(l, &ua, retval));
    734       1.1       mrg }
    735       1.1       mrg 
    736       1.1       mrg int
    737      1.24   thorpej compat_43_netbsd32_ogetsockname(l, v, retval)
    738      1.24   thorpej 	struct lwp* l;
    739       1.1       mrg 	void *v;
    740       1.1       mrg 	register_t *retval;
    741       1.1       mrg {
    742       1.8       eeh 	struct compat_43_netbsd32_ogetsockname_args /* {
    743       1.1       mrg 		syscallarg(int) fdec;
    744       1.5       mrg 		syscallarg(netbsd32_caddr_t) asa;
    745       1.5       mrg 		syscallarg(netbsd32_intp) alen;
    746       1.1       mrg 	} */ *uap = v;
    747       1.1       mrg 	struct compat_43_sys_getsockname_args ua;
    748       1.1       mrg 
    749       1.6       mrg 	NETBSD32TO64_UAP(fdec);
    750  1.35.2.1     rmind 	NETBSD32TOX64_UAP(asa, void *);
    751       1.6       mrg 	NETBSD32TOP_UAP(alen, int);
    752      1.24   thorpej 	return (compat_43_sys_getsockname(l, &ua, retval));
    753       1.1       mrg }
    754       1.1       mrg 
    755       1.1       mrg int
    756      1.24   thorpej compat_43_netbsd32_ogetpeername(l, v, retval)
    757      1.24   thorpej 	struct lwp* l;
    758       1.1       mrg 	void *v;
    759       1.1       mrg 	register_t *retval;
    760       1.1       mrg {
    761       1.8       eeh 	struct compat_43_netbsd32_ogetpeername_args /* {
    762       1.1       mrg 		syscallarg(int) fdes;
    763       1.5       mrg 		syscallarg(netbsd32_caddr_t) asa;
    764       1.5       mrg 		syscallarg(netbsd32_intp) alen;
    765       1.1       mrg 	} */ *uap = v;
    766       1.1       mrg 	struct compat_43_sys_getpeername_args ua;
    767       1.1       mrg 
    768       1.6       mrg 	NETBSD32TO64_UAP(fdes);
    769  1.35.2.1     rmind 	NETBSD32TOX64_UAP(asa, void *);
    770       1.6       mrg 	NETBSD32TOP_UAP(alen, int);
    771      1.24   thorpej 	return (compat_43_sys_getpeername(l, &ua, retval));
    772       1.1       mrg }
    773       1.1       mrg 
    774       1.1       mrg /* signal syscalls */
    775       1.1       mrg int
    776      1.24   thorpej compat_43_netbsd32_osigvec(l, v, retval)
    777      1.24   thorpej 	struct lwp* l;
    778       1.1       mrg 	void *v;
    779       1.1       mrg 	register_t *retval;
    780       1.1       mrg {
    781      1.24   thorpej 	struct proc *p = l->l_proc;
    782       1.8       eeh 	struct compat_43_netbsd32_osigvec_args /* {
    783       1.1       mrg 		syscallarg(int) signum;
    784       1.5       mrg 		syscallarg(netbsd32_sigvecp_t) nsv;
    785       1.5       mrg 		syscallarg(netbsd32_sigvecp_t) osv;
    786       1.1       mrg 	} */ *uap = v;
    787       1.1       mrg 	struct compat_43_sys_sigvec_args ua;
    788      1.16       mrg 	struct netbsd32_sigvec sv32;
    789      1.28  christos 	struct sigvec sv;
    790  1.35.2.1     rmind 	void *sg = stackgap_init(p, 0);
    791      1.16       mrg 	int rv, error;
    792       1.1       mrg 
    793       1.6       mrg 	NETBSD32TO64_UAP(signum);
    794       1.1       mrg 	if (SCARG(uap, osv))
    795      1.28  christos 		SCARG(&ua, osv) = stackgap_alloc(p, &sg, sizeof(sv));
    796       1.1       mrg 	else
    797       1.1       mrg 		SCARG(&ua, osv) = NULL;
    798       1.1       mrg 	if (SCARG(uap, nsv)) {
    799      1.28  christos 		SCARG(&ua, nsv) = stackgap_alloc(p, &sg, sizeof(sv));
    800  1.35.2.1     rmind 		error = copyin((void *)NETBSD32PTR64(SCARG(uap, nsv)), &sv32,
    801      1.23       scw 		    sizeof(sv32));
    802      1.16       mrg 		if (error)
    803      1.16       mrg 			return (error);
    804      1.23       scw 		sv.sv_handler = (void *)NETBSD32PTR64(sv32.sv_handler);
    805      1.16       mrg 		sv.sv_mask = sv32.sv_mask;
    806      1.16       mrg 		sv.sv_flags = sv32.sv_flags;
    807      1.28  christos 		error = copyout(&sv, SCARG(&ua, nsv), sizeof(sv));
    808      1.16       mrg 		if (error)
    809      1.16       mrg 			return (error);
    810       1.1       mrg 	} else
    811       1.1       mrg 		SCARG(&ua, nsv) = NULL;
    812      1.24   thorpej 	rv = compat_43_sys_sigvec(l, &ua, retval);
    813       1.1       mrg 	if (rv)
    814       1.1       mrg 		return (rv);
    815       1.1       mrg 
    816       1.1       mrg 	if (SCARG(uap, osv)) {
    817      1.28  christos 		error = copyin(SCARG(&ua, osv), &sv, sizeof(sv));
    818      1.16       mrg 		if (error)
    819      1.16       mrg 			return (error);
    820      1.16       mrg 		sv32.sv_handler = (netbsd32_sigvecp_t)(u_long)sv.sv_handler;
    821      1.16       mrg 		sv32.sv_mask = sv.sv_mask;
    822      1.16       mrg 		sv32.sv_flags = sv.sv_flags;
    823  1.35.2.1     rmind 		error = copyout(&sv32, (void *)NETBSD32PTR64(SCARG(uap, osv)),
    824      1.23       scw 		    sizeof(sv32));
    825      1.16       mrg 		if (error)
    826      1.16       mrg 			return (error);
    827       1.1       mrg 	}
    828       1.1       mrg 
    829       1.1       mrg 	return (0);
    830       1.4       eeh }
    831       1.4       eeh 
    832       1.4       eeh int
    833      1.24   thorpej compat_43_netbsd32_sigblock(l, v, retval)
    834      1.24   thorpej 	struct lwp* l;
    835       1.4       eeh 	void *v;
    836       1.4       eeh 	register_t *retval;
    837       1.4       eeh {
    838       1.8       eeh 	struct compat_43_netbsd32_sigblock_args /* {
    839       1.4       eeh 		syscallarg(int) mask;
    840       1.4       eeh 	} */ *uap = v;
    841       1.4       eeh 	struct compat_43_sys_sigblock_args ua;
    842       1.4       eeh 
    843       1.6       mrg 	NETBSD32TO64_UAP(mask);
    844      1.24   thorpej 	return (compat_43_sys_sigblock(l, &ua, retval));
    845       1.4       eeh }
    846       1.4       eeh 
    847       1.4       eeh int
    848      1.24   thorpej compat_43_netbsd32_sigsetmask(l, v, retval)
    849      1.24   thorpej 	struct lwp* l;
    850       1.4       eeh 	void *v;
    851       1.4       eeh 	register_t *retval;
    852       1.4       eeh {
    853       1.8       eeh 	struct compat_43_netbsd32_sigsetmask_args /* {
    854       1.4       eeh 		syscallarg(int) mask;
    855       1.4       eeh 	} */ *uap = v;
    856       1.4       eeh 	struct compat_43_sys_sigsetmask_args ua;
    857       1.4       eeh 
    858       1.6       mrg 	NETBSD32TO64_UAP(mask);
    859      1.24   thorpej 	return (compat_43_sys_sigsetmask(l, &ua, retval));
    860       1.1       mrg }
    861       1.1       mrg 
    862       1.1       mrg int
    863      1.24   thorpej compat_43_netbsd32_osigstack(l, v, retval)
    864      1.24   thorpej 	struct lwp* l;
    865       1.1       mrg 	void *v;
    866       1.1       mrg 	register_t *retval;
    867       1.1       mrg {
    868      1.24   thorpej 	struct proc *p = l->l_proc;
    869       1.8       eeh 	struct compat_43_netbsd32_osigstack_args /* {
    870       1.5       mrg 		syscallarg(netbsd32_sigstackp_t) nss;
    871       1.5       mrg 		syscallarg(netbsd32_sigstackp_t) oss;
    872       1.1       mrg 	} */ *uap = v;
    873       1.1       mrg 	struct compat_43_sys_sigstack_args ua;
    874      1.16       mrg 	struct netbsd32_sigstack ss32;
    875      1.28  christos 	struct sigstack ss;
    876  1.35.2.1     rmind 	void *sg = stackgap_init(p, 0);
    877      1.16       mrg 	int error, rv;
    878       1.1       mrg 
    879       1.1       mrg 	if (SCARG(uap, oss))
    880      1.28  christos 		SCARG(&ua, oss) = stackgap_alloc(p, &sg, sizeof(ss));
    881       1.1       mrg 	else
    882       1.1       mrg 		SCARG(&ua, oss) = NULL;
    883       1.1       mrg 	if (SCARG(uap, nss)) {
    884      1.28  christos 		SCARG(&ua, nss) = stackgap_alloc(p, &sg, sizeof(ss));
    885  1.35.2.1     rmind 		error = copyin((void *)NETBSD32PTR64(SCARG(uap, nss)), &ss32,
    886      1.23       scw 		    sizeof(ss32));
    887      1.16       mrg 		if (error)
    888      1.16       mrg 			return (error);
    889      1.23       scw 		ss.ss_sp = (void *)NETBSD32PTR64(ss32.ss_sp);
    890      1.16       mrg 		ss.ss_onstack = ss32.ss_onstack;
    891      1.28  christos 		error = copyout(&ss, SCARG(&ua, nss), sizeof(ss));
    892      1.16       mrg 		if (error)
    893      1.16       mrg 			return (error);
    894       1.1       mrg 	} else
    895       1.1       mrg 		SCARG(&ua, nss) = NULL;
    896       1.1       mrg 
    897      1.24   thorpej 	rv = compat_43_sys_sigstack(l, &ua, retval);
    898       1.1       mrg 	if (rv)
    899       1.1       mrg 		return (rv);
    900       1.1       mrg 
    901       1.1       mrg 	if (SCARG(uap, oss)) {
    902      1.28  christos 		error = copyin(SCARG(&ua, oss), &ss, sizeof(ss));
    903      1.16       mrg 		if (error)
    904      1.16       mrg 			return (error);
    905      1.16       mrg 		ss32.ss_sp = (netbsd32_sigstackp_t)(u_long)ss.ss_sp;
    906      1.16       mrg 		ss32.ss_onstack = ss.ss_onstack;
    907  1.35.2.1     rmind 		error = copyout(&ss32, (void *)NETBSD32PTR64(SCARG(uap, oss)),
    908      1.23       scw 		    sizeof(ss32));
    909      1.16       mrg 		if (error)
    910      1.16       mrg 			return (error);
    911       1.1       mrg 	}
    912       1.1       mrg 
    913       1.1       mrg 	return (0);
    914       1.1       mrg }
    915