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