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