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