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