Home | History | Annotate | Line # | Download | only in netbsd32
netbsd32.h revision 1.118.2.3
      1 /*	$NetBSD: netbsd32.h,v 1.118.2.3 2020/04/13 08:04:16 martin Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1998, 2001, 2008, 2015 Matthew R. Green
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  * SUCH DAMAGE.
     27  */
     28 
     29 #ifndef _COMPAT_NETBSD32_NETBSD32_H_
     30 #define _COMPAT_NETBSD32_NETBSD32_H_
     31 /* We need to change the size of register_t */
     32 #ifdef syscallargs
     33 #undef syscallargs
     34 #endif
     35 /*
     36  * NetBSD 32-bit compatibility module.
     37  */
     38 
     39 #include <sys/param.h> /* precautionary upon removal from ucred.h */
     40 #include <sys/systm.h>
     41 #include <sys/mount.h>
     42 #include <sys/ptrace.h>
     43 #include <sys/stat.h>
     44 #include <sys/statvfs.h>
     45 #include <sys/syscallargs.h>
     46 #include <sys/ipc.h>
     47 #include <sys/shm.h>
     48 #include <sys/ucontext.h>
     49 #include <sys/ucred.h>
     50 #include <sys/module_hook.h>
     51 
     52 #include <compat/sys/ucontext.h>
     53 #include <compat/sys/mount.h>
     54 #include <compat/sys/signal.h>
     55 #include <compat/sys/siginfo.h>
     56 #include <compat/common/compat_util.h>
     57 
     58 #include <nfs/rpcv2.h>
     59 
     60 /*
     61  * first, define the basic types we need.
     62  */
     63 
     64 typedef int32_t netbsd32_long;
     65 typedef uint32_t netbsd32_u_long;
     66 typedef int64_t netbsd32_quad;
     67 
     68 typedef uint32_t netbsd32_clock_t;
     69 typedef uint32_t netbsd32_size_t;
     70 typedef int32_t netbsd32_ssize_t;
     71 typedef int32_t netbsd32_clockid_t;
     72 typedef int32_t netbsd32_key_t;
     73 typedef int32_t netbsd32_intptr_t;
     74 typedef uint32_t netbsd32_uintptr_t;
     75 
     76 /* netbsd32_[u]int64 are machine dependent and defined below */
     77 
     78 /*
     79  * machine dependant section; must define:
     80  *	NETBSD32_POINTER_TYPE
     81  *		- 32-bit pointer type, normally uint32_t but can be int32_t
     82  *		  for platforms which rely on sign-extension of pointers
     83  *		  such as SH-5.
     84  *                eg:	#define NETBSD32_POINTER_TYPE uint32_t
     85  *	netbsd32_pointer_t
     86  *		- a typedef'd struct with the above as an "i32" member.
     87  *                eg:	typedef struct {
     88  *				NETBSD32_POINTER_TYPE i32;
     89  *			} netbsd32_pointer_t;
     90  *	NETBSD32PTR64(p32)
     91  *		- Translate a 32-bit pointer into something valid in a
     92  *		  64-bit context.
     93  *	struct netbsd32_sigcontext
     94  *		- 32bit compatibility sigcontext structure for this arch.
     95  *	netbsd32_sigcontextp_t
     96  *		- type of pointer to above, normally uint32_t
     97  *	void netbsd32_setregs(struct proc *p, struct exec_package *pack,
     98  *	    unsigned long stack);
     99  *	int netbsd32_sigreturn(struct proc *p, void *v,
    100  *	    register_t *retval);
    101  *	void netbsd32_sendsig(sig_t catcher, int sig, int mask, u_long code);
    102  *	char netbsd32_esigcode[], netbsd32_sigcode[]
    103  *		- the above are abvious
    104  *
    105  * pull in the netbsd32 machine dependent header, that may help with the
    106  * above, or it may be provided via the MD layer itself.
    107  */
    108 #include <machine/netbsd32_machdep.h>
    109 
    110 /*
    111  * Conversion functions for the rest of the compat32 code:
    112  *
    113  * NETBSD32PTR64()	Convert user-supplied 32bit pointer to 'void *'
    114  * NETBSD32PTR32()	Assign a 'void *' to a 32bit pointer variable
    115  * NETBSD32PTR32PLUS()	Add an integer to a 32bit pointer
    116  *
    117  * Under rare circumstances the following get used:
    118  *
    119  * NETBSD32PTR32I()	Convert 'void *' to the 32bit pointer base type.
    120  * NETBSD32IPTR64()	Convert 32bit pointer base type to 'void *'
    121  */
    122 #define	NETBSD32PTR64(p32)		NETBSD32IPTR64((p32).i32)
    123 #define	NETBSD32PTR32(p32, p64)		((p32).i32 = NETBSD32PTR32I(p64))
    124 #define	NETBSD32PTR32PLUS(p32, incr)	netbsd32_ptr32_incr(&p32, incr)
    125 #define	NETBSD32PTR32I(p32)		netbsd32_ptr32i(p32)
    126 #define	NETBSD32IPTR64(p32)		netbsd32_iptr64(p32)
    127 
    128 static __inline NETBSD32_POINTER_TYPE
    129 netbsd32_ptr32i(const void *p64)
    130 {
    131 	uintptr_t u64 = (uintptr_t)p64;
    132 	KASSERTMSG(u64 == (uintptr_t)(NETBSD32_POINTER_TYPE)u64,
    133 	    "u64 %jx != %jx", (uintmax_t)u64,
    134 	   (uintmax_t)(NETBSD32_POINTER_TYPE)u64);
    135 	return u64;
    136 }
    137 
    138 static __inline void *
    139 netbsd32_iptr64(NETBSD32_POINTER_TYPE p32)
    140 {
    141 	return (void *)(intptr_t)p32;
    142 }
    143 
    144 static __inline netbsd32_pointer_t
    145 netbsd32_ptr32_incr(netbsd32_pointer_t *p32, uint32_t incr)
    146 {
    147 	netbsd32_pointer_t n32 = *p32;
    148 
    149 	n32.i32 += incr;
    150 	KASSERT(NETBSD32PTR64(n32) > NETBSD32PTR64(*p32));
    151 	return *p32 = n32;
    152 }
    153 
    154 /* Nothing should be using the raw type, so kill it */
    155 #undef NETBSD32_POINTER_TYPE
    156 
    157 /*
    158  * 64 bit integers only have 4-byte alignment on some 32 bit ports,
    159  * but always have 8-byte alignment on 64 bit systems.
    160  * NETBSD32_INT64_ALIGN may be __attribute__((__aligned__(4)))
    161  */
    162 typedef int64_t netbsd32_int64 NETBSD32_INT64_ALIGN;
    163 typedef uint64_t netbsd32_uint64 NETBSD32_INT64_ALIGN;
    164 #undef NETBSD32_INT64_ALIGN
    165 
    166 /* Type used in siginfo, avoids circular dependencies between headers. */
    167 CTASSERT(sizeof(netbsd32_uint64) == sizeof(netbsd32_siginfo_uint64));
    168 CTASSERT(__alignof__(netbsd32_uint64) == __alignof__(netbsd32_siginfo_uint64));
    169 
    170 /*
    171  * all pointers are netbsd32_pointer_t (defined in <machine/netbsd32_machdep.h>)
    172  */
    173 
    174 typedef netbsd32_pointer_t netbsd32_voidp;
    175 typedef netbsd32_pointer_t netbsd32_u_shortp;
    176 typedef netbsd32_pointer_t netbsd32_charp;
    177 typedef netbsd32_pointer_t netbsd32_u_charp;
    178 typedef netbsd32_pointer_t netbsd32_charpp;
    179 typedef netbsd32_pointer_t netbsd32_size_tp;
    180 typedef netbsd32_pointer_t netbsd32_intp;
    181 typedef netbsd32_pointer_t netbsd32_uintp;
    182 typedef netbsd32_pointer_t netbsd32_longp;
    183 typedef netbsd32_pointer_t netbsd32_caddrp;
    184 typedef netbsd32_pointer_t netbsd32_caddr;
    185 typedef netbsd32_pointer_t netbsd32_gid_tp;
    186 typedef netbsd32_pointer_t netbsd32_fsid_tp_t;
    187 typedef netbsd32_pointer_t netbsd32_lwpidp;
    188 typedef netbsd32_pointer_t netbsd32_ucontextp;
    189 typedef netbsd32_pointer_t netbsd32_caddr_t;
    190 typedef netbsd32_pointer_t netbsd32_lwpctlp;
    191 typedef netbsd32_pointer_t netbsd32_pid_tp;
    192 typedef netbsd32_pointer_t netbsd32_psetidp_t;
    193 
    194 /*
    195  * now, the compatibility structures and their fake pointer types.
    196  */
    197 
    198 /* from <sys/types.h> */
    199 typedef netbsd32_pointer_t netbsd32_fd_setp_t;
    200 typedef netbsd32_intptr_t netbsd32_semid_t;
    201 typedef netbsd32_pointer_t netbsd32_semidp_t;
    202 typedef netbsd32_uint64 netbsd32_dev_t;
    203 typedef netbsd32_int64 netbsd32_off_t;
    204 typedef netbsd32_uint64 netbsd32_ino_t;
    205 
    206 /* from <sys/spawn.h> */
    207 typedef netbsd32_pointer_t netbsd32_posix_spawn_file_actionsp;
    208 typedef netbsd32_pointer_t netbsd32_posix_spawnattrp;
    209 typedef netbsd32_pointer_t netbsd32_posix_spawn_file_actions_entryp;
    210 
    211 /* from <sys/uio.h> */
    212 typedef netbsd32_pointer_t netbsd32_iovecp_t;
    213 struct netbsd32_iovec {
    214 	netbsd32_voidp	 iov_base;	/* Base address. */
    215 	netbsd32_size_t	 iov_len;	/* Length. */
    216 };
    217 
    218 /* from <sys/time.h> */
    219 typedef int32_t netbsd32_timer_t;
    220 typedef	int32_t netbsd32_time50_t;
    221 typedef	netbsd32_int64 netbsd32_time_t;
    222 typedef netbsd32_pointer_t netbsd32_timerp_t;
    223 typedef netbsd32_pointer_t netbsd32_clockidp_t;
    224 
    225 typedef netbsd32_pointer_t netbsd32_timespec50p_t;
    226 struct netbsd32_timespec50 {
    227 	netbsd32_time50_t tv_sec;			/* seconds */
    228 	netbsd32_long	tv_nsec;	/* and nanoseconds */
    229 };
    230 
    231 typedef netbsd32_pointer_t netbsd32_timespecp_t;
    232 struct netbsd32_timespec {
    233 	netbsd32_time_t tv_sec;			/* seconds */
    234 	netbsd32_long	tv_nsec;	/* and nanoseconds */
    235 };
    236 
    237 typedef netbsd32_pointer_t netbsd32_timeval50p_t;
    238 struct netbsd32_timeval50 {
    239 	netbsd32_time50_t	tv_sec;		/* seconds */
    240 	netbsd32_long		tv_usec;	/* and microseconds */
    241 };
    242 
    243 typedef netbsd32_pointer_t netbsd32_timevalp_t;
    244 struct netbsd32_timeval {
    245 	netbsd32_time_t	tv_sec;		/* seconds */
    246 	suseconds_t	tv_usec;	/* and microseconds */
    247 };
    248 
    249 typedef netbsd32_pointer_t netbsd32_timezonep_t;
    250 struct netbsd32_timezone {
    251 	int	tz_minuteswest;	/* minutes west of Greenwich */
    252 	int	tz_dsttime;	/* type of dst correction */
    253 };
    254 
    255 typedef netbsd32_pointer_t netbsd32_itimerval50p_t;
    256 struct	netbsd32_itimerval50 {
    257 	struct	netbsd32_timeval50 it_interval;	/* timer interval */
    258 	struct	netbsd32_timeval50 it_value;	/* current value */
    259 };
    260 
    261 typedef netbsd32_pointer_t netbsd32_itimervalp_t;
    262 struct	netbsd32_itimerval {
    263 	struct	netbsd32_timeval it_interval;	/* timer interval */
    264 	struct	netbsd32_timeval it_value;	/* current value */
    265 };
    266 
    267 typedef netbsd32_pointer_t netbsd32_itimerspec50p_t;
    268 struct netbsd32_itimerspec50 {
    269 	struct netbsd32_timespec50 it_interval;
    270 	struct netbsd32_timespec50 it_value;
    271 };
    272 
    273 typedef netbsd32_pointer_t netbsd32_itimerspecp_t;
    274 struct netbsd32_itimerspec {
    275 	struct netbsd32_timespec it_interval;
    276 	struct netbsd32_timespec it_value;
    277 };
    278 
    279 /* from <sys/mount.h> */
    280 typedef netbsd32_pointer_t netbsd32_fidp_t;
    281 
    282 typedef netbsd32_pointer_t netbsd32_fhandlep_t;
    283 typedef netbsd32_pointer_t netbsd32_compat_30_fhandlep_t;
    284 
    285 typedef netbsd32_pointer_t netbsd32_statfsp_t;
    286 struct netbsd32_statfs {
    287 	short	f_type;			/* type of file system */
    288 	unsigned short	f_flags;	/* copy of mount flags */
    289 	netbsd32_long	f_bsize;	/* fundamental file system block size */
    290 	netbsd32_long	f_iosize;	/* optimal transfer block size */
    291 	netbsd32_long	f_blocks;	/* total data blocks in file system */
    292 	netbsd32_long	f_bfree;	/* free blocks in fs */
    293 	netbsd32_long	f_bavail;	/* free blocks avail to non-superuser */
    294 	netbsd32_long	f_files;	/* total file nodes in file system */
    295 	netbsd32_long	f_ffree;	/* free file nodes in fs */
    296 	fsid_t	f_fsid;			/* file system id */
    297 	uid_t	f_owner;		/* user that mounted the file system */
    298 	netbsd32_long	f_spare[4];	/* spare for later */
    299 	char	f_fstypename[MFSNAMELEN]; /* fs type name */
    300 	char	f_mntonname[MNAMELEN];	  /* directory on which mounted */
    301 	char	f_mntfromname[MNAMELEN];  /* mounted file system */
    302 };
    303 
    304 struct netbsd32_export_args30 {
    305 	int	ex_flags;		/* export related flags */
    306 	uid_t	ex_root;		/* mapping for root uid */
    307 	struct	uucred ex_anon;		/* mapping for anonymous user */
    308 	netbsd32_pointer_t ex_addr;	/* net address to which exported */
    309 	int	ex_addrlen;		/* and the net address length */
    310 	netbsd32_pointer_t ex_mask;	/* mask of valid bits in saddr */
    311 	int	ex_masklen;		/* and the smask length */
    312 	netbsd32_charp ex_indexfile;	/* index file for WebNFS URLs */
    313 };
    314 
    315 /* from <sys/poll.h> */
    316 typedef netbsd32_pointer_t netbsd32_pollfdp_t;
    317 
    318 /* from <sys/ptrace.h> */
    319 typedef netbsd32_pointer_t netbsd32_ptrace_io_descp_t;
    320 struct netbsd32_ptrace_io_desc {
    321 	int	piod_op;		/* I/O operation */
    322 	netbsd32_voidp piod_offs;	/* child offset */
    323 	netbsd32_voidp piod_addr;	/* parent offset */
    324 	netbsd32_size_t piod_len;	/* request length (in) /
    325 					   actual count (out) */
    326 };
    327 
    328 struct netbsd32_ptrace_siginfo {
    329 	siginfo32_t	psi_siginfo;	/* signal information structure */
    330 	lwpid_t		psi_lwpid;	/* destination LWP of the signal
    331 					 * value 0 means the whole process
    332 					 * (route signal to all LWPs) */
    333 };
    334 
    335 #define PL32_LNAMELEN 20
    336 
    337 struct netbsd32_ptrace_lwpstatus {
    338 	lwpid_t		pl_lwpid;
    339 	sigset_t	pl_sigpend;
    340 	sigset_t	pl_sigmask;
    341 	char		pl_name[PL32_LNAMELEN];
    342 	netbsd32_voidp	pl_private;
    343 };
    344 
    345 /* from <sys/quotactl.h> */
    346 typedef netbsd32_pointer_t netbsd32_quotactlargsp_t;
    347 struct netbsd32_quotactlargs {
    348 	unsigned qc_op;
    349 	union {
    350 		struct {
    351 			netbsd32_pointer_t qc_info;
    352 		} stat;
    353 		struct {
    354 			int qc_idtype;
    355 			netbsd32_pointer_t qc_info;
    356 		} idtypestat;
    357 		struct {
    358 			int qc_objtype;
    359 			netbsd32_pointer_t qc_info;
    360 		} objtypestat;
    361 		struct {
    362 			netbsd32_pointer_t qc_key;
    363 			netbsd32_pointer_t qc_val;
    364 		} get;
    365 		struct {
    366 			netbsd32_pointer_t qc_key;
    367 			netbsd32_pointer_t qc_val;
    368 		} put;
    369 		struct {
    370 			netbsd32_pointer_t qc_key;
    371 		} del;
    372 		struct {
    373 			netbsd32_pointer_t qc_cursor;
    374 		} cursoropen;
    375 		struct {
    376 			netbsd32_pointer_t qc_cursor;
    377 		} cursorclose;
    378 		struct {
    379 			netbsd32_pointer_t qc_cursor;
    380 			int qc_idtype;
    381 		} cursorskipidtype;
    382 		struct {
    383 			netbsd32_pointer_t qc_cursor;
    384 			netbsd32_pointer_t qc_keys;
    385 			netbsd32_pointer_t qc_vals;
    386 			unsigned qc_maxnum;
    387 			netbsd32_pointer_t qc_ret;
    388 		} cursorget;
    389 		struct {
    390 			netbsd32_pointer_t qc_cursor;
    391 			netbsd32_pointer_t qc_ret;
    392 		} cursoratend;
    393 		struct {
    394 			netbsd32_pointer_t qc_cursor;
    395 		} cursorrewind;
    396 		struct {
    397 			int qc_idtype;
    398 			netbsd32_pointer_t qc_quotafile;
    399 		} quotaon;
    400 		struct {
    401 			int qc_idtype;
    402 		} quotaoff;
    403 	} u;
    404 };
    405 
    406 /* from <sys/resource.h> */
    407 typedef netbsd32_pointer_t netbsd32_rusage50p_t;
    408 struct	netbsd32_rusage50 {
    409 	struct netbsd32_timeval50 ru_utime;/* user time used */
    410 	struct netbsd32_timeval50 ru_stime;/* system time used */
    411 	netbsd32_long	ru_maxrss;	/* max resident set size */
    412 	netbsd32_long	ru_ixrss;	/* integral shared memory size */
    413 	netbsd32_long	ru_idrss;	/* integral unshared data " */
    414 	netbsd32_long	ru_isrss;	/* integral unshared stack " */
    415 	netbsd32_long	ru_minflt;	/* page reclaims */
    416 	netbsd32_long	ru_majflt;	/* page faults */
    417 	netbsd32_long	ru_nswap;	/* swaps */
    418 	netbsd32_long	ru_inblock;	/* block input operations */
    419 	netbsd32_long	ru_oublock;	/* block output operations */
    420 	netbsd32_long	ru_msgsnd;	/* messages sent */
    421 	netbsd32_long	ru_msgrcv;	/* messages received */
    422 	netbsd32_long	ru_nsignals;	/* signals received */
    423 	netbsd32_long	ru_nvcsw;	/* voluntary context switches */
    424 	netbsd32_long	ru_nivcsw;	/* involuntary " */
    425 };
    426 
    427 typedef netbsd32_pointer_t netbsd32_rusagep_t;
    428 struct	netbsd32_rusage {
    429 	struct netbsd32_timeval ru_utime;/* user time used */
    430 	struct netbsd32_timeval ru_stime;/* system time used */
    431 	netbsd32_long	ru_maxrss;	/* max resident set size */
    432 	netbsd32_long	ru_ixrss;	/* integral shared memory size */
    433 	netbsd32_long	ru_idrss;	/* integral unshared data " */
    434 	netbsd32_long	ru_isrss;	/* integral unshared stack " */
    435 	netbsd32_long	ru_minflt;	/* page reclaims */
    436 	netbsd32_long	ru_majflt;	/* page faults */
    437 	netbsd32_long	ru_nswap;	/* swaps */
    438 	netbsd32_long	ru_inblock;	/* block input operations */
    439 	netbsd32_long	ru_oublock;	/* block output operations */
    440 	netbsd32_long	ru_msgsnd;	/* messages sent */
    441 	netbsd32_long	ru_msgrcv;	/* messages received */
    442 	netbsd32_long	ru_nsignals;	/* signals received */
    443 	netbsd32_long	ru_nvcsw;	/* voluntary context switches */
    444 	netbsd32_long	ru_nivcsw;	/* involuntary " */
    445 };
    446 
    447 typedef netbsd32_pointer_t netbsd32_wrusagep_t;
    448 struct netbsd32_wrusage {
    449 	struct netbsd32_rusage	wru_self;
    450 	struct netbsd32_rusage	wru_children;
    451 };
    452 
    453 typedef netbsd32_pointer_t netbsd32_orlimitp_t;
    454 
    455 typedef netbsd32_pointer_t netbsd32_rlimitp_t;
    456 
    457 struct netbsd32_loadavg {
    458 	fixpt_t	ldavg[3];
    459 	netbsd32_long	fscale;
    460 };
    461 
    462 /* from <sys/swap.h> */
    463 struct netbsd32_swapent {
    464 	netbsd32_dev_t	se_dev;		/* device id */
    465 	int	se_flags;		/* flags */
    466 	int	se_nblks;		/* total blocks */
    467 	int	se_inuse;		/* blocks in use */
    468 	int	se_priority;		/* priority of this device */
    469 	char	se_path[PATH_MAX+1];	/* path	name */
    470 };
    471 
    472 /* from <sys/ipc.h> */
    473 typedef netbsd32_pointer_t netbsd32_ipc_permp_t;
    474 struct netbsd32_ipc_perm {
    475 	uid_t		cuid;	/* creator user id */
    476 	gid_t		cgid;	/* creator group id */
    477 	uid_t		uid;	/* user id */
    478 	gid_t		gid;	/* group id */
    479 	mode_t		mode;	/* r/w permission */
    480 	unsigned short	_seq;	/* sequence # (to generate unique msg/sem/shm id) */
    481 	netbsd32_key_t	_key;	/* user specified msg/sem/shm key */
    482 };
    483 struct netbsd32_ipc_perm14 {
    484 	unsigned short	cuid;	/* creator user id */
    485 	unsigned short	cgid;	/* creator group id */
    486 	unsigned short	uid;	/* user id */
    487 	unsigned short	gid;	/* group id */
    488 	unsigned short	mode;	/* r/w permission */
    489 	unsigned short	seq;	/* sequence # (to generate unique msg/sem/shm id) */
    490 	netbsd32_key_t	key;	/* user specified msg/sem/shm key */
    491 };
    492 
    493 /* from <sys/msg.h> */
    494 typedef netbsd32_pointer_t netbsd32_msgp_t;
    495 struct netbsd32_msg {
    496 	netbsd32_msgp_t msg_next;	/* next msg in the chain */
    497 	netbsd32_long	msg_type;	/* type of this message */
    498     					/* >0 -> type of this message */
    499     					/* 0 -> free header */
    500 	unsigned short	msg_ts;		/* size of this message */
    501 	short	msg_spot;		/* location of start of msg in buffer */
    502 };
    503 
    504 typedef uint32_t netbsd32_msgqnum_t;
    505 typedef netbsd32_size_t netbsd32_msglen_t;
    506 
    507 typedef netbsd32_pointer_t netbsd32_msqid_dsp_t;
    508 struct netbsd32_msqid_ds {
    509 	struct netbsd32_ipc_perm msg_perm;	/* operation permission strucure */
    510 	netbsd32_msgqnum_t	msg_qnum;	/* number of messages in the queue */
    511 	netbsd32_msglen_t	msg_qbytes;	/* max # of bytes in the queue */
    512 	pid_t		msg_lspid;	/* process ID of last msgsend() */
    513 	pid_t		msg_lrpid;	/* process ID of last msgrcv() */
    514 	netbsd32_time_t		msg_stime;	/* time of last msgsend() */
    515 	netbsd32_time_t		msg_rtime;	/* time of last msgrcv() */
    516 	netbsd32_time_t		msg_ctime;	/* time of last change */
    517 
    518 	/*
    519 	 * These members are private and used only in the internal
    520 	 * implementation of this interface.
    521 	 */
    522 	netbsd32_msgp_t _msg_first;	/* first message in the queue */
    523 	netbsd32_msgp_t	_msg_last;	/* last message in the queue */
    524 	netbsd32_msglen_t _msg_cbytes;	/* # of bytes currently in queue */
    525 };
    526 typedef netbsd32_pointer_t netbsd32_msqid_ds50p_t;
    527 struct netbsd32_msqid_ds50 {
    528 	struct netbsd32_ipc_perm msg_perm;	/* operation permission strucure */
    529 	netbsd32_msgqnum_t	msg_qnum;	/* number of messages in the queue */
    530 	netbsd32_msglen_t	msg_qbytes;	/* max # of bytes in the queue */
    531 	pid_t		msg_lspid;	/* process ID of last msgsend() */
    532 	pid_t		msg_lrpid;	/* process ID of last msgrcv() */
    533 	int32_t		msg_stime;	/* time of last msgsend() */
    534 	int32_t		msg_rtime;	/* time of last msgrcv() */
    535 	int32_t		msg_ctime;	/* time of last change */
    536 
    537 	/*
    538 	 * These members are private and used only in the internal
    539 	 * implementation of this interface.
    540 	 */
    541 	netbsd32_msgp_t _msg_first;	/* first message in the queue */
    542 	netbsd32_msgp_t	_msg_last;	/* last message in the queue */
    543 	netbsd32_msglen_t _msg_cbytes;	/* # of bytes currently in queue */
    544 };
    545 
    546 typedef netbsd32_pointer_t netbsd32_msqid_ds14p_t;
    547 struct netbsd32_msqid_ds14 {
    548 	struct	netbsd32_ipc_perm14 msg_perm;	/* msg queue permission bits */
    549 	netbsd32_msgp_t	msg_first;	/* first message in the queue */
    550 	netbsd32_msgp_t	msg_last;	/* last message in the queue */
    551 	netbsd32_u_long	msg_cbytes;	/* number of bytes in use on the queue */
    552 	netbsd32_u_long	msg_qnum;	/* number of msgs in the queue */
    553 	netbsd32_u_long	msg_qbytes;	/* max # of bytes on the queue */
    554 	pid_t msg_lspid;		/* pid of last msgsnd() */
    555 	pid_t msg_lrpid;		/* pid of last msgrcv() */
    556 	int32_t		msg_stime;	/* time of last msgsnd() */
    557 	netbsd32_long	msg_pad1;
    558 	int32_t		msg_rtime;	/* time of last msgrcv() */
    559 	netbsd32_long	msg_pad2;
    560 	int32_t		msg_ctime;	/* time of last msgctl() */
    561 	netbsd32_long	msg_pad3;
    562 	netbsd32_long	msg_pad4[4];
    563 };
    564 
    565 /* from <sys/sem.h> */
    566 typedef netbsd32_pointer_t netbsd32_semp_t;
    567 
    568 typedef netbsd32_pointer_t netbsd32_semid_dsp_t;
    569 struct netbsd32_semid_ds {
    570 	struct netbsd32_ipc_perm	sem_perm;/* operation permission struct */
    571 	unsigned short	sem_nsems;	/* number of sems in set */
    572 	netbsd32_time_t	sem_otime;	/* last operation time */
    573 	netbsd32_time_t	sem_ctime;	/* last change time */
    574 
    575 	/*
    576 	 * These members are private and used only in the internal
    577 	 * implementation of this interface.
    578 	 */
    579 	netbsd32_semp_t	_sem_base;	/* pointer to first semaphore in set */
    580 };
    581 
    582 typedef netbsd32_pointer_t netbsd32_semid_ds50p_t;
    583 struct netbsd32_semid_ds50 {
    584 	struct netbsd32_ipc_perm	sem_perm;/* operation permission struct */
    585 	unsigned short	sem_nsems;	/* number of sems in set */
    586 	int32_t		sem_otime;	/* last operation time */
    587 	int32_t		sem_ctime;	/* last change time */
    588 
    589 	/*
    590 	 * These members are private and used only in the internal
    591 	 * implementation of this interface.
    592 	 */
    593 	netbsd32_semp_t	_sem_base;	/* pointer to first semaphore in set */
    594 };
    595 
    596 typedef netbsd32_pointer_t netbsd32_semid_ds14p_t;
    597 struct netbsd32_semid_ds14 {
    598 	struct netbsd32_ipc_perm14	sem_perm;/* operation permission struct */
    599 	netbsd32_semp_t	sem_base;	/* pointer to first semaphore in set */
    600 	unsigned short	sem_nsems;	/* number of sems in set */
    601 	netbsd32_time_t	sem_otime;	/* last operation time */
    602 	netbsd32_long	sem_pad1;	/* SVABI/386 says I need this here */
    603 	netbsd32_time_t	sem_ctime;	/* last change time */
    604 					/* Times measured in secs since */
    605 					/* 00:00:00 GMT, Jan. 1, 1970 */
    606 	int32_t		sem_pad2;	/* SVABI/386 says I need this here */
    607 	int32_t		sem_pad3[4];	/* SVABI/386 says I need this here */
    608 };
    609 
    610 typedef uint32_t netbsd32_semunu_t;
    611 typedef netbsd32_pointer_t netbsd32_semunp_t;
    612 union netbsd32_semun {
    613 	int	val;			/* value for SETVAL */
    614 	netbsd32_semid_dsp_t buf;	/* buffer for IPC_STAT & IPC_SET */
    615 	netbsd32_u_shortp array;	/* array for GETALL & SETALL */
    616 };
    617 
    618 typedef netbsd32_pointer_t netbsd32_semun50p_t;
    619 union netbsd32_semun50 {
    620 	int	val;			/* value for SETVAL */
    621 	netbsd32_semid_ds50p_t buf;	/* buffer for IPC_STAT & IPC_SET */
    622 	netbsd32_u_shortp array;	/* array for GETALL & SETALL */
    623 };
    624 
    625 typedef netbsd32_pointer_t netbsd32_sembufp_t;
    626 struct netbsd32_sembuf {
    627 	unsigned short	sem_num;	/* semaphore # */
    628 	short		sem_op;		/* semaphore operation */
    629 	short		sem_flg;	/* operation flags */
    630 };
    631 
    632 /* from <sys/shm.h> */
    633 typedef netbsd32_pointer_t netbsd32_shmid_dsp_t;
    634 struct netbsd32_shmid_ds {
    635 	struct netbsd32_ipc_perm shm_perm; /* operation permission structure */
    636 	netbsd32_size_t	shm_segsz;	/* size of segment in bytes */
    637 	pid_t		shm_lpid;	/* process ID of last shm op */
    638 	pid_t		shm_cpid;	/* process ID of creator */
    639 	shmatt_t	shm_nattch;	/* number of current attaches */
    640 	netbsd32_time_t	shm_atime;	/* time of last shmat() */
    641 	netbsd32_time_t	shm_dtime;	/* time of last shmdt() */
    642 	netbsd32_time_t	shm_ctime;	/* time of last change by shmctl() */
    643 	netbsd32_voidp	_shm_internal;	/* sysv stupidity */
    644 };
    645 
    646 typedef netbsd32_pointer_t netbsd32_shmid_ds50p_t;
    647 struct netbsd32_shmid_ds50 {
    648 	struct netbsd32_ipc_perm shm_perm; /* operation permission structure */
    649 	netbsd32_size_t	shm_segsz;	/* size of segment in bytes */
    650 	pid_t		shm_lpid;	/* process ID of last shm op */
    651 	pid_t		shm_cpid;	/* process ID of creator */
    652 	shmatt_t	shm_nattch;	/* number of current attaches */
    653 	int32_t		shm_atime;	/* time of last shmat() */
    654 	int32_t		shm_dtime;	/* time of last shmdt() */
    655 	int32_t		shm_ctime;	/* time of last change by shmctl() */
    656 	netbsd32_voidp	_shm_internal;	/* sysv stupidity */
    657 };
    658 
    659 typedef netbsd32_pointer_t netbsd32_shmid_ds14p_t;
    660 struct netbsd32_shmid_ds14 {
    661 	struct netbsd32_ipc_perm14 shm_perm; /* operation permission structure */
    662 	int		shm_segsz;	/* size of segment in bytes */
    663 	pid_t		shm_lpid;	/* process ID of last shm op */
    664 	pid_t		shm_cpid;	/* process ID of creator */
    665 	short		shm_nattch;	/* number of current attaches */
    666 	int32_t		shm_atime;	/* time of last shmat() */
    667 	int32_t		shm_dtime;	/* time of last shmdt() */
    668 	int32_t		shm_ctime;	/* time of last change by shmctl() */
    669 	netbsd32_voidp	_shm_internal;	/* sysv stupidity */
    670 };
    671 
    672 /* from <sys/signal.h> */
    673 typedef netbsd32_pointer_t netbsd32_sigsetp_t;
    674 typedef netbsd32_pointer_t netbsd32_sigactionp_t;
    675 struct	netbsd32_sigaction13 {
    676 	netbsd32_voidp netbsd32_sa_handler;	/* signal handler */
    677 	sigset13_t netbsd32_sa_mask;		/* signal mask to apply */
    678 	int	netbsd32_sa_flags;		/* see signal options below */
    679 };
    680 
    681 struct	netbsd32_sigaction {
    682 	netbsd32_voidp netbsd32_sa_handler;	/* signal handler */
    683 	sigset_t netbsd32_sa_mask;		/* signal mask to apply */
    684 	int	netbsd32_sa_flags;		/* see signal options below */
    685 };
    686 
    687 typedef netbsd32_pointer_t netbsd32_sigaltstack13p_t;
    688 struct netbsd32_sigaltstack13 {
    689 	netbsd32_charp	ss_sp;		/* signal stack base */
    690 	int	ss_size;		/* signal stack length */
    691 	int	ss_flags;		/* SS_DISABLE and/or SS_ONSTACK */
    692 };
    693 
    694 typedef netbsd32_pointer_t netbsd32_sigaltstackp_t;
    695 struct netbsd32_sigaltstack {
    696 	netbsd32_voidp	ss_sp;		/* signal stack base */
    697 	netbsd32_size_t	ss_size;	/* signal stack length */
    698 	int	ss_flags;		/* SS_DISABLE and/or SS_ONSTACK */
    699 };
    700 
    701 typedef netbsd32_pointer_t netbsd32_sigstackp_t;
    702 struct	netbsd32_sigstack {
    703 	netbsd32_voidp	ss_sp;		/* signal stack pointer */
    704 	int	ss_onstack;		/* current status */
    705 };
    706 
    707 typedef netbsd32_pointer_t netbsd32_sigvecp_t;
    708 struct	netbsd32_sigvec {
    709 	netbsd32_voidp sv_handler;	/* signal handler */
    710 	int	sv_mask;		/* signal mask to apply */
    711 	int	sv_flags;		/* see signal options below */
    712 };
    713 
    714 typedef netbsd32_pointer_t netbsd32_siginfop_t;
    715 
    716 union netbsd32_sigval {
    717 	int	sival_int;
    718 	netbsd32_voidp	sival_ptr;
    719 };
    720 
    721 typedef netbsd32_pointer_t netbsd32_sigeventp_t;
    722 struct netbsd32_sigevent {
    723 	int	sigev_notify;
    724 	int	sigev_signo;
    725 	union netbsd32_sigval	sigev_value;
    726 	netbsd32_voidp	sigev_notify_function;
    727 	netbsd32_voidp	sigev_notify_attributes;
    728 };
    729 
    730 /* from <sys/sigtypes.h> */
    731 typedef netbsd32_pointer_t netbsd32_stackp_t;
    732 
    733 /* from <sys/socket.h> */
    734 typedef netbsd32_pointer_t netbsd32_sockaddrp_t;
    735 typedef netbsd32_pointer_t netbsd32_osockaddrp_t;
    736 typedef netbsd32_pointer_t netbsd32_socklenp_t;
    737 
    738 typedef netbsd32_pointer_t netbsd32_msghdrp_t;
    739 struct netbsd32_msghdr {
    740 	netbsd32_caddr_t msg_name;		/* optional address */
    741 	unsigned int	msg_namelen;		/* size of address */
    742 	netbsd32_iovecp_t msg_iov;		/* scatter/gather array */
    743 	unsigned int	msg_iovlen;		/* # elements in msg_iov */
    744 	netbsd32_caddr_t msg_control;		/* ancillary data, see below */
    745 	unsigned int	msg_controllen;		/* ancillary data buffer len */
    746 	int	msg_flags;		/* flags on received message */
    747 };
    748 
    749 typedef netbsd32_pointer_t netbsd32_omsghdrp_t;
    750 struct netbsd32_omsghdr {
    751 	netbsd32_caddr_t msg_name;		/* optional address */
    752 	int		 msg_namelen;		/* size of address */
    753 	netbsd32_iovecp_t msg_iov;		/* scatter/gather array */
    754 	int		 msg_iovlen;		/* # elements in msg_iov */
    755 	netbsd32_caddr_t msg_accrights;		/* access rights sent/recvd */
    756 	u_int		 msg_accrightslen;
    757 };
    758 
    759 typedef netbsd32_pointer_t netbsd32_mmsghdrp_t;
    760 struct netbsd32_mmsghdr {
    761 	struct netbsd32_msghdr msg_hdr;
    762 	unsigned int msg_len;
    763 };
    764 
    765 /* from <sys/stat.h> */
    766 typedef netbsd32_pointer_t netbsd32_stat12p_t;
    767 struct netbsd32_stat12 {		/* NetBSD-1.2 stat struct */
    768 	uint32_t	st_dev;		/* inode's device */
    769 	uint32_t	st_ino;		/* inode's number */
    770 	uint16_t	st_mode;	/* inode protection mode */
    771 	uint16_t	st_nlink;	/* number of hard links */
    772 	uid_t		st_uid;		/* user ID of the file's owner */
    773 	gid_t		st_gid;		/* group ID of the file's group */
    774 	uint32_t	st_rdev;	/* device type */
    775 	struct netbsd32_timespec50 st_atimespec;/* time of last access */
    776 	struct netbsd32_timespec50 st_mtimespec;/* time of last data modification */
    777 	struct netbsd32_timespec50 st_ctimespec;/* time of last file status change */
    778 	netbsd32_int64	st_size;	/* file size, in bytes */
    779 	netbsd32_int64	st_blocks;	/* blocks allocated for file */
    780 	uint32_t	st_blksize;	/* optimal blocksize for I/O */
    781 	uint32_t	st_flags;	/* user defined flags for file */
    782 	uint32_t	st_gen;		/* file generation number */
    783 	int32_t		st_lspare;
    784 	netbsd32_int64	st_qspare[2];
    785 };
    786 
    787 typedef netbsd32_pointer_t netbsd32_stat43p_t;
    788 struct netbsd32_stat43 {		/* BSD-4.3 stat struct */
    789 	uint16_t  st_dev;		/* inode's device */
    790 	uint32_t  st_ino;		/* inode's number */
    791 	uint16_t  st_mode;		/* inode protection mode */
    792 	uint16_t  st_nlink;		/* number of hard links */
    793 	uint16_t  st_uid;		/* user ID of the file's owner */
    794 	uint16_t  st_gid;		/* group ID of the file's group */
    795 	uint16_t  st_rdev;		/* device type */
    796 	int32_t	  st_size;		/* file size, in bytes */
    797 	struct netbsd32_timespec50 st_atimespec;/* time of last access */
    798 	struct netbsd32_timespec50 st_mtimespec;/* time of last data modification */
    799 	struct netbsd32_timespec50 st_ctimespec;/* time of last file status change */
    800 	int32_t	  st_blksize;		/* optimal blocksize for I/O */
    801 	int32_t	  st_blocks;		/* blocks allocated for file */
    802 	uint32_t  st_flags;		/* user defined flags for file */
    803 	uint32_t  st_gen;		/* file generation number */
    804 };
    805 typedef netbsd32_pointer_t netbsd32_stat13p_t;
    806 struct netbsd32_stat13 {
    807 	uint32_t  st_dev;		/* inode's device */
    808 	uint32_t  st_ino;		/* inode's number */
    809 	mode_t	  st_mode;		/* inode protection mode */
    810 	nlink_t	  st_nlink;		/* number of hard links */
    811 	uid_t	  st_uid;		/* user ID of the file's owner */
    812 	gid_t	  st_gid;		/* group ID of the file's group */
    813 	uint32_t  st_rdev;		/* device type */
    814 	struct netbsd32_timespec50 st_atimespec;/* time of last access */
    815 	struct netbsd32_timespec50 st_mtimespec;/* time of last data modification */
    816 	struct netbsd32_timespec50 st_ctimespec;/* time of last file status change */
    817 	netbsd32_int64	  st_size;		/* file size, in bytes */
    818 	netbsd32_uint64  st_blocks;		/* blocks allocated for file */
    819 	blksize_t st_blksize;		/* optimal blocksize for I/O */
    820 	uint32_t  st_flags;		/* user defined flags for file */
    821 	uint32_t  st_gen;		/* file generation number */
    822 	uint32_t  st_spare;		/* file generation number */
    823 	struct	  netbsd32_timespec50 st_birthtimespec;
    824 	uint32_t  st_spare2;
    825 };
    826 
    827 typedef netbsd32_pointer_t netbsd32_stat50p_t;
    828 struct netbsd32_stat50 {
    829 	uint32_t	st_dev;		/* inode's device */
    830 	mode_t		st_mode;	/* inode protection mode */
    831 	netbsd32_uint64	st_ino;		/* inode's number */
    832 	nlink_t		st_nlink;	/* number of hard links */
    833 	uid_t		st_uid;		/* user ID of the file's owner */
    834 	gid_t		st_gid;		/* group ID of the file's group */
    835 	uint32_t	st_rdev;	/* device type */
    836 	struct netbsd32_timespec50 st_atimespec;/* time of last access */
    837 	struct netbsd32_timespec50 st_mtimespec;/* time of last data modification */
    838 	struct netbsd32_timespec50 st_ctimespec;/* time of last file status change */
    839 	struct netbsd32_timespec50 st_birthtimespec; /* time of creation */
    840 	netbsd32_int64	st_size;	/* file size, in bytes */
    841 	netbsd32_uint64 st_blocks;	/* blocks allocated for file */
    842 	blksize_t	st_blksize;	/* optimal blocksize for I/O */
    843 	uint32_t	st_flags;	/* user defined flags for file */
    844 	uint32_t	st_gen;		/* file generation number */
    845 	uint32_t	st_spare[2];
    846 };
    847 
    848 typedef netbsd32_pointer_t netbsd32_statp_t;
    849 struct netbsd32_stat {
    850 	netbsd32_dev_t	st_dev;		/* inode's device */
    851 	mode_t		st_mode;	/* inode protection mode */
    852 	netbsd32_uint64	st_ino;		/* inode's number */
    853 	nlink_t		st_nlink;	/* number of hard links */
    854 	uid_t		st_uid;		/* user ID of the file's owner */
    855 	gid_t		st_gid;		/* group ID of the file's group */
    856 	netbsd32_dev_t	st_rdev;	/* device type */
    857 	struct netbsd32_timespec st_atimespec;/* time of last access */
    858 	struct netbsd32_timespec st_mtimespec;/* time of last data modification */
    859 	struct netbsd32_timespec st_ctimespec;/* time of last file status change */
    860 	struct netbsd32_timespec st_birthtimespec; /* time of creation */
    861 	netbsd32_int64	st_size;	/* file size, in bytes */
    862 	netbsd32_uint64 st_blocks;	/* blocks allocated for file */
    863 	blksize_t	st_blksize;	/* optimal blocksize for I/O */
    864 	uint32_t	st_flags;	/* user defined flags for file */
    865 	uint32_t	st_gen;		/* file generation number */
    866 	uint32_t	st_spare[2];
    867 };
    868 
    869 /* from <sys/statvfs.h> */
    870 typedef netbsd32_pointer_t netbsd32_statvfs90p_t;
    871 struct netbsd32_statvfs90 {
    872 	netbsd32_u_long	f_flag;		/* copy of mount exported flags */
    873 	netbsd32_u_long	f_bsize;	/* system block size */
    874 	netbsd32_u_long	f_frsize;	/* system fragment size */
    875 	netbsd32_u_long	f_iosize;	/* optimal file system block size */
    876 	netbsd32_uint64	f_blocks;	/* number of blocks in file system */
    877 	netbsd32_uint64	f_bfree;	/* free blocks avail in file system */
    878 	netbsd32_uint64	f_bavail;	/* free blocks avail to non-root */
    879 	netbsd32_uint64	f_bresvd;	/* blocks reserved for root */
    880 	netbsd32_uint64	f_files;	/* total file nodes in file system */
    881 	netbsd32_uint64	f_ffree;	/* free file nodes in file system */
    882 	netbsd32_uint64	f_favail;	/* free file nodes avail to non-root */
    883 	netbsd32_uint64	f_fresvd;	/* file nodes reserved for root */
    884 	netbsd32_uint64	f_syncreads;	/* count of sync reads since mount */
    885 	netbsd32_uint64	f_syncwrites;	/* count of sync writes since mount */
    886 	netbsd32_uint64	f_asyncreads;	/* count of async reads since mount */
    887 	netbsd32_uint64	f_asyncwrites;	/* count of async writes since mount */
    888 	fsid_t		f_fsidx;	/* NetBSD compatible fsid */
    889 	netbsd32_u_long	f_fsid;		/* Posix compatible fsid */
    890 	netbsd32_u_long	f_namemax;	/* maximum filename length */
    891 	uid_t		f_owner;	/* user that mounted the file system */
    892 	uint32_t	f_spare[4];	/* spare space */
    893 	char	f_fstypename[_VFS_NAMELEN]; /* fs type name */
    894 	char	f_mntonname[_VFS_MNAMELEN];  /* directory on which mounted */
    895 	char	f_mntfromname[_VFS_MNAMELEN];  /* mounted file system */
    896 };
    897 
    898 typedef netbsd32_pointer_t netbsd32_statvfsp_t;
    899 struct netbsd32_statvfs {
    900 	netbsd32_u_long	f_flag;		/* copy of mount exported flags */
    901 	netbsd32_u_long	f_bsize;	/* system block size */
    902 	netbsd32_u_long	f_frsize;	/* system fragment size */
    903 	netbsd32_u_long	f_iosize;	/* optimal file system block size */
    904 	netbsd32_uint64	f_blocks;	/* number of blocks in file system */
    905 	netbsd32_uint64	f_bfree;	/* free blocks avail in file system */
    906 	netbsd32_uint64	f_bavail;	/* free blocks avail to non-root */
    907 	netbsd32_uint64	f_bresvd;	/* blocks reserved for root */
    908 	netbsd32_uint64	f_files;	/* total file nodes in file system */
    909 	netbsd32_uint64	f_ffree;	/* free file nodes in file system */
    910 	netbsd32_uint64	f_favail;	/* free file nodes avail to non-root */
    911 	netbsd32_uint64	f_fresvd;	/* file nodes reserved for root */
    912 	netbsd32_uint64	f_syncreads;	/* count of sync reads since mount */
    913 	netbsd32_uint64	f_syncwrites;	/* count of sync writes since mount */
    914 	netbsd32_uint64	f_asyncreads;	/* count of async reads since mount */
    915 	netbsd32_uint64	f_asyncwrites;	/* count of async writes since mount */
    916 	fsid_t		f_fsidx;	/* NetBSD compatible fsid */
    917 	netbsd32_u_long	f_fsid;		/* Posix compatible fsid */
    918 	netbsd32_u_long	f_namemax;	/* maximum filename length */
    919 	uid_t		f_owner;	/* user that mounted the file system */
    920 	netbsd32_uint64	f_spare[4];	/* spare space */
    921 	char	f_fstypename[_VFS_NAMELEN]; /* fs type name */
    922 	char	f_mntonname[_VFS_MNAMELEN];  /* directory on which mounted */
    923 	char	f_mntfromname[_VFS_MNAMELEN];  /* mounted file system */
    924 	char	f_mntfromlabel[_VFS_MNAMELEN];  /* disk label name if available */
    925 };
    926 
    927 /* from <sys/timex.h> */
    928 typedef netbsd32_pointer_t netbsd32_ntptimevalp_t;
    929 typedef netbsd32_pointer_t netbsd32_ntptimeval30p_t;
    930 typedef netbsd32_pointer_t netbsd32_ntptimeval50p_t;
    931 
    932 struct netbsd32_ntptimeval30 {
    933 	struct netbsd32_timeval50 time;	/* current time (ro) */
    934 	netbsd32_long maxerror;	/* maximum error (us) (ro) */
    935 	netbsd32_long esterror;	/* estimated error (us) (ro) */
    936 };
    937 struct netbsd32_ntptimeval50 {
    938 	struct netbsd32_timespec50 time;	/* current time (ro) */
    939 	netbsd32_long maxerror;	/* maximum error (us) (ro) */
    940 	netbsd32_long esterror;	/* estimated error (us) (ro) */
    941 	netbsd32_long tai;	/* TAI offset */
    942 	int time_state;		/* time status */
    943 };
    944 
    945 struct netbsd32_ntptimeval {
    946 	struct netbsd32_timespec time;	/* current time (ro) */
    947 	netbsd32_long maxerror;	/* maximum error (us) (ro) */
    948 	netbsd32_long esterror;	/* estimated error (us) (ro) */
    949 	netbsd32_long tai;	/* TAI offset */
    950 	int time_state;		/* time status */
    951 };
    952 typedef netbsd32_pointer_t netbsd32_timexp_t;
    953 struct netbsd32_timex {
    954 	unsigned int modes;	/* clock mode bits (wo) */
    955 	netbsd32_long offset;	/* time offset (us) (rw) */
    956 	netbsd32_long freq;	/* frequency offset (scaled ppm) (rw) */
    957 	netbsd32_long maxerror;	/* maximum error (us) (rw) */
    958 	netbsd32_long esterror;	/* estimated error (us) (rw) */
    959 	int status;		/* clock status bits (rw) */
    960 	netbsd32_long constant;	/* pll time constant (rw) */
    961 	netbsd32_long precision;	/* clock precision (us) (ro) */
    962 	netbsd32_long tolerance;	/* clock frequency tolerance (scaled
    963 				 * ppm) (ro) */
    964 	/*
    965 	 * The following read-only structure members are implemented
    966 	 * only if the PPS signal discipline is configured in the
    967 	 * kernel.
    968 	 */
    969 	netbsd32_long ppsfreq;	/* pps frequency (scaled ppm) (ro) */
    970 	netbsd32_long jitter;	/* pps jitter (us) (ro) */
    971 	int shift;		/* interval duration (s) (shift) (ro) */
    972 	netbsd32_long stabil;	/* pps stability (scaled ppm) (ro) */
    973 	netbsd32_long jitcnt;	/* jitter limit exceeded (ro) */
    974 	netbsd32_long calcnt;	/* calibration intervals (ro) */
    975 	netbsd32_long errcnt;	/* calibration errors (ro) */
    976 	netbsd32_long stbcnt;	/* stability limit exceeded (ro) */
    977 };
    978 
    979 /* <prop/plistref.h> */
    980 struct netbsd32_plistref {
    981 	netbsd32_pointer_t pref_plist;
    982 	netbsd32_size_t pref_len;
    983 };
    984 
    985 /* <nv.h> */
    986 typedef struct {
    987 	netbsd32_pointer_t buf;
    988 	netbsd32_size_t    len;
    989 	int                flags;
    990 } netbsd32_nvlist_ref_t;
    991 
    992 /* from <ufs/lfs/lfs.h> */
    993 typedef netbsd32_pointer_t netbsd32_block_infop_t;  /* XXX broken */
    994 
    995 /* from <sys/utsname.h> */
    996 typedef netbsd32_pointer_t netbsd32_utsnamep_t;
    997 
    998 /* from <compat/common/kern_info_09.c> */
    999 typedef netbsd32_pointer_t netbsd32_outsnamep_t;
   1000 
   1001 /* from <arch/sparc{,64}/include/vuid_event.h> */
   1002 typedef struct firm_event32 {
   1003 	unsigned short	id;		/* key or MS_* or LOC_[XY]_DELTA */
   1004 	unsigned short	pad;		/* unused, at least by X11 */
   1005 	int	value;		/* VKEY_{UP,DOWN} or locator delta */
   1006 	struct netbsd32_timeval time;
   1007 } Firm_event32;
   1008 
   1009 /* from <sys/uuid.h> */
   1010 typedef netbsd32_pointer_t netbsd32_uuidp_t;
   1011 
   1012 /* from <sys/event.h> */
   1013 typedef netbsd32_pointer_t netbsd32_keventp_t;
   1014 
   1015 struct netbsd32_kevent {
   1016 	netbsd32_uintptr_t	ident;
   1017 	uint32_t		filter;
   1018 	uint32_t		flags;
   1019 	uint32_t		fflags;
   1020 	netbsd32_int64		data;
   1021 	netbsd32_pointer_t	udata;
   1022 };
   1023 
   1024 /* from <sys/sched.h> */
   1025 typedef netbsd32_pointer_t netbsd32_sched_paramp_t;
   1026 typedef netbsd32_pointer_t netbsd32_cpusetp_t;
   1027 
   1028 /* from <fs/tmpfs/tmpfs_args.h> */
   1029 struct netbsd32_tmpfs_args {
   1030         int                     ta_version;
   1031 
   1032         /* Size counters. */
   1033         netbsd32_ino_t          ta_nodes_max;
   1034         netbsd32_off_t          ta_size_max;
   1035 
   1036         /* Root node attributes. */
   1037         uid_t                   ta_root_uid;
   1038         gid_t                   ta_root_gid;
   1039         mode_t                  ta_root_mode;
   1040 };
   1041 
   1042 /* from <fs/cd9660/cd9660_mount.h> */
   1043 struct netbsd32_iso_args {
   1044 	netbsd32_charp fspec;
   1045 	struct netbsd32_export_args30 _pad1;
   1046 	int	flags;
   1047 };
   1048 
   1049 /* from <ufs/ufs/ufs_mount.h> */
   1050 struct netbsd32_ufs_args {
   1051 	netbsd32_charp		fspec;
   1052 };
   1053 
   1054 struct netbsd32_mfs_args {
   1055 	netbsd32_charp		fspec;
   1056 	struct netbsd32_export_args30	_pad1;
   1057 	netbsd32_voidp		base;
   1058 	netbsd32_u_long		size;
   1059 };
   1060 
   1061 /* from <nfs/nfs.h> */
   1062 struct netbsd32_nfsd_args {
   1063 	int		sock;
   1064 	netbsd32_voidp	name;
   1065 	int		namelen;
   1066 };
   1067 
   1068 typedef netbsd32_pointer_t netbsd32_nfsdp;
   1069 struct netbsd32_nfsd_srvargs {
   1070 	netbsd32_nfsdp	nsd_nfsd;
   1071 	uid_t		nsd_uid;
   1072 	u_int32_t	nsd_haddr;
   1073 	struct uucred	nsd_cr;
   1074 	int		nsd_authlen;
   1075 	netbsd32_u_charp nsd_authstr;
   1076 	int		nsd_verflen;
   1077 	netbsd32_u_charp nsd_verfstr;
   1078 	struct netbsd32_timeval	nsd_timestamp;
   1079 	u_int32_t	nsd_ttl;
   1080 	NFSKERBKEY_T	nsd_key;
   1081 };
   1082 
   1083 typedef netbsd32_pointer_t netbsd32_export_argsp;
   1084 struct netbsd32_export_args {
   1085 	int		ex_flags;
   1086 	uid_t		ex_root;
   1087 	struct uucred	ex_anon;
   1088 	netbsd32_sockaddrp_t ex_addr;
   1089 	int		ex_addrlen;
   1090 	netbsd32_sockaddrp_t ex_mask;
   1091 	int		ex_masklen;
   1092 	netbsd32_charp	ex_indexfile;
   1093 };
   1094 
   1095 struct netbsd32_mountd_exports_list {
   1096 	const netbsd32_charp	mel_path;
   1097 	netbsd32_size_t		mel_nexports;
   1098 	netbsd32_export_argsp	mel_exports;
   1099 };
   1100 
   1101 /* from <nfs/nfsmount,h> */
   1102 struct netbsd32_nfs_args {
   1103 	int32_t		version;	/* args structure version number */
   1104 	netbsd32_sockaddrp_t addr;	/* file server address */
   1105 	int32_t		addrlen;	/* length of address */
   1106 	int32_t		sotype;		/* Socket type */
   1107 	int32_t		proto;		/* and Protocol */
   1108 	netbsd32_u_charp fh;		/* File handle to be mounted */
   1109 	int32_t		fhsize;		/* Size, in bytes, of fh */
   1110 	int32_t		flags;		/* flags */
   1111 	int32_t		wsize;		/* write size in bytes */
   1112 	int32_t		rsize;		/* read size in bytes */
   1113 	int32_t		readdirsize;	/* readdir size in bytes */
   1114 	int32_t		timeo;		/* initial timeout in .1 secs */
   1115 	int32_t		retrans;	/* times to retry send */
   1116 	int32_t		maxgrouplist;	/* Max. size of group list */
   1117 	int32_t		readahead;	/* # of blocks to readahead */
   1118 	int32_t		leaseterm;	/* Ignored; Term (sec) of lease */
   1119 	int32_t		deadthresh;	/* Retrans threshold */
   1120 	netbsd32_charp	hostname;	/* server's name */
   1121 };
   1122 
   1123 /* from <msdosfs/msdosfsmount.h> */
   1124 struct netbsd32_msdosfs_args {
   1125 	netbsd32_charp	fspec;		/* blocks special holding the fs to mount */
   1126 	struct	netbsd32_export_args30 _pad1; /* compat with old userland tools */
   1127 	uid_t	uid;		/* uid that owns msdosfs files */
   1128 	gid_t	gid;		/* gid that owns msdosfs files */
   1129 	mode_t  mask;		/* mask to be applied for msdosfs perms */
   1130 	int	flags;		/* see below */
   1131 
   1132 	/* Following items added after versioning support */
   1133 	int	version;	/* version of the struct */
   1134 	mode_t  dirmask;	/* v2: mask to be applied for msdosfs perms */
   1135 	int	gmtoff;		/* v3: offset from UTC in seconds */
   1136 };
   1137 
   1138 /* from <miscfs/genfs/layer.h> */
   1139 struct netbsd32_layer_args {
   1140 	netbsd32_charp target;		/* Target of loopback  */
   1141 	struct netbsd32_export_args30 _pad1; /* compat with old userland tools */
   1142 };
   1143 
   1144 /* from <miscfs/nullfs/null.h> */
   1145 struct netbsd32_null_args {
   1146 	struct	netbsd32_layer_args	la;	/* generic layerfs args */
   1147 };
   1148 
   1149 struct netbsd32_posix_spawn_file_actions_entry {
   1150 	enum { FAE32_OPEN, FAE32_DUP2, FAE32_CLOSE } fae_action;
   1151 
   1152 	int fae_fildes;
   1153 	union {
   1154 		struct {
   1155 			netbsd32_charp path;
   1156 			int oflag;
   1157 			mode_t mode;
   1158 		} open;
   1159 		struct {
   1160 			int newfildes;
   1161 		} dup2;
   1162 	} fae_data;
   1163 };
   1164 
   1165 struct netbsd32_posix_spawn_file_actions {
   1166 	unsigned int size;	/* size of fae array */
   1167 	unsigned int len;	/* how many slots are used */
   1168 	netbsd32_posix_spawn_file_actions_entryp fae;
   1169 };
   1170 
   1171 struct netbsd32_modctl_load {
   1172 	netbsd32_charp ml_filename;
   1173 	int ml_flags;
   1174 	netbsd32_charp ml_props;
   1175 	netbsd32_size_t ml_propslen;
   1176 };
   1177 
   1178 struct netbsd32_mq_attr {
   1179 	netbsd32_long	mq_flags;
   1180 	netbsd32_long	mq_maxmsg;
   1181 	netbsd32_long	mq_msgsize;
   1182 	netbsd32_long	mq_curmsgs;
   1183 };
   1184 typedef netbsd32_pointer_t netbsd32_mq_attrp_t;
   1185 
   1186 #if 0
   1187 int	netbsd32_kevent(struct lwp *, void *, register_t *);
   1188 #endif
   1189 
   1190 /*
   1191  * here are some macros to convert between netbsd32 and native 64 bit types.
   1192  * note that they do *NOT* act like good macros and put ()'s around all
   1193  * arguments cuz this _breaks_ SCARG().
   1194  */
   1195 #define NETBSD32TO64(s32uap, uap, name) \
   1196 	    SCARG(uap, name) = SCARG(s32uap, name)
   1197 #define NETBSD32TOP(s32uap, uap, name, type) \
   1198 	    SCARG(uap, name) = SCARG_P32(s32uap, name)
   1199 #define NETBSD32TOX(s32uap, uap, name, type) \
   1200 	    SCARG(uap, name) = (type)SCARG(s32uap, name)
   1201 #define NETBSD32TOX64(s32uap, uap, name, type) \
   1202 	    SCARG(uap, name) = (type)(long)SCARG(s32uap, name)
   1203 
   1204 /* and some standard versions */
   1205 #define	NETBSD32TO64_UAP(name)		NETBSD32TO64(uap, &ua, name)
   1206 #define	NETBSD32TOP_UAP(name, type)	NETBSD32TOP(uap, &ua, name, type)
   1207 #define	NETBSD32TOX_UAP(name, type)	NETBSD32TOX(uap, &ua, name, type)
   1208 #define	NETBSD32TOX64_UAP(name, type)	NETBSD32TOX64(uap, &ua, name, type)
   1209 
   1210 #define	SCARG_P32(uap, name) NETBSD32PTR64(SCARG(uap, name))
   1211 
   1212 struct coredump_iostate;
   1213 int	coredump_netbsd32(struct lwp *, struct coredump_iostate *);
   1214 
   1215 /*
   1216  * random other stuff
   1217  */
   1218 
   1219 vaddr_t netbsd32_vm_default_addr(struct proc *, vaddr_t, vsize_t, int);
   1220 void netbsd32_adjust_limits(struct proc *);
   1221 
   1222 void	netbsd32_si_to_si32(siginfo32_t *, const siginfo_t *);
   1223 void	netbsd32_si32_to_si(siginfo_t *, const siginfo32_t *);
   1224 
   1225 void	netbsd32_ksi32_to_ksi(struct _ksiginfo *si, const struct __ksiginfo32 *si32);
   1226 
   1227 void	netbsd32_read_lwpstatus(struct lwp *, struct netbsd32_ptrace_lwpstatus *);
   1228 
   1229 #ifdef KTRACE
   1230 void netbsd32_ktrpsig(int, sig_t, const sigset_t *, const ksiginfo_t *);
   1231 #else
   1232 #define netbsd32_ktrpsig NULL
   1233 #endif
   1234 
   1235 
   1236 void	startlwp32(void *);
   1237 struct compat_50_netbsd32___semctl14_args;
   1238 int	do_netbsd32___semctl14(struct lwp *, const struct compat_50_netbsd32___semctl14_args *, register_t *, void *);
   1239 
   1240 struct iovec *netbsd32_get_iov(struct netbsd32_iovec *, int, struct iovec *,
   1241 	    int);
   1242 
   1243 #ifdef SYSCTL_SETUP_PROTO
   1244 SYSCTL_SETUP_PROTO(netbsd32_sysctl_emul_setup);
   1245 #endif /* SYSCTL_SETUP_PROTO */
   1246 
   1247 MODULE_HOOK(netbsd32_sendsig_hook, void,
   1248     (const ksiginfo_t *, const sigset_t *));
   1249 
   1250 extern struct sysent netbsd32_sysent[];
   1251 extern const uint32_t netbsd32_sysent_nomodbits[];
   1252 #ifdef SYSCALL_DEBUG
   1253 extern const char * const netbsd32_syscallnames[];
   1254 #endif
   1255 
   1256 extern struct sysctlnode netbsd32_sysctl_root;
   1257 
   1258 struct netbsd32_modctl_args;
   1259 MODULE_HOOK(compat32_80_modctl_hook, int,
   1260     (struct lwp *, const struct netbsd32_modctl_args *, register_t *));
   1261 
   1262 /*
   1263  * Finally, declare emul_netbsd32 as this is needed in lots of
   1264  * places when calling syscall_{,dis}establish()
   1265  */
   1266 
   1267 extern struct emul emul_netbsd32;
   1268 extern char netbsd32_sigcode[], netbsd32_esigcode[];
   1269 
   1270 /*
   1271  * Prototypes for MD initialization routines
   1272  */
   1273 void netbsd32_machdep_md_init(void);
   1274 void netbsd32_machdep_md_fini(void);
   1275 void netbsd32_machdep_md_13_init(void);
   1276 void netbsd32_machdep_md_13_fini(void);
   1277 void netbsd32_machdep_md_16_init(void);
   1278 void netbsd32_machdep_md_16_fini(void);
   1279 
   1280 #endif /* _COMPAT_NETBSD32_NETBSD32_H_ */
   1281