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