Home | History | Annotate | Line # | Download | only in netbsd32
netbsd32_conv.h revision 1.7
      1 /*	$NetBSD: netbsd32_conv.h,v 1.7 2005/07/23 21:51:29 cube 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_CONV_H_
     32 #define _COMPAT_NETBSD32_NETBSD32_CONV_H_
     33 
     34 /*
     35  * Though COMPAT_OLDSOCK is needed only for COMPAT_43, SunOS, Linux,
     36  * HP-UX, FreeBSD, Ultrix, OSF1, we define it unconditionally so that
     37  * this would be LKM-safe.
     38  */
     39 #define COMPAT_OLDSOCK /* used by <sys/socket.h> */
     40 
     41 #include <sys/param.h>
     42 #include <sys/systm.h>
     43 #include <sys/kernel.h>
     44 #include <sys/ipc.h>
     45 #include <sys/msg.h>
     46 #define msg __msg /* Don't ask me! */
     47 #include <sys/sem.h>
     48 #include <sys/shm.h>
     49 #include <sys/socket.h>
     50 #include <sys/stat.h>
     51 #include <sys/time.h>
     52 #include <sys/timex.h>
     53 
     54 #include <compat/netbsd32/netbsd32.h>
     55 
     56 static __inline void netbsd32_from_timeval __P((const struct timeval *, struct netbsd32_timeval *));
     57 static __inline void netbsd32_to_timeval __P((const struct netbsd32_timeval *, struct timeval *));
     58 static __inline void netbsd32_from_itimerval __P((const struct itimerval *, struct netbsd32_itimerval *));
     59 static __inline void netbsd32_to_itimerval __P((const struct netbsd32_itimerval *, struct itimerval *));
     60 static __inline void netbsd32_to_timespec __P((const struct netbsd32_timespec *, struct timespec *));
     61 static __inline void netbsd32_from_timespec __P((const struct timespec *, struct netbsd32_timespec *));
     62 static __inline void netbsd32_from_rusage __P((const struct rusage *, struct netbsd32_rusage *));
     63 static __inline void netbsd32_to_rusage __P((const struct netbsd32_rusage *, struct rusage *));
     64 static __inline int netbsd32_to_iovecin __P((const struct netbsd32_iovec *, struct iovec *, int));
     65 static __inline void netbsd32_to_msghdr __P((const struct netbsd32_msghdr *, struct msghdr *));
     66 static __inline void netbsd32_from_msghdr __P((struct netbsd32_msghdr *, const struct msghdr *));
     67 static __inline void netbsd32_from_statvfs __P((const struct statvfs *, struct netbsd32_statvfs *));
     68 static __inline void netbsd32_from_timex __P((const struct timex *, struct netbsd32_timex *));
     69 static __inline void netbsd32_to_timex __P((const struct netbsd32_timex *, struct timex *));
     70 static __inline void netbsd32_from___stat13 __P((const struct stat *, struct netbsd32_stat *));
     71 static __inline void netbsd32_to_ipc_perm __P((const struct netbsd32_ipc_perm *, struct ipc_perm *));
     72 static __inline void netbsd32_from_ipc_perm __P((const struct ipc_perm *, struct netbsd32_ipc_perm *));
     73 static __inline void netbsd32_to_msg __P((const struct netbsd32_msg *, struct msg *));
     74 static __inline void netbsd32_from_msg __P((const struct msg *, struct netbsd32_msg *));
     75 static __inline void netbsd32_to_msqid_ds __P((const struct netbsd32_msqid_ds *, struct msqid_ds *));
     76 static __inline void netbsd32_from_msqid_ds __P((const struct msqid_ds *, struct netbsd32_msqid_ds *));
     77 static __inline void netbsd32_to_shmid_ds __P((const struct netbsd32_shmid_ds *, struct shmid_ds *));
     78 static __inline void netbsd32_from_shmid_ds __P((const struct shmid_ds *, struct netbsd32_shmid_ds *));
     79 static __inline void netbsd32_to_semid_ds __P((const struct  netbsd32_semid_ds *, struct  semid_ds *));
     80 static __inline void netbsd32_from_semid_ds __P((const struct  semid_ds *, struct  netbsd32_semid_ds *));
     81 static __inline void netbsd32_from_loadavg __P((struct netbsd32_loadavg *, const struct loadavg *));
     82 static __inline void netbsd32_to_sigevent(const struct netbsd32_sigevent *, struct sigevent *);
     83 
     84 /* converters for structures that we need */
     85 static __inline void
     86 netbsd32_from_timeval(tv, tv32)
     87 	const struct timeval *tv;
     88 	struct netbsd32_timeval *tv32;
     89 {
     90 
     91 	tv32->tv_sec = (netbsd32_long)tv->tv_sec;
     92 	tv32->tv_usec = (netbsd32_long)tv->tv_usec;
     93 }
     94 
     95 static __inline void
     96 netbsd32_to_timeval(tv32, tv)
     97 	const struct netbsd32_timeval *tv32;
     98 	struct timeval *tv;
     99 {
    100 
    101 	tv->tv_sec = (long)tv32->tv_sec;
    102 	tv->tv_usec = (long)tv32->tv_usec;
    103 }
    104 
    105 static __inline void
    106 netbsd32_from_itimerval(itv, itv32)
    107 	const struct itimerval *itv;
    108 	struct netbsd32_itimerval *itv32;
    109 {
    110 
    111 	netbsd32_from_timeval(&itv->it_interval,
    112 			     &itv32->it_interval);
    113 	netbsd32_from_timeval(&itv->it_value,
    114 			     &itv32->it_value);
    115 }
    116 
    117 static __inline void
    118 netbsd32_to_itimerval(itv32, itv)
    119 	const struct netbsd32_itimerval *itv32;
    120 	struct itimerval *itv;
    121 {
    122 
    123 	netbsd32_to_timeval(&itv32->it_interval, &itv->it_interval);
    124 	netbsd32_to_timeval(&itv32->it_value, &itv->it_value);
    125 }
    126 
    127 static __inline void
    128 netbsd32_to_timespec(s32p, p)
    129 	const struct netbsd32_timespec *s32p;
    130 	struct timespec *p;
    131 {
    132 
    133 	p->tv_sec = (time_t)s32p->tv_sec;
    134 	p->tv_nsec = (long)s32p->tv_nsec;
    135 }
    136 
    137 static __inline void
    138 netbsd32_from_timespec(p, s32p)
    139 	const struct timespec *p;
    140 	struct netbsd32_timespec *s32p;
    141 {
    142 
    143 	s32p->tv_sec = (netbsd32_time_t)p->tv_sec;
    144 	s32p->tv_nsec = (netbsd32_long)p->tv_nsec;
    145 }
    146 
    147 static __inline void
    148 netbsd32_from_rusage(rup, ru32p)
    149 	const struct rusage *rup;
    150 	struct netbsd32_rusage *ru32p;
    151 {
    152 
    153 	netbsd32_from_timeval(&rup->ru_utime, &ru32p->ru_utime);
    154 	netbsd32_from_timeval(&rup->ru_stime, &ru32p->ru_stime);
    155 #define C(var)	ru32p->var = (netbsd32_long)rup->var
    156 	C(ru_maxrss);
    157 	C(ru_ixrss);
    158 	C(ru_idrss);
    159 	C(ru_isrss);
    160 	C(ru_minflt);
    161 	C(ru_majflt);
    162 	C(ru_nswap);
    163 	C(ru_inblock);
    164 	C(ru_oublock);
    165 	C(ru_msgsnd);
    166 	C(ru_msgrcv);
    167 	C(ru_nsignals);
    168 	C(ru_nvcsw);
    169 	C(ru_nivcsw);
    170 #undef C
    171 }
    172 
    173 static __inline void
    174 netbsd32_to_rusage(ru32p, rup)
    175 	const struct netbsd32_rusage *ru32p;
    176 	struct rusage *rup;
    177 {
    178 
    179 	netbsd32_to_timeval(&ru32p->ru_utime, &rup->ru_utime);
    180 	netbsd32_to_timeval(&ru32p->ru_stime, &rup->ru_stime);
    181 #define C(var)	rup->var = (long)ru32p->var
    182 	C(ru_maxrss);
    183 	C(ru_ixrss);
    184 	C(ru_idrss);
    185 	C(ru_isrss);
    186 	C(ru_minflt);
    187 	C(ru_majflt);
    188 	C(ru_nswap);
    189 	C(ru_inblock);
    190 	C(ru_oublock);
    191 	C(ru_msgsnd);
    192 	C(ru_msgrcv);
    193 	C(ru_nsignals);
    194 	C(ru_nvcsw);
    195 	C(ru_nivcsw);
    196 #undef C
    197 }
    198 
    199 static __inline int
    200 netbsd32_to_iovecin(iov32p, iovp, len)
    201 	const struct netbsd32_iovec *iov32p;
    202 	struct iovec *iovp;
    203 	int len;
    204 {
    205 	int i, error=0;
    206 	u_int32_t iov_base;
    207 	u_int32_t iov_len;
    208 	/*
    209 	 * We could allocate an iov32p, do a copyin, and translate
    210 	 * each field and then free it all up, or we could copyin
    211 	 * each field separately.  I'm doing the latter to reduce
    212 	 * the number of MALLOC()s.
    213 	 */
    214 	for (i = 0; i < len; i++, iovp++, iov32p++) {
    215 		if ((error = copyin(&iov32p->iov_base, &iov_base, sizeof(iov_base))))
    216 		    return (error);
    217 		if ((error = copyin(&iov32p->iov_len, &iov_len, sizeof(iov_len))))
    218 		    return (error);
    219 		iovp->iov_base = (void *)(u_long)iov_base;
    220 		iovp->iov_len = (size_t)iov_len;
    221 	}
    222 	return error;
    223 }
    224 
    225 /* msg_iov must be done separately */
    226 static __inline void
    227 netbsd32_to_msghdr(mhp32, mhp)
    228 	const struct netbsd32_msghdr *mhp32;
    229 	struct msghdr *mhp;
    230 {
    231 
    232 	mhp->msg_name = (caddr_t)(u_long)mhp32->msg_name;
    233 	mhp->msg_namelen = mhp32->msg_namelen;
    234 	mhp->msg_iovlen = (size_t)mhp32->msg_iovlen;
    235 	mhp->msg_control = (caddr_t)(u_long)mhp32->msg_control;
    236 	mhp->msg_controllen = mhp32->msg_controllen;
    237 	mhp->msg_flags = mhp32->msg_flags;
    238 }
    239 
    240 /* msg_iov must be done separately */
    241 static __inline void
    242 netbsd32_from_msghdr(mhp32, mhp)
    243 	struct netbsd32_msghdr *mhp32;
    244 	const struct msghdr *mhp;
    245 {
    246 
    247 	mhp32->msg_name = mhp32->msg_name;
    248 	mhp32->msg_namelen = mhp32->msg_namelen;
    249 	mhp32->msg_iovlen = mhp32->msg_iovlen;
    250 	mhp32->msg_control = mhp32->msg_control;
    251 	mhp32->msg_controllen = mhp->msg_controllen;
    252 	mhp32->msg_flags = mhp->msg_flags;
    253 }
    254 
    255 static __inline void
    256 netbsd32_from_statvfs(sbp, sb32p)
    257 	const struct statvfs *sbp;
    258 	struct netbsd32_statvfs *sb32p;
    259 {
    260 	sb32p->f_flag = sbp->f_flag;
    261 	sb32p->f_bsize = (netbsd32_u_long)sbp->f_bsize;
    262 	sb32p->f_frsize = (netbsd32_u_long)sbp->f_frsize;
    263 	sb32p->f_iosize = (netbsd32_u_long)sbp->f_iosize;
    264 	sb32p->f_blocks = sbp->f_blocks;
    265 	sb32p->f_bfree = sbp->f_bfree;
    266 	sb32p->f_bavail = sbp->f_bavail;
    267 	sb32p->f_bresvd = sbp->f_bresvd;
    268 	sb32p->f_files = sbp->f_files;
    269 	sb32p->f_ffree = sbp->f_ffree;
    270 	sb32p->f_favail = sbp->f_favail;
    271 	sb32p->f_fresvd = sbp->f_fresvd;
    272 	sb32p->f_syncreads = sbp->f_syncreads;
    273 	sb32p->f_syncwrites = sbp->f_syncwrites;
    274 	sb32p->f_asyncreads = sbp->f_asyncreads;
    275 	sb32p->f_asyncwrites = sbp->f_asyncwrites;
    276 	sb32p->f_fsidx = sbp->f_fsidx;
    277 	sb32p->f_fsid = (netbsd32_u_long)sbp->f_fsid;
    278 	sb32p->f_namemax = (netbsd32_u_long)sbp->f_namemax;
    279 	sb32p->f_owner = sbp->f_owner;
    280 	sb32p->f_spare[0] = 0;
    281 	sb32p->f_spare[1] = 0;
    282 	sb32p->f_spare[2] = 0;
    283 	sb32p->f_spare[3] = 0;
    284 #if 1
    285 	/* May as well do the whole batch in one go */
    286 	memcpy(sb32p->f_fstypename, sbp->f_fstypename,
    287 	    sizeof(sb32p->f_fstypename) + sizeof(sb32p->f_mntonname) +
    288 	    sizeof(sb32p->f_mntfromname));
    289 #else
    290 	/* If we want to be careful */
    291 	memcpy(sb32p->f_fstypename, sbp->f_fstypename, sizeof(sb32p->f_fstypename));
    292 	memcpy(sb32p->f_mntonname, sbp->f_mntonname, sizeof(sb32p->f_mntonname));
    293 	memcpy(sb32p->f_mntfromname, sbp->f_mntfromname, sizeof(sb32p->f_mntfromname));
    294 #endif
    295 }
    296 
    297 static __inline void
    298 netbsd32_from_timex(txp, tx32p)
    299 	const struct timex *txp;
    300 	struct netbsd32_timex *tx32p;
    301 {
    302 
    303 	tx32p->modes = txp->modes;
    304 	tx32p->offset = (netbsd32_long)txp->offset;
    305 	tx32p->freq = (netbsd32_long)txp->freq;
    306 	tx32p->maxerror = (netbsd32_long)txp->maxerror;
    307 	tx32p->esterror = (netbsd32_long)txp->esterror;
    308 	tx32p->status = txp->status;
    309 	tx32p->constant = (netbsd32_long)txp->constant;
    310 	tx32p->precision = (netbsd32_long)txp->precision;
    311 	tx32p->tolerance = (netbsd32_long)txp->tolerance;
    312 	tx32p->ppsfreq = (netbsd32_long)txp->ppsfreq;
    313 	tx32p->jitter = (netbsd32_long)txp->jitter;
    314 	tx32p->shift = txp->shift;
    315 	tx32p->stabil = (netbsd32_long)txp->stabil;
    316 	tx32p->jitcnt = (netbsd32_long)txp->jitcnt;
    317 	tx32p->calcnt = (netbsd32_long)txp->calcnt;
    318 	tx32p->errcnt = (netbsd32_long)txp->errcnt;
    319 	tx32p->stbcnt = (netbsd32_long)txp->stbcnt;
    320 }
    321 
    322 static __inline void
    323 netbsd32_to_timex(tx32p, txp)
    324 	const struct netbsd32_timex *tx32p;
    325 	struct timex *txp;
    326 {
    327 
    328 	txp->modes = tx32p->modes;
    329 	txp->offset = (long)tx32p->offset;
    330 	txp->freq = (long)tx32p->freq;
    331 	txp->maxerror = (long)tx32p->maxerror;
    332 	txp->esterror = (long)tx32p->esterror;
    333 	txp->status = tx32p->status;
    334 	txp->constant = (long)tx32p->constant;
    335 	txp->precision = (long)tx32p->precision;
    336 	txp->tolerance = (long)tx32p->tolerance;
    337 	txp->ppsfreq = (long)tx32p->ppsfreq;
    338 	txp->jitter = (long)tx32p->jitter;
    339 	txp->shift = tx32p->shift;
    340 	txp->stabil = (long)tx32p->stabil;
    341 	txp->jitcnt = (long)tx32p->jitcnt;
    342 	txp->calcnt = (long)tx32p->calcnt;
    343 	txp->errcnt = (long)tx32p->errcnt;
    344 	txp->stbcnt = (long)tx32p->stbcnt;
    345 }
    346 
    347 static __inline void
    348 netbsd32_from___stat13(sbp, sb32p)
    349 	const struct stat *sbp;
    350 	struct netbsd32_stat *sb32p;
    351 {
    352 	sb32p->st_dev = sbp->st_dev;
    353 	sb32p->st_ino = sbp->st_ino;
    354 	sb32p->st_mode = sbp->st_mode;
    355 	sb32p->st_nlink = sbp->st_nlink;
    356 	sb32p->st_uid = sbp->st_uid;
    357 	sb32p->st_gid = sbp->st_gid;
    358 	sb32p->st_rdev = sbp->st_rdev;
    359 	if (sbp->st_size < (quad_t)1 << 32)
    360 		sb32p->st_size = sbp->st_size;
    361 	else
    362 		sb32p->st_size = -2;
    363 	sb32p->st_atimespec.tv_sec = (netbsd32_time_t)sbp->st_atimespec.tv_sec;
    364 	sb32p->st_atimespec.tv_nsec = (netbsd32_long)sbp->st_atimespec.tv_nsec;
    365 	sb32p->st_mtimespec.tv_sec = (netbsd32_time_t)sbp->st_mtimespec.tv_sec;
    366 	sb32p->st_mtimespec.tv_nsec = (netbsd32_long)sbp->st_mtimespec.tv_nsec;
    367 	sb32p->st_ctimespec.tv_sec = (netbsd32_time_t)sbp->st_ctimespec.tv_sec;
    368 	sb32p->st_ctimespec.tv_nsec = (netbsd32_long)sbp->st_ctimespec.tv_nsec;
    369 	sb32p->st_blksize = sbp->st_blksize;
    370 	sb32p->st_blocks = sbp->st_blocks;
    371 	sb32p->st_flags = sbp->st_flags;
    372 	sb32p->st_gen = sbp->st_gen;
    373 }
    374 
    375 static __inline void
    376 netbsd32_to_ipc_perm(ip32p, ipp)
    377 	const struct netbsd32_ipc_perm *ip32p;
    378 	struct ipc_perm *ipp;
    379 {
    380 
    381 	ipp->cuid = ip32p->cuid;
    382 	ipp->cgid = ip32p->cgid;
    383 	ipp->uid = ip32p->uid;
    384 	ipp->gid = ip32p->gid;
    385 	ipp->mode = ip32p->mode;
    386 	ipp->_seq = ip32p->_seq;
    387 	ipp->_key = (key_t)ip32p->_key;
    388 }
    389 
    390 static __inline void
    391 netbsd32_from_ipc_perm(ipp, ip32p)
    392 	const struct ipc_perm *ipp;
    393 	struct netbsd32_ipc_perm *ip32p;
    394 {
    395 
    396 	ip32p->cuid = ipp->cuid;
    397 	ip32p->cgid = ipp->cgid;
    398 	ip32p->uid = ipp->uid;
    399 	ip32p->gid = ipp->gid;
    400 	ip32p->mode = ipp->mode;
    401 	ip32p->_seq = ipp->_seq;
    402 	ip32p->_key = (netbsd32_key_t)ipp->_key;
    403 }
    404 
    405 static __inline void
    406 netbsd32_to_msg(m32p, mp)
    407 	const struct netbsd32_msg *m32p;
    408 	struct msg *mp;
    409 {
    410 
    411 	mp->msg_next = (struct msg *)(u_long)m32p->msg_next;
    412 	mp->msg_type = (long)m32p->msg_type;
    413 	mp->msg_ts = m32p->msg_ts;
    414 	mp->msg_spot = m32p->msg_spot;
    415 }
    416 
    417 static __inline void
    418 netbsd32_from_msg(mp, m32p)
    419 	const struct msg *mp;
    420 	struct netbsd32_msg *m32p;
    421 {
    422 
    423 	m32p->msg_next = (netbsd32_msgp_t)(u_long)mp->msg_next;
    424 	m32p->msg_type = (netbsd32_long)mp->msg_type;
    425 	m32p->msg_ts = mp->msg_ts;
    426 	m32p->msg_spot = mp->msg_spot;
    427 }
    428 
    429 static __inline void
    430 netbsd32_to_msqid_ds(ds32p, dsp)
    431 	const struct netbsd32_msqid_ds *ds32p;
    432 	struct msqid_ds *dsp;
    433 {
    434 
    435 	netbsd32_to_ipc_perm(&ds32p->msg_perm, &dsp->msg_perm);
    436 	netbsd32_to_msg((struct netbsd32_msg *)(u_long)ds32p->_msg_first, dsp->_msg_first);
    437 	netbsd32_to_msg((struct netbsd32_msg *)(u_long)ds32p->_msg_last, dsp->_msg_last);
    438 	dsp->_msg_cbytes = (u_long)ds32p->_msg_cbytes;
    439 	dsp->msg_qnum = (u_long)ds32p->msg_qnum;
    440 	dsp->msg_qbytes = (u_long)ds32p->msg_qbytes;
    441 	dsp->msg_lspid = ds32p->msg_lspid;
    442 	dsp->msg_lrpid = ds32p->msg_lrpid;
    443 	dsp->msg_rtime = (time_t)ds32p->msg_rtime;
    444 	dsp->msg_stime = (time_t)ds32p->msg_stime;
    445 	dsp->msg_ctime = (time_t)ds32p->msg_ctime;
    446 }
    447 
    448 static __inline void
    449 netbsd32_from_msqid_ds(dsp, ds32p)
    450 	const struct msqid_ds *dsp;
    451 	struct netbsd32_msqid_ds *ds32p;
    452 {
    453 
    454 	netbsd32_from_ipc_perm(&dsp->msg_perm, &ds32p->msg_perm);
    455 	netbsd32_from_msg(dsp->_msg_first, (struct netbsd32_msg *)(u_long)ds32p->_msg_first);
    456 	netbsd32_from_msg(dsp->_msg_last, (struct netbsd32_msg *)(u_long)ds32p->_msg_last);
    457 	ds32p->_msg_cbytes = (netbsd32_u_long)dsp->_msg_cbytes;
    458 	ds32p->msg_qnum = (netbsd32_u_long)dsp->msg_qnum;
    459 	ds32p->msg_qbytes = (netbsd32_u_long)dsp->msg_qbytes;
    460 	ds32p->msg_lspid = dsp->msg_lspid;
    461 	ds32p->msg_lrpid = dsp->msg_lrpid;
    462 	ds32p->msg_rtime = dsp->msg_rtime;
    463 	ds32p->msg_stime = dsp->msg_stime;
    464 	ds32p->msg_ctime = dsp->msg_ctime;
    465 }
    466 
    467 static __inline void
    468 netbsd32_to_shmid_ds(ds32p, dsp)
    469 	const struct netbsd32_shmid_ds *ds32p;
    470 	struct shmid_ds *dsp;
    471 {
    472 
    473 	netbsd32_to_ipc_perm(&ds32p->shm_perm, &dsp->shm_perm);
    474 	dsp->shm_segsz = ds32p->shm_segsz;
    475 	dsp->shm_lpid = ds32p->shm_lpid;
    476 	dsp->shm_cpid = ds32p->shm_cpid;
    477 	dsp->shm_nattch = ds32p->shm_nattch;
    478 	dsp->shm_atime = (long)ds32p->shm_atime;
    479 	dsp->shm_dtime = (long)ds32p->shm_dtime;
    480 	dsp->shm_ctime = (long)ds32p->shm_ctime;
    481 	dsp->_shm_internal = (void *)(u_long)ds32p->_shm_internal;
    482 }
    483 
    484 static __inline void
    485 netbsd32_from_shmid_ds(dsp, ds32p)
    486 	const struct shmid_ds *dsp;
    487 	struct netbsd32_shmid_ds *ds32p;
    488 {
    489 
    490 	netbsd32_from_ipc_perm(&dsp->shm_perm, &ds32p->shm_perm);
    491 	ds32p->shm_segsz = dsp->shm_segsz;
    492 	ds32p->shm_lpid = dsp->shm_lpid;
    493 	ds32p->shm_cpid = dsp->shm_cpid;
    494 	ds32p->shm_nattch = dsp->shm_nattch;
    495 	ds32p->shm_atime = (netbsd32_long)dsp->shm_atime;
    496 	ds32p->shm_dtime = (netbsd32_long)dsp->shm_dtime;
    497 	ds32p->shm_ctime = (netbsd32_long)dsp->shm_ctime;
    498 	ds32p->_shm_internal = (netbsd32_voidp)(u_long)dsp->_shm_internal;
    499 }
    500 
    501 static __inline void
    502 netbsd32_to_semid_ds(s32dsp, dsp)
    503 	const struct  netbsd32_semid_ds *s32dsp;
    504 	struct  semid_ds *dsp;
    505 {
    506 
    507 	netbsd32_to_ipc_perm(&s32dsp->sem_perm, &dsp->sem_perm);
    508 	dsp->_sem_base = (struct __sem *)(u_long)s32dsp->_sem_base;
    509 	dsp->sem_nsems = s32dsp->sem_nsems;
    510 	dsp->sem_otime = s32dsp->sem_otime;
    511 	dsp->sem_ctime = s32dsp->sem_ctime;
    512 }
    513 
    514 static __inline void
    515 netbsd32_from_semid_ds(dsp, s32dsp)
    516 	const struct  semid_ds *dsp;
    517 	struct  netbsd32_semid_ds *s32dsp;
    518 {
    519 
    520 	netbsd32_from_ipc_perm(&dsp->sem_perm, &s32dsp->sem_perm);
    521 	s32dsp->_sem_base = (netbsd32_semp_t)(u_long)dsp->_sem_base;
    522 	s32dsp->sem_nsems = dsp->sem_nsems;
    523 	s32dsp->sem_otime = dsp->sem_otime;
    524 	s32dsp->sem_ctime = dsp->sem_ctime;
    525 }
    526 
    527 static __inline void
    528 netbsd32_from_loadavg(av32, av)
    529 	struct netbsd32_loadavg *av32;
    530 	const struct loadavg *av;
    531 {
    532 
    533 	av32->ldavg[0] = av->ldavg[0];
    534 	av32->ldavg[1] = av->ldavg[1];
    535 	av32->ldavg[2] = av->ldavg[2];
    536 	av32->fscale = (netbsd32_long)av->fscale;
    537 }
    538 
    539 static __inline void
    540 netbsd32_to_sigevent(const struct netbsd32_sigevent *ev32, struct sigevent *ev)
    541 {
    542 	ev->sigev_notify = ev32->sigev_notify;
    543 	ev->sigev_signo = ev32->sigev_signo;
    544 	/*
    545 	 * XXX sival_ptr, sigev_notify_function and
    546 	 *     sigev_notify_attributes are  currently unused
    547 	 */
    548 	ev->sigev_value.sival_int = ev32->sigev_value.sival_int;
    549 	ev->sigev_notify_function = (void *)(intptr_t)ev32->sigev_notify_function;
    550 	ev->sigev_notify_attributes = (void *)(intptr_t)ev32->sigev_notify_attributes;
    551 }
    552 
    553 #endif /* _COMPAT_NETBSD32_NETBSD32_CONV_H_ */
    554