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