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