Home | History | Annotate | Line # | Download | only in netbsd32
netbsd32.h revision 1.22
      1 /*	$NetBSD: netbsd32.h,v 1.22 2002/10/23 13:16:40 scw Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1998, 2001 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  * 3. The name of the author may not be used to endorse or promote products
     16  *    derived from this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     23  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     25  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     26  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28  * SUCH DAMAGE.
     29  */
     30 
     31 #ifndef _COMPAT_NETBSD32_NETBSD32_H_
     32 #define _COMPAT_NETBSD32_NETBSD32_H_
     33 /* We need to change the size of register_t */
     34 #ifdef syscallargs
     35 #undef syscallargs
     36 #endif
     37 /*
     38  * NetBSD 32-bit compatibility module.
     39  */
     40 
     41 #include <sys/systm.h>
     42 #include <sys/mount.h>
     43 #include <sys/stat.h>
     44 #include <sys/syscallargs.h>
     45 #include <sys/ipc.h>
     46 #include <sys/shm.h>
     47 
     48 /*
     49  * first, define the basic types we need.
     50  */
     51 
     52 typedef int32_t netbsd32_long;
     53 typedef u_int32_t netbsd32_u_long;
     54 
     55 typedef u_int32_t netbsd32_clock_t;
     56 typedef u_int32_t netbsd32_size_t;
     57 typedef int32_t netbsd32_ssize_t;
     58 typedef int32_t netbsd32_clockid_t;
     59 typedef u_int32_t netbsd32_caddr_t;
     60 typedef int32_t netbsd32_key_t;
     61 typedef int32_t netbsd32_intptr_t;
     62 typedef u_int32_t netbsd32_uintptr_t;
     63 
     64 /*
     65  * machine depedant section; must define:
     66  *	netbsd32_pointer_t
     67  *		- 32-bit pointer type, normally u_int32_t but can be int32_t
     68  *		  for platforms which rely on sign-extension of pointers
     69  *		  such as SH-5.
     70  *	NETBSD32PTR64(p32)
     71  *		- Translate a 32-bit pointer into something valid in a
     72  *		  64-bit context.
     73  *	struct netbsd32_sigcontext
     74  *		- 32bit compatibility sigcontext structure for this arch.
     75  *	netbsd32_sigcontextp_t
     76  *		- type of pointer to above, normally u_int32_t
     77  *	void netbsd32_setregs(struct proc *p, struct exec_package *pack,
     78  *	    u_long stack);
     79  *	int netbsd32_sigreturn(struct proc *p, void *v,
     80  *	    register_t *retval);
     81  *	void netbsd32_sendsig(sig_t catcher, int sig, int mask, u_long code);
     82  *	char netbsd32_esigcode[], netbsd32_sigcode[]
     83  *		- the above are abvious
     84  *
     85  * pull in the netbsd32 machine dependant header, that may help with the
     86  * above, or it may be provided via the MD layer itself.
     87  */
     88 #include <machine/netbsd32_machdep.h>
     89 
     90 /*
     91  * all pointers are netbsd32_pointer_t (defined in <machine/netbsd32_machdep.h>)
     92  */
     93 
     94 typedef netbsd32_pointer_t netbsd32_voidp;
     95 typedef netbsd32_pointer_t netbsd32_u_shortp;
     96 typedef netbsd32_pointer_t netbsd32_charp;
     97 typedef netbsd32_pointer_t netbsd32_u_charp;
     98 typedef netbsd32_pointer_t netbsd32_charpp;
     99 typedef netbsd32_pointer_t netbsd32_size_tp;
    100 typedef netbsd32_pointer_t netbsd32_intp;
    101 typedef netbsd32_pointer_t netbsd32_longp;
    102 typedef netbsd32_pointer_t netbsd32_caddrp;
    103 typedef netbsd32_pointer_t netbsd32_caddr;
    104 typedef netbsd32_pointer_t netbsd32_gid_tp;
    105 typedef netbsd32_pointer_t netbsd32_fsid_tp_t;
    106 
    107 /*
    108  * now, the compatibility structures and their fake pointer types.
    109  */
    110 
    111 /* from <sys/types.h> */
    112 typedef netbsd32_pointer_t netbsd32_fd_setp_t;
    113 
    114 /* from <sys/uio.h> */
    115 typedef netbsd32_pointer_t netbsd32_iovecp_t;
    116 struct netbsd32_iovec {
    117 	netbsd32_voidp	iov_base;	/* Base address. */
    118 	netbsd32_size_t	 iov_len;	/* Length. */
    119 };
    120 
    121 /* from <sys/time.h> */
    122 typedef int32_t netbsd32_timer_t;
    123 typedef	int32_t netbsd32_time_t;
    124 
    125 typedef netbsd32_pointer_t netbsd32_timespecp_t;
    126 struct netbsd32_timespec {
    127 	netbsd32_time_t	tv_sec;			/* seconds */
    128 	netbsd32_long	tv_nsec;	/* and nanoseconds */
    129 };
    130 
    131 typedef netbsd32_pointer_t netbsd32_timevalp_t;
    132 struct netbsd32_timeval {
    133 	netbsd32_long	tv_sec;		/* seconds */
    134 	netbsd32_long	tv_usec;	/* and microseconds */
    135 };
    136 
    137 typedef netbsd32_pointer_t netbsd32_timezonep_t;
    138 struct netbsd32_timezone {
    139 	int	tz_minuteswest;	/* minutes west of Greenwich */
    140 	int	tz_dsttime;	/* type of dst correction */
    141 };
    142 
    143 typedef netbsd32_pointer_t netbsd32_itimervalp_t;
    144 struct	netbsd32_itimerval {
    145 	struct	netbsd32_timeval it_interval;	/* timer interval */
    146 	struct	netbsd32_timeval it_value;	/* current value */
    147 };
    148 
    149 /* from <sys/mount.h> */
    150 typedef netbsd32_pointer_t netbsd32_fidp_t;
    151 
    152 typedef netbsd32_pointer_t netbsd32_fhandlep_t;
    153 
    154 typedef netbsd32_pointer_t netbsd32_statfsp_t;
    155 struct netbsd32_statfs {
    156 	short	f_type;			/* type of file system */
    157 	u_short	f_flags;		/* copy of mount flags */
    158 	netbsd32_long	f_bsize;	/* fundamental file system block size */
    159 	netbsd32_long	f_iosize;	/* optimal transfer block size */
    160 	netbsd32_long	f_blocks;	/* total data blocks in file system */
    161 	netbsd32_long	f_bfree;	/* free blocks in fs */
    162 	netbsd32_long	f_bavail;	/* free blocks avail to non-superuser */
    163 	netbsd32_long	f_files;	/* total file nodes in file system */
    164 	netbsd32_long	f_ffree;	/* free file nodes in fs */
    165 	fsid_t	f_fsid;			/* file system id */
    166 	uid_t	f_owner;		/* user that mounted the file system */
    167 	netbsd32_long	f_spare[4];	/* spare for later */
    168 	char	f_fstypename[MFSNAMELEN]; /* fs type name */
    169 	char	f_mntonname[MNAMELEN];	  /* directory on which mounted */
    170 	char	f_mntfromname[MNAMELEN];  /* mounted file system */
    171 };
    172 
    173 /* from <sys/poll.h> */
    174 typedef netbsd32_pointer_t netbsd32_pollfdp_t;
    175 
    176 /* from <sys/resource.h> */
    177 typedef netbsd32_pointer_t netbsd32_rusagep_t;
    178 struct	netbsd32_rusage {
    179 	struct netbsd32_timeval ru_utime;/* user time used */
    180 	struct netbsd32_timeval ru_stime;/* system time used */
    181 	netbsd32_long	ru_maxrss;	/* max resident set size */
    182 	netbsd32_long	ru_ixrss;	/* integral shared memory size */
    183 	netbsd32_long	ru_idrss;	/* integral unshared data " */
    184 	netbsd32_long	ru_isrss;	/* integral unshared stack " */
    185 	netbsd32_long	ru_minflt;	/* page reclaims */
    186 	netbsd32_long	ru_majflt;	/* page faults */
    187 	netbsd32_long	ru_nswap;	/* swaps */
    188 	netbsd32_long	ru_inblock;	/* block input operations */
    189 	netbsd32_long	ru_oublock;	/* block output operations */
    190 	netbsd32_long	ru_msgsnd;	/* messages sent */
    191 	netbsd32_long	ru_msgrcv;	/* messages received */
    192 	netbsd32_long	ru_nsignals;	/* signals received */
    193 	netbsd32_long	ru_nvcsw;	/* voluntary context switches */
    194 	netbsd32_long	ru_nivcsw;	/* involuntary " */
    195 };
    196 
    197 typedef netbsd32_pointer_t netbsd32_orlimitp_t;
    198 
    199 typedef netbsd32_pointer_t netbsd32_rlimitp_t;
    200 
    201 struct netbsd32_loadavg {
    202 	fixpt_t	ldavg[3];
    203 	netbsd32_long	fscale;
    204 };
    205 
    206 /* from <sys/ipc.h> */
    207 typedef netbsd32_pointer_t netbsd32_ipc_permp_t;
    208 struct netbsd32_ipc_perm {
    209 	ushort	cuid;		/* creator user id */
    210 	ushort	cgid;		/* creator group id */
    211 	ushort	uid;		/* user id */
    212 	ushort	gid;		/* group id */
    213 	ushort	mode;		/* r/w permission */
    214 	ushort	_seq;		/* sequence # (to generate unique msg/sem/shm id) */
    215 	netbsd32_key_t	_key;	/* user specified msg/sem/shm key */
    216 };
    217 struct netbsd32_ipc_perm14 {
    218 	ushort	cuid;		/* creator user id */
    219 	ushort	cgid;		/* creator group id */
    220 	ushort	uid;		/* user id */
    221 	ushort	gid;		/* group id */
    222 	ushort	mode;		/* r/w permission */
    223 	ushort	seq;		/* sequence # (to generate unique msg/sem/shm id) */
    224 	netbsd32_key_t	key;	/* user specified msg/sem/shm key */
    225 };
    226 
    227 /* from <sys/msg.h> */
    228 typedef netbsd32_pointer_t netbsd32_msgp_t;
    229 struct netbsd32_msg {
    230 	netbsd32_msgp_t msg_next;	/* next msg in the chain */
    231 	netbsd32_long	msg_type;	/* type of this message */
    232     				/* >0 -> type of this message */
    233     				/* 0 -> free header */
    234 	u_short	msg_ts;		/* size of this message */
    235 	short	msg_spot;	/* location of start of msg in buffer */
    236 };
    237 
    238 typedef u_int32_t netbsd32_msqid_dsp_t;
    239 typedef u_int32_t netbsd32_msgqnum_t;
    240 typedef netbsd32_size_t netbsd32_msglen_t;
    241 
    242 struct netbsd32_msqid_ds {
    243 	struct netbsd32_ipc_perm	msg_perm;	/* operation permission strucure */
    244 	netbsd32_msgqnum_t	msg_qnum;	/* number of messages in the queue */
    245 	netbsd32_msglen_t	msg_qbytes;	/* max # of bytes in the queue */
    246 	pid_t		msg_lspid;	/* process ID of last msgsend() */
    247 	pid_t		msg_lrpid;	/* process ID of last msgrcv() */
    248 	netbsd32_time_t		msg_stime;	/* time of last msgsend() */
    249 	netbsd32_time_t		msg_rtime;	/* time of last msgrcv() */
    250 	netbsd32_time_t		msg_ctime;	/* time of last change */
    251 
    252 	/*
    253 	 * These members are private and used only in the internal
    254 	 * implementation of this interface.
    255 	 */
    256 	netbsd32_msgp_t _msg_first;	/* first message in the queue */
    257 	netbsd32_msgp_t	_msg_last;	/* last message in the queue */
    258 	netbsd32_msglen_t	_msg_cbytes;	/* # of bytes currently in queue */
    259 };
    260 struct netbsd32_msqid_ds14 {
    261 	struct	netbsd32_ipc_perm14 msg_perm;	/* msg queue permission bits */
    262 	netbsd32_msgp_t	msg_first;	/* first message in the queue */
    263 	netbsd32_msgp_t	msg_last;	/* last message in the queue */
    264 	netbsd32_u_long	msg_cbytes;	/* number of bytes in use on the queue */
    265 	netbsd32_u_long	msg_qnum;	/* number of msgs in the queue */
    266 	netbsd32_u_long	msg_qbytes;	/* max # of bytes on the queue */
    267 	pid_t msg_lspid;		/* pid of last msgsnd() */
    268 	pid_t msg_lrpid;		/* pid of last msgrcv() */
    269 	netbsd32_time_t	msg_stime;		/* time of last msgsnd() */
    270 	netbsd32_long	msg_pad1;
    271 	netbsd32_time_t	msg_rtime;		/* time of last msgrcv() */
    272 	netbsd32_long	msg_pad2;
    273 	netbsd32_time_t	msg_ctime;		/* time of last msgctl() */
    274 	netbsd32_long	msg_pad3;
    275 	netbsd32_long	msg_pad4[4];
    276 };
    277 
    278 /* from <sys/sem.h> */
    279 typedef netbsd32_pointer_t netbsd32_semp_t;
    280 
    281 typedef u_int32_t netbsd32_semid_dsp_t;
    282 struct netbsd32_semid_ds {
    283 	struct netbsd32_ipc_perm	sem_perm;/* operation permission struct */
    284 	unsigned short	sem_nsems;	/* number of sems in set */
    285 	netbsd32_time_t		sem_otime;	/* last operation time */
    286 	netbsd32_time_t		sem_ctime;	/* last change time */
    287 
    288 	/*
    289 	 * These members are private and used only in the internal
    290 	 * implementation of this interface.
    291 	 */
    292 	netbsd32_semp_t	_sem_base;	/* pointer to first semaphore in set */
    293 };
    294 
    295 struct netbsd32_semid_ds14 {
    296 	struct netbsd32_ipc_perm14	sem_perm;/* operation permission struct */
    297 	netbsd32_semp_t	sem_base;	/* pointer to first semaphore in set */
    298 	unsigned short	sem_nsems;	/* number of sems in set */
    299 	netbsd32_time_t	sem_otime;		/* last operation time */
    300 	netbsd32_long	sem_pad1;	/* SVABI/386 says I need this here */
    301 	netbsd32_time_t	sem_ctime;		/* last change time */
    302 					/* Times measured in secs since */
    303 					/* 00:00:00 GMT, Jan. 1, 1970 */
    304 	netbsd32_long	sem_pad2;	/* SVABI/386 says I need this here */
    305 	netbsd32_long	sem_pad3[4];	/* SVABI/386 says I need this here */
    306 };
    307 
    308 typedef u_int32_t netbsd32_semunu_t;
    309 union netbsd32_semun {
    310 	int	val;		/* value for SETVAL */
    311 	netbsd32_semid_dsp_t buf; /* buffer for IPC_STAT & IPC_SET */
    312 	netbsd32_u_shortp array;	/* array for GETALL & SETALL */
    313 };
    314 
    315 typedef netbsd32_pointer_t netbsd32_sembufp_t;
    316 struct netbsd32_sembuf {
    317 	unsigned short	sem_num;	/* semaphore # */
    318 	short		sem_op;		/* semaphore operation */
    319 	short		sem_flg;	/* operation flags */
    320 };
    321 
    322 /* from <sys/shm.h> */
    323 typedef u_int32_t netbsd32_shmid_dsp_t;
    324 struct netbsd32_shmid_ds {
    325 	struct netbsd32_ipc_perm	shm_perm; /* operation permission structure */
    326 	size_t		shm_segsz;	/* size of segment in bytes */
    327 	pid_t		shm_lpid;	/* process ID of last shm op */
    328 	pid_t		shm_cpid;	/* process ID of creator */
    329 	shmatt_t	shm_nattch;	/* number of current attaches */
    330 	netbsd32_time_t	shm_atime;	/* time of last shmat() */
    331 	netbsd32_time_t	shm_dtime;	/* time of last shmdt() */
    332 	netbsd32_time_t	shm_ctime;	/* time of last change by shmctl() */
    333 	netbsd32_voidp	_shm_internal;	/* sysv stupidity */
    334 };
    335 
    336 struct netbsd32_shmid_ds14 {
    337 	struct netbsd32_ipc_perm14	shm_perm; /* operation permission structure */
    338 	int		shm_segsz;	/* size of segment in bytes */
    339 	pid_t		shm_lpid;	/* process ID of last shm op */
    340 	pid_t		shm_cpid;	/* process ID of creator */
    341 	short		shm_nattch;	/* number of current attaches */
    342 	netbsd32_time_t		shm_atime;	/* time of last shmat() */
    343 	netbsd32_time_t		shm_dtime;	/* time of last shmdt() */
    344 	netbsd32_time_t		shm_ctime;	/* time of last change by shmctl() */
    345 	netbsd32_voidp	_shm_internal;	/* sysv stupidity */
    346 };
    347 
    348 /* from <sys/signal.h> */
    349 typedef netbsd32_pointer_t netbsd32_sigsetp_t;
    350 typedef netbsd32_pointer_t netbsd32_sigactionp_t;
    351 struct	netbsd32_sigaction {
    352 	netbsd32_voidp sa_handler;	/* signal handler */
    353 	sigset_t sa_mask;		/* signal mask to apply */
    354 	int	sa_flags;		/* see signal options below */
    355 };
    356 
    357 typedef netbsd32_pointer_t netbsd32_sigaltstack13p_t;
    358 struct netbsd32_sigaltstack13 {
    359 	netbsd32_charp	ss_sp;			/* signal stack base */
    360 	int	ss_size;		/* signal stack length */
    361 	int	ss_flags;		/* SS_DISABLE and/or SS_ONSTACK */
    362 };
    363 
    364 typedef netbsd32_pointer_t netbsd32_sigaltstackp_t;
    365 struct netbsd32_sigaltstack {
    366 	netbsd32_voidp	ss_sp;			/* signal stack base */
    367 	netbsd32_size_t	ss_size;		/* signal stack length */
    368 	int	ss_flags;		/* SS_DISABLE and/or SS_ONSTACK */
    369 };
    370 
    371 typedef netbsd32_pointer_t netbsd32_sigstackp_t;
    372 struct	netbsd32_sigstack {
    373 	netbsd32_voidp	ss_sp;			/* signal stack pointer */
    374 	int	ss_onstack;		/* current status */
    375 };
    376 
    377 typedef netbsd32_pointer_t netbsd32_sigvecp_t;
    378 struct	netbsd32_sigvec {
    379 	netbsd32_voidp sv_handler;	/* signal handler */
    380 	int	sv_mask;		/* signal mask to apply */
    381 	int	sv_flags;		/* see signal options below */
    382 };
    383 
    384 /* from <sys/socket.h> */
    385 typedef netbsd32_pointer_t netbsd32_sockaddrp_t;
    386 typedef netbsd32_pointer_t netbsd32_osockaddrp_t;
    387 
    388 typedef netbsd32_pointer_t netbsd32_msghdrp_t;
    389 struct netbsd32_msghdr {
    390 	netbsd32_caddr_t	msg_name;		/* optional address */
    391 	u_int	msg_namelen;		/* size of address */
    392 	netbsd32_iovecp_t msg_iov;		/* scatter/gather array */
    393 	u_int	msg_iovlen;		/* # elements in msg_iov */
    394 	netbsd32_caddr_t	msg_control;		/* ancillary data, see below */
    395 	u_int	msg_controllen;		/* ancillary data buffer len */
    396 	int	msg_flags;		/* flags on received message */
    397 };
    398 
    399 typedef netbsd32_pointer_t netbsd32_omsghdrp_t;
    400 struct netbsd32_omsghdr {
    401 	netbsd32_caddr_t	msg_name;		/* optional address */
    402 	int	msg_namelen;		/* size of address */
    403 	netbsd32_iovecp_t msg_iov;		/* scatter/gather array */
    404 	int	msg_iovlen;		/* # elements in msg_iov */
    405 	netbsd32_caddr_t	msg_accrights;		/* access rights sent/received */
    406 	int	msg_accrightslen;
    407 };
    408 
    409 /* from <sys/stat.h> */
    410 typedef netbsd32_pointer_t netbsd32_stat12p_t;
    411 struct netbsd32_stat12 {			/* NetBSD-1.2 stat struct */
    412 	dev_t	  st_dev;		/* inode's device */
    413 	ino_t	  st_ino;		/* inode's number */
    414 	u_int16_t st_mode;		/* inode protection mode */
    415 	u_int16_t st_nlink;		/* number of hard links */
    416 	uid_t	  st_uid;		/* user ID of the file's owner */
    417 	gid_t	  st_gid;		/* group ID of the file's group */
    418 	dev_t	  st_rdev;		/* device type */
    419 	struct	  netbsd32_timespec st_atimespec;/* time of last access */
    420 	struct	  netbsd32_timespec st_mtimespec;/* time of last data modification */
    421 	struct	  netbsd32_timespec st_ctimespec;/* time of last file status change */
    422 	off_t	  st_size;		/* file size, in bytes */
    423 	int64_t	  st_blocks;		/* blocks allocated for file */
    424 	u_int32_t st_blksize;		/* optimal blocksize for I/O */
    425 	u_int32_t st_flags;		/* user defined flags for file */
    426 	u_int32_t st_gen;		/* file generation number */
    427 	int32_t	  st_lspare;
    428 	int64_t	  st_qspare[2];
    429 };
    430 
    431 typedef netbsd32_pointer_t netbsd32_stat43p_t;
    432 struct netbsd32_stat43 {			/* BSD-4.3 stat struct */
    433 	u_int16_t st_dev;		/* inode's device */
    434 	ino_t	  st_ino;		/* inode's number */
    435 	u_int16_t st_mode;		/* inode protection mode */
    436 	u_int16_t st_nlink;		/* number of hard links */
    437 	u_int16_t st_uid;		/* user ID of the file's owner */
    438 	u_int16_t st_gid;		/* group ID of the file's group */
    439 	u_int16_t st_rdev;		/* device type */
    440 	int32_t	  st_size;		/* file size, in bytes */
    441 	struct	  netbsd32_timespec st_atimespec;/* time of last access */
    442 	struct	  netbsd32_timespec st_mtimespec;/* time of last data modification */
    443 	struct	  netbsd32_timespec st_ctimespec;/* time of last file status change */
    444 	int32_t	  st_blksize;		/* optimal blocksize for I/O */
    445 	int32_t	  st_blocks;		/* blocks allocated for file */
    446 	u_int32_t st_flags;		/* user defined flags for file */
    447 	u_int32_t st_gen;		/* file generation number */
    448 };
    449 typedef netbsd32_pointer_t netbsd32_statp_t;
    450 struct netbsd32_stat {
    451 	dev_t	  st_dev;		/* inode's device */
    452 	ino_t	  st_ino;		/* inode's number */
    453 	mode_t	  st_mode;		/* inode protection mode */
    454 	nlink_t	  st_nlink;		/* number of hard links */
    455 	uid_t	  st_uid;		/* user ID of the file's owner */
    456 	gid_t	  st_gid;		/* group ID of the file's group */
    457 	dev_t	  st_rdev;		/* device type */
    458 	struct	  netbsd32_timespec st_atimespec;/* time of last access */
    459 	struct	  netbsd32_timespec st_mtimespec;/* time of last data modification */
    460 	struct	  netbsd32_timespec st_ctimespec;/* time of last file status change */
    461 	off_t	  st_size;		/* file size, in bytes */
    462 	blkcnt_t  st_blocks;		/* blocks allocated for file */
    463 	blksize_t st_blksize;		/* optimal blocksize for I/O */
    464 	u_int32_t st_flags;		/* user defined flags for file */
    465 	u_int32_t st_gen;		/* file generation number */
    466 	int64_t	  st_qspare[2];
    467 }
    468 #ifdef __x86_64__
    469 __attribute__((packed))
    470 #endif
    471 ;
    472 
    473 /* from <sys/timex.h> */
    474 typedef netbsd32_pointer_t netbsd32_ntptimevalp_t;
    475 struct netbsd32_ntptimeval {
    476 	struct netbsd32_timeval time;	/* current time (ro) */
    477 	netbsd32_long maxerror;	/* maximum error (us) (ro) */
    478 	netbsd32_long esterror;	/* estimated error (us) (ro) */
    479 };
    480 
    481 typedef netbsd32_pointer_t netbsd32_timexp_t;
    482 struct netbsd32_timex {
    483 	unsigned int modes;	/* clock mode bits (wo) */
    484 	netbsd32_long offset;	/* time offset (us) (rw) */
    485 	netbsd32_long freq;	/* frequency offset (scaled ppm) (rw) */
    486 	netbsd32_long maxerror;	/* maximum error (us) (rw) */
    487 	netbsd32_long esterror;	/* estimated error (us) (rw) */
    488 	int status;		/* clock status bits (rw) */
    489 	netbsd32_long constant;	/* pll time constant (rw) */
    490 	netbsd32_long precision;	/* clock precision (us) (ro) */
    491 	netbsd32_long tolerance;	/* clock frequency tolerance (scaled
    492 				 * ppm) (ro) */
    493 	/*
    494 	 * The following read-only structure members are implemented
    495 	 * only if the PPS signal discipline is configured in the
    496 	 * kernel.
    497 	 */
    498 	netbsd32_long ppsfreq;	/* pps frequency (scaled ppm) (ro) */
    499 	netbsd32_long jitter;	/* pps jitter (us) (ro) */
    500 	int shift;		/* interval duration (s) (shift) (ro) */
    501 	netbsd32_long stabil;	/* pps stability (scaled ppm) (ro) */
    502 	netbsd32_long jitcnt;	/* jitter limit exceeded (ro) */
    503 	netbsd32_long calcnt;	/* calibration intervals (ro) */
    504 	netbsd32_long errcnt;	/* calibration errors (ro) */
    505 	netbsd32_long stbcnt;	/* stability limit exceeded (ro) */
    506 };
    507 
    508 /* from <ufs/lfs/lfs.h> */
    509 typedef netbsd32_pointer_t netbsd32_block_infop_t;  /* XXX broken */
    510 
    511 /* from <sys/utsname.h> */
    512 typedef netbsd32_pointer_t netbsd32_utsnamep_t;
    513 
    514 /* from <compat/common/kern_info_09.c> */
    515 typedef netbsd32_pointer_t netbsd32_outsnamep_t;
    516 
    517 /* from <arch/sparc{,64}/include/vuid_event.h> */
    518 typedef struct firm_event32 {
    519 	u_short	id;		/* key or MS_* or LOC_[XY]_DELTA */
    520 	u_short	pad;		/* unused, at least by X11 */
    521 	int	value;		/* VKEY_{UP,DOWN} or locator delta */
    522 	struct netbsd32_timeval time;
    523 } Firm_event32;
    524 
    525 /*
    526  * here are some macros to convert between netbsd32 and sparc64 types.
    527  * note that they do *NOT* act like good macros and put ()'s around all
    528  * arguments cuz this _breaks_ SCARG().
    529  */
    530 #define NETBSD32TO64(s32uap, uap, name) \
    531 	    SCARG(uap, name) = SCARG(s32uap, name)
    532 #define NETBSD32TOP(s32uap, uap, name, type) \
    533 	    SCARG(uap, name) = (type *)NETBSD32PTR64(SCARG(s32uap, name))
    534 #define NETBSD32TOX(s32uap, uap, name, type) \
    535 	    SCARG(uap, name) = (type)SCARG(s32uap, name)
    536 #define NETBSD32TOX64(s32uap, uap, name, type) \
    537 	    SCARG(uap, name) = (type)(long)SCARG(s32uap, name)
    538 
    539 /* and some standard versions */
    540 #define	NETBSD32TO64_UAP(name)		NETBSD32TO64(uap, &ua, name);
    541 #define	NETBSD32TOP_UAP(name, type)	NETBSD32TOP(uap, &ua, name, type);
    542 #define	NETBSD32TOX_UAP(name, type)	NETBSD32TOX(uap, &ua, name, type);
    543 #define	NETBSD32TOX64_UAP(name, type)	NETBSD32TOX64(uap, &ua, name, type);
    544 
    545 int	coredump_netbsd32(struct proc *, struct vnode *, struct ucred *);
    546 
    547 /*
    548  * random other stuff
    549  */
    550 #include <compat/common/compat_util.h>
    551 
    552 void netbsd32_from_stat43 __P((struct stat43 *, struct netbsd32_stat43 *));
    553 int netbsd32_execve2(struct proc *, struct sys_execve_args *, register_t *);
    554 
    555 #endif /* _COMPAT_NETBSD32_NETBSD32_H_ */
    556