1 /* $NetBSD: netbsd32_conv.h,v 1.21 2009/01/11 02:45:49 christos Exp $ */
4 * Copyright (c) 1998, 2001 Matthew R. Green
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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
29 #ifndef _COMPAT_NETBSD32_NETBSD32_CONV_H_
30 #define _COMPAT_NETBSD32_NETBSD32_CONV_H_
33 * Though COMPAT_OLDSOCK is needed only for COMPAT_43, SunOS, Linux,
34 * HP-UX, FreeBSD, Ultrix, OSF1, we define it unconditionally so that
35 * this would be module-safe.
37 #define COMPAT_OLDSOCK /* used by <sys/socket.h> */
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/kernel.h>
44 #define msg __msg /* Don't ask me! */
47 #include <sys/socket.h>
50 #include <sys/timex.h>
51 #include <sys/event.h>
53 #include <compat/sys/dirent.h>
55 #include <compat/netbsd32/netbsd32.h>
57 /* converters for structures that we need */
59 netbsd32_from_timeval50(const struct timeval
*tv
,
60 struct netbsd32_timeval50
*tv32
)
63 tv32
->tv_sec
= (netbsd32_long
)tv
->tv_sec
;
64 tv32
->tv_usec
= (netbsd32_long
)tv
->tv_usec
;
68 netbsd32_from_timeval(const struct timeval
*tv
,
69 struct netbsd32_timeval
*tv32
)
72 tv32
->tv_sec
= (time_t)tv
->tv_sec
;
73 tv32
->tv_usec
= (suseconds_t
)tv
->tv_usec
;
77 netbsd32_to_timeval50(const struct netbsd32_timeval50
*tv32
,
81 tv
->tv_sec
= (time_t)tv32
->tv_sec
;
82 tv
->tv_usec
= (suseconds_t
)tv32
->tv_usec
;
86 netbsd32_to_timeval(const struct netbsd32_timeval
*tv32
,
90 tv
->tv_sec
= (time_t)tv32
->tv_sec
;
91 tv
->tv_usec
= (suseconds_t
)tv32
->tv_usec
;
95 netbsd32_from_itimerval50(const struct itimerval
*itv
,
96 struct netbsd32_itimerval50
*itv32
)
99 netbsd32_from_timeval50(&itv
->it_interval
,
100 &itv32
->it_interval
);
101 netbsd32_from_timeval50(&itv
->it_value
,
106 netbsd32_from_itimerval(const struct itimerval
*itv
,
107 struct netbsd32_itimerval
*itv32
)
110 netbsd32_from_timeval(&itv
->it_interval
,
111 &itv32
->it_interval
);
112 netbsd32_from_timeval(&itv
->it_value
,
117 netbsd32_to_itimerval50(const struct netbsd32_itimerval50
*itv32
,
118 struct itimerval
*itv
)
121 netbsd32_to_timeval50(&itv32
->it_interval
, &itv
->it_interval
);
122 netbsd32_to_timeval50(&itv32
->it_value
, &itv
->it_value
);
126 netbsd32_to_itimerval(const struct netbsd32_itimerval
*itv32
,
127 struct itimerval
*itv
)
130 netbsd32_to_timeval(&itv32
->it_interval
, &itv
->it_interval
);
131 netbsd32_to_timeval(&itv32
->it_value
, &itv
->it_value
);
135 netbsd32_to_timespec50(const struct netbsd32_timespec50
*s32p
,
139 p
->tv_sec
= (time_t)s32p
->tv_sec
;
140 p
->tv_nsec
= (long)s32p
->tv_nsec
;
144 netbsd32_to_timespec(const struct netbsd32_timespec
*s32p
,
148 p
->tv_sec
= (time_t)s32p
->tv_sec
;
149 p
->tv_nsec
= (long)s32p
->tv_nsec
;
153 netbsd32_from_timespec50(const struct timespec
*p
,
154 struct netbsd32_timespec50
*s32p
)
157 s32p
->tv_sec
= (netbsd32_long
)p
->tv_sec
;
158 s32p
->tv_nsec
= (netbsd32_long
)p
->tv_nsec
;
162 netbsd32_from_timespec(const struct timespec
*p
,
163 struct netbsd32_timespec
*s32p
)
166 s32p
->tv_sec
= (netbsd32_long
)p
->tv_sec
;
167 s32p
->tv_nsec
= (netbsd32_long
)p
->tv_nsec
;
171 netbsd32_from_rusage(const struct rusage
*rup
,
172 struct netbsd32_rusage
*ru32p
)
175 netbsd32_from_timeval(&rup
->ru_utime
, &ru32p
->ru_utime
);
176 netbsd32_from_timeval(&rup
->ru_stime
, &ru32p
->ru_stime
);
177 #define C(var) ru32p->var = (netbsd32_long)rup->var
196 netbsd32_to_rusage(const struct netbsd32_rusage
*ru32p
,
200 netbsd32_to_timeval(&ru32p
->ru_utime
, &rup
->ru_utime
);
201 netbsd32_to_timeval(&ru32p
->ru_stime
, &rup
->ru_stime
);
202 #define C(var) rup->var = (long)ru32p->var
221 netbsd32_from_rusage50(const struct rusage
*rup
,
222 struct netbsd32_rusage50
*ru32p
)
225 netbsd32_from_timeval50(&rup
->ru_utime
, &ru32p
->ru_utime
);
226 netbsd32_from_timeval50(&rup
->ru_stime
, &ru32p
->ru_stime
);
227 #define C(var) ru32p->var = (netbsd32_long)rup->var
246 netbsd32_to_iovecin(const struct netbsd32_iovec
*iov32p
, struct iovec
*iovp
,
253 * We could allocate an iov32p, do a copyin, and translate
254 * each field and then free it all up, or we could copyin
255 * each field separately. I'm doing the latter to reduce
256 * the number of MALLOC()s.
258 for (i
= 0; i
< len
; i
++, iovp
++, iov32p
++) {
259 if ((error
= copyin(&iov32p
->iov_base
, &iov_base
, sizeof(iov_base
))))
261 if ((error
= copyin(&iov32p
->iov_len
, &iov_len
, sizeof(iov_len
))))
263 iovp
->iov_base
= (void *)(u_long
)iov_base
;
264 iovp
->iov_len
= (size_t)iov_len
;
269 /* msg_iov must be done separately */
271 netbsd32_to_msghdr(const struct netbsd32_msghdr
*mhp32
, struct msghdr
*mhp
)
274 mhp
->msg_name
= NETBSD32PTR64(mhp32
->msg_name
);
275 mhp
->msg_namelen
= mhp32
->msg_namelen
;
276 mhp
->msg_iovlen
= (size_t)mhp32
->msg_iovlen
;
277 mhp
->msg_control
= NETBSD32PTR64(mhp32
->msg_control
);
278 mhp
->msg_controllen
= mhp32
->msg_controllen
;
279 mhp
->msg_flags
= mhp32
->msg_flags
;
282 /* msg_iov must be done separately */
284 netbsd32_from_msghdr(struct netbsd32_msghdr
*mhp32
, const struct msghdr
*mhp
)
287 mhp32
->msg_name
= mhp32
->msg_name
;
288 mhp32
->msg_namelen
= mhp32
->msg_namelen
;
289 mhp32
->msg_iovlen
= mhp32
->msg_iovlen
;
290 mhp32
->msg_control
= mhp32
->msg_control
;
291 mhp32
->msg_controllen
= mhp
->msg_controllen
;
292 mhp32
->msg_flags
= mhp
->msg_flags
;
296 netbsd32_from_statvfs(const struct statvfs
*sbp
, struct netbsd32_statvfs
*sb32p
)
298 sb32p
->f_flag
= sbp
->f_flag
;
299 sb32p
->f_bsize
= (netbsd32_u_long
)sbp
->f_bsize
;
300 sb32p
->f_frsize
= (netbsd32_u_long
)sbp
->f_frsize
;
301 sb32p
->f_iosize
= (netbsd32_u_long
)sbp
->f_iosize
;
302 sb32p
->f_blocks
= sbp
->f_blocks
;
303 sb32p
->f_bfree
= sbp
->f_bfree
;
304 sb32p
->f_bavail
= sbp
->f_bavail
;
305 sb32p
->f_bresvd
= sbp
->f_bresvd
;
306 sb32p
->f_files
= sbp
->f_files
;
307 sb32p
->f_ffree
= sbp
->f_ffree
;
308 sb32p
->f_favail
= sbp
->f_favail
;
309 sb32p
->f_fresvd
= sbp
->f_fresvd
;
310 sb32p
->f_syncreads
= sbp
->f_syncreads
;
311 sb32p
->f_syncwrites
= sbp
->f_syncwrites
;
312 sb32p
->f_asyncreads
= sbp
->f_asyncreads
;
313 sb32p
->f_asyncwrites
= sbp
->f_asyncwrites
;
314 sb32p
->f_fsidx
= sbp
->f_fsidx
;
315 sb32p
->f_fsid
= (netbsd32_u_long
)sbp
->f_fsid
;
316 sb32p
->f_namemax
= (netbsd32_u_long
)sbp
->f_namemax
;
317 sb32p
->f_owner
= sbp
->f_owner
;
318 sb32p
->f_spare
[0] = 0;
319 sb32p
->f_spare
[1] = 0;
320 sb32p
->f_spare
[2] = 0;
321 sb32p
->f_spare
[3] = 0;
323 /* May as well do the whole batch in one go */
324 memcpy(sb32p
->f_fstypename
, sbp
->f_fstypename
,
325 sizeof(sb32p
->f_fstypename
) + sizeof(sb32p
->f_mntonname
) +
326 sizeof(sb32p
->f_mntfromname
));
328 /* If we want to be careful */
329 memcpy(sb32p
->f_fstypename
, sbp
->f_fstypename
, sizeof(sb32p
->f_fstypename
));
330 memcpy(sb32p
->f_mntonname
, sbp
->f_mntonname
, sizeof(sb32p
->f_mntonname
));
331 memcpy(sb32p
->f_mntfromname
, sbp
->f_mntfromname
, sizeof(sb32p
->f_mntfromname
));
336 netbsd32_from_timex(const struct timex
*txp
, struct netbsd32_timex
*tx32p
)
339 tx32p
->modes
= txp
->modes
;
340 tx32p
->offset
= (netbsd32_long
)txp
->offset
;
341 tx32p
->freq
= (netbsd32_long
)txp
->freq
;
342 tx32p
->maxerror
= (netbsd32_long
)txp
->maxerror
;
343 tx32p
->esterror
= (netbsd32_long
)txp
->esterror
;
344 tx32p
->status
= txp
->status
;
345 tx32p
->constant
= (netbsd32_long
)txp
->constant
;
346 tx32p
->precision
= (netbsd32_long
)txp
->precision
;
347 tx32p
->tolerance
= (netbsd32_long
)txp
->tolerance
;
348 tx32p
->ppsfreq
= (netbsd32_long
)txp
->ppsfreq
;
349 tx32p
->jitter
= (netbsd32_long
)txp
->jitter
;
350 tx32p
->shift
= txp
->shift
;
351 tx32p
->stabil
= (netbsd32_long
)txp
->stabil
;
352 tx32p
->jitcnt
= (netbsd32_long
)txp
->jitcnt
;
353 tx32p
->calcnt
= (netbsd32_long
)txp
->calcnt
;
354 tx32p
->errcnt
= (netbsd32_long
)txp
->errcnt
;
355 tx32p
->stbcnt
= (netbsd32_long
)txp
->stbcnt
;
359 netbsd32_to_timex(const struct netbsd32_timex
*tx32p
, struct timex
*txp
)
362 txp
->modes
= tx32p
->modes
;
363 txp
->offset
= (long)tx32p
->offset
;
364 txp
->freq
= (long)tx32p
->freq
;
365 txp
->maxerror
= (long)tx32p
->maxerror
;
366 txp
->esterror
= (long)tx32p
->esterror
;
367 txp
->status
= tx32p
->status
;
368 txp
->constant
= (long)tx32p
->constant
;
369 txp
->precision
= (long)tx32p
->precision
;
370 txp
->tolerance
= (long)tx32p
->tolerance
;
371 txp
->ppsfreq
= (long)tx32p
->ppsfreq
;
372 txp
->jitter
= (long)tx32p
->jitter
;
373 txp
->shift
= tx32p
->shift
;
374 txp
->stabil
= (long)tx32p
->stabil
;
375 txp
->jitcnt
= (long)tx32p
->jitcnt
;
376 txp
->calcnt
= (long)tx32p
->calcnt
;
377 txp
->errcnt
= (long)tx32p
->errcnt
;
378 txp
->stbcnt
= (long)tx32p
->stbcnt
;
382 netbsd32_from___stat13(const struct stat
*sbp
, struct netbsd32_stat13
*sb32p
)
384 sb32p
->st_dev
= (uint32_t)sbp
->st_dev
;
385 sb32p
->st_ino
= sbp
->st_ino
;
386 sb32p
->st_mode
= sbp
->st_mode
;
387 sb32p
->st_nlink
= sbp
->st_nlink
;
388 sb32p
->st_uid
= sbp
->st_uid
;
389 sb32p
->st_gid
= sbp
->st_gid
;
390 sb32p
->st_rdev
= (uint32_t)sbp
->st_rdev
;
391 sb32p
->st_size
= sbp
->st_size
;
392 sb32p
->st_atimespec
.tv_sec
= (int32_t)sbp
->st_atimespec
.tv_sec
;
393 sb32p
->st_atimespec
.tv_nsec
= (netbsd32_long
)sbp
->st_atimespec
.tv_nsec
;
394 sb32p
->st_mtimespec
.tv_sec
= (int32_t)sbp
->st_mtimespec
.tv_sec
;
395 sb32p
->st_mtimespec
.tv_nsec
= (netbsd32_long
)sbp
->st_mtimespec
.tv_nsec
;
396 sb32p
->st_ctimespec
.tv_sec
= (int32_t)sbp
->st_ctimespec
.tv_sec
;
397 sb32p
->st_ctimespec
.tv_nsec
= (netbsd32_long
)sbp
->st_ctimespec
.tv_nsec
;
398 sb32p
->st_blksize
= sbp
->st_blksize
;
399 sb32p
->st_blocks
= sbp
->st_blocks
;
400 sb32p
->st_flags
= sbp
->st_flags
;
401 sb32p
->st_gen
= sbp
->st_gen
;
405 netbsd32_from___stat50(const struct stat
*sbp
, struct netbsd32_stat50
*sb32p
)
407 sb32p
->st_dev
= (uint32_t)sbp
->st_dev
;
408 sb32p
->st_ino
= sbp
->st_ino
;
409 sb32p
->st_mode
= sbp
->st_mode
;
410 sb32p
->st_nlink
= sbp
->st_nlink
;
411 sb32p
->st_uid
= sbp
->st_uid
;
412 sb32p
->st_gid
= sbp
->st_gid
;
413 sb32p
->st_rdev
= (uint32_t)sbp
->st_rdev
;
414 sb32p
->st_size
= sbp
->st_size
;
415 sb32p
->st_atimespec
.tv_sec
= (int32_t)sbp
->st_atimespec
.tv_sec
;
416 sb32p
->st_atimespec
.tv_nsec
= (netbsd32_long
)sbp
->st_atimespec
.tv_nsec
;
417 sb32p
->st_mtimespec
.tv_sec
= (int32_t)sbp
->st_mtimespec
.tv_sec
;
418 sb32p
->st_mtimespec
.tv_nsec
= (netbsd32_long
)sbp
->st_mtimespec
.tv_nsec
;
419 sb32p
->st_ctimespec
.tv_sec
= (int32_t)sbp
->st_ctimespec
.tv_sec
;
420 sb32p
->st_ctimespec
.tv_nsec
= (netbsd32_long
)sbp
->st_ctimespec
.tv_nsec
;
421 sb32p
->st_blksize
= sbp
->st_blksize
;
422 sb32p
->st_blocks
= sbp
->st_blocks
;
423 sb32p
->st_flags
= sbp
->st_flags
;
424 sb32p
->st_gen
= sbp
->st_gen
;
428 netbsd32_from_stat(const struct stat
*sbp
, struct netbsd32_stat
*sb32p
)
430 sb32p
->st_dev
= sbp
->st_dev
;
431 sb32p
->st_ino
= sbp
->st_ino
;
432 sb32p
->st_mode
= sbp
->st_mode
;
433 sb32p
->st_nlink
= sbp
->st_nlink
;
434 sb32p
->st_uid
= sbp
->st_uid
;
435 sb32p
->st_gid
= sbp
->st_gid
;
436 sb32p
->st_rdev
= sbp
->st_rdev
;
437 sb32p
->st_size
= sbp
->st_size
;
438 sb32p
->st_atimespec
.tv_sec
= (netbsd32_time_t
)sbp
->st_atimespec
.tv_sec
;
439 sb32p
->st_atimespec
.tv_nsec
= (netbsd32_long
)sbp
->st_atimespec
.tv_nsec
;
440 sb32p
->st_mtimespec
.tv_sec
= (netbsd32_time_t
)sbp
->st_mtimespec
.tv_sec
;
441 sb32p
->st_mtimespec
.tv_nsec
= (netbsd32_long
)sbp
->st_mtimespec
.tv_nsec
;
442 sb32p
->st_ctimespec
.tv_sec
= (netbsd32_time_t
)sbp
->st_ctimespec
.tv_sec
;
443 sb32p
->st_ctimespec
.tv_nsec
= (netbsd32_long
)sbp
->st_ctimespec
.tv_nsec
;
444 sb32p
->st_blksize
= sbp
->st_blksize
;
445 sb32p
->st_blocks
= sbp
->st_blocks
;
446 sb32p
->st_flags
= sbp
->st_flags
;
447 sb32p
->st_gen
= sbp
->st_gen
;
451 netbsd32_to_ipc_perm(const struct netbsd32_ipc_perm
*ip32p
,
452 struct ipc_perm
*ipp
)
455 ipp
->cuid
= ip32p
->cuid
;
456 ipp
->cgid
= ip32p
->cgid
;
457 ipp
->uid
= ip32p
->uid
;
458 ipp
->gid
= ip32p
->gid
;
459 ipp
->mode
= ip32p
->mode
;
460 ipp
->_seq
= ip32p
->_seq
;
461 ipp
->_key
= (key_t
)ip32p
->_key
;
465 netbsd32_from_ipc_perm(const struct ipc_perm
*ipp
,
466 struct netbsd32_ipc_perm
*ip32p
)
469 ip32p
->cuid
= ipp
->cuid
;
470 ip32p
->cgid
= ipp
->cgid
;
471 ip32p
->uid
= ipp
->uid
;
472 ip32p
->gid
= ipp
->gid
;
473 ip32p
->mode
= ipp
->mode
;
474 ip32p
->_seq
= ipp
->_seq
;
475 ip32p
->_key
= (netbsd32_key_t
)ipp
->_key
;
479 netbsd32_to_msg(const struct netbsd32_msg
*m32p
, struct msg
*mp
)
482 mp
->msg_next
= NETBSD32PTR64(m32p
->msg_next
);
483 mp
->msg_type
= (long)m32p
->msg_type
;
484 mp
->msg_ts
= m32p
->msg_ts
;
485 mp
->msg_spot
= m32p
->msg_spot
;
489 netbsd32_from_msg(const struct msg
*mp
, struct netbsd32_msg
*m32p
)
492 NETBSD32PTR32(m32p
->msg_next
, mp
->msg_next
);
493 m32p
->msg_type
= (netbsd32_long
)mp
->msg_type
;
494 m32p
->msg_ts
= mp
->msg_ts
;
495 m32p
->msg_spot
= mp
->msg_spot
;
499 netbsd32_to_msqid_ds50(const struct netbsd32_msqid_ds50
*ds32p
,
500 struct msqid_ds
*dsp
)
503 netbsd32_to_ipc_perm(&ds32p
->msg_perm
, &dsp
->msg_perm
);
504 dsp
->_msg_cbytes
= (u_long
)ds32p
->_msg_cbytes
;
505 dsp
->msg_qnum
= (u_long
)ds32p
->msg_qnum
;
506 dsp
->msg_qbytes
= (u_long
)ds32p
->msg_qbytes
;
507 dsp
->msg_lspid
= ds32p
->msg_lspid
;
508 dsp
->msg_lrpid
= ds32p
->msg_lrpid
;
509 dsp
->msg_rtime
= (time_t)ds32p
->msg_rtime
;
510 dsp
->msg_stime
= (time_t)ds32p
->msg_stime
;
511 dsp
->msg_ctime
= (time_t)ds32p
->msg_ctime
;
515 netbsd32_to_msqid_ds(const struct netbsd32_msqid_ds
*ds32p
,
516 struct msqid_ds
*dsp
)
519 netbsd32_to_ipc_perm(&ds32p
->msg_perm
, &dsp
->msg_perm
);
520 dsp
->_msg_cbytes
= (u_long
)ds32p
->_msg_cbytes
;
521 dsp
->msg_qnum
= (u_long
)ds32p
->msg_qnum
;
522 dsp
->msg_qbytes
= (u_long
)ds32p
->msg_qbytes
;
523 dsp
->msg_lspid
= ds32p
->msg_lspid
;
524 dsp
->msg_lrpid
= ds32p
->msg_lrpid
;
525 dsp
->msg_rtime
= (time_t)ds32p
->msg_rtime
;
526 dsp
->msg_stime
= (time_t)ds32p
->msg_stime
;
527 dsp
->msg_ctime
= (time_t)ds32p
->msg_ctime
;
531 netbsd32_from_msqid_ds50(const struct msqid_ds
*dsp
,
532 struct netbsd32_msqid_ds50
*ds32p
)
535 netbsd32_from_ipc_perm(&dsp
->msg_perm
, &ds32p
->msg_perm
);
536 ds32p
->_msg_cbytes
= (netbsd32_u_long
)dsp
->_msg_cbytes
;
537 ds32p
->msg_qnum
= (netbsd32_u_long
)dsp
->msg_qnum
;
538 ds32p
->msg_qbytes
= (netbsd32_u_long
)dsp
->msg_qbytes
;
539 ds32p
->msg_lspid
= dsp
->msg_lspid
;
540 ds32p
->msg_lrpid
= dsp
->msg_lrpid
;
541 ds32p
->msg_rtime
= (int32_t)dsp
->msg_rtime
;
542 ds32p
->msg_stime
= (int32_t)dsp
->msg_stime
;
543 ds32p
->msg_ctime
= (int32_t)dsp
->msg_ctime
;
547 netbsd32_from_msqid_ds(const struct msqid_ds
*dsp
,
548 struct netbsd32_msqid_ds
*ds32p
)
551 netbsd32_from_ipc_perm(&dsp
->msg_perm
, &ds32p
->msg_perm
);
552 ds32p
->_msg_cbytes
= (netbsd32_u_long
)dsp
->_msg_cbytes
;
553 ds32p
->msg_qnum
= (netbsd32_u_long
)dsp
->msg_qnum
;
554 ds32p
->msg_qbytes
= (netbsd32_u_long
)dsp
->msg_qbytes
;
555 ds32p
->msg_lspid
= dsp
->msg_lspid
;
556 ds32p
->msg_lrpid
= dsp
->msg_lrpid
;
557 ds32p
->msg_rtime
= dsp
->msg_rtime
;
558 ds32p
->msg_stime
= dsp
->msg_stime
;
559 ds32p
->msg_ctime
= dsp
->msg_ctime
;
563 netbsd32_to_shmid_ds50(const struct netbsd32_shmid_ds50
*ds32p
,
564 struct shmid_ds
*dsp
)
567 netbsd32_to_ipc_perm(&ds32p
->shm_perm
, &dsp
->shm_perm
);
568 dsp
->shm_segsz
= ds32p
->shm_segsz
;
569 dsp
->shm_lpid
= ds32p
->shm_lpid
;
570 dsp
->shm_cpid
= ds32p
->shm_cpid
;
571 dsp
->shm_nattch
= ds32p
->shm_nattch
;
572 dsp
->shm_atime
= (time_t)ds32p
->shm_atime
;
573 dsp
->shm_dtime
= (time_t)ds32p
->shm_dtime
;
574 dsp
->shm_ctime
= (time_t)ds32p
->shm_ctime
;
575 dsp
->_shm_internal
= NETBSD32PTR64(ds32p
->_shm_internal
);
579 netbsd32_to_shmid_ds(const struct netbsd32_shmid_ds
*ds32p
,
580 struct shmid_ds
*dsp
)
583 netbsd32_to_ipc_perm(&ds32p
->shm_perm
, &dsp
->shm_perm
);
584 dsp
->shm_segsz
= ds32p
->shm_segsz
;
585 dsp
->shm_lpid
= ds32p
->shm_lpid
;
586 dsp
->shm_cpid
= ds32p
->shm_cpid
;
587 dsp
->shm_nattch
= ds32p
->shm_nattch
;
588 dsp
->shm_atime
= (long)ds32p
->shm_atime
;
589 dsp
->shm_dtime
= (time_t)ds32p
->shm_dtime
;
590 dsp
->shm_ctime
= (time_t)ds32p
->shm_ctime
;
591 dsp
->_shm_internal
= NETBSD32PTR64(ds32p
->_shm_internal
);
595 netbsd32_from_shmid_ds50(const struct shmid_ds
*dsp
,
596 struct netbsd32_shmid_ds50
*ds32p
)
599 netbsd32_from_ipc_perm(&dsp
->shm_perm
, &ds32p
->shm_perm
);
600 ds32p
->shm_segsz
= dsp
->shm_segsz
;
601 ds32p
->shm_lpid
= dsp
->shm_lpid
;
602 ds32p
->shm_cpid
= dsp
->shm_cpid
;
603 ds32p
->shm_nattch
= dsp
->shm_nattch
;
604 ds32p
->shm_atime
= (int32_t)dsp
->shm_atime
;
605 ds32p
->shm_dtime
= (int32_t)dsp
->shm_dtime
;
606 ds32p
->shm_ctime
= (int32_t)dsp
->shm_ctime
;
607 NETBSD32PTR32(ds32p
->_shm_internal
, dsp
->_shm_internal
);
611 netbsd32_from_shmid_ds(const struct shmid_ds
*dsp
,
612 struct netbsd32_shmid_ds
*ds32p
)
615 netbsd32_from_ipc_perm(&dsp
->shm_perm
, &ds32p
->shm_perm
);
616 ds32p
->shm_segsz
= dsp
->shm_segsz
;
617 ds32p
->shm_lpid
= dsp
->shm_lpid
;
618 ds32p
->shm_cpid
= dsp
->shm_cpid
;
619 ds32p
->shm_nattch
= dsp
->shm_nattch
;
620 ds32p
->shm_atime
= (netbsd32_long
)dsp
->shm_atime
;
621 ds32p
->shm_dtime
= (netbsd32_long
)dsp
->shm_dtime
;
622 ds32p
->shm_ctime
= (netbsd32_long
)dsp
->shm_ctime
;
623 NETBSD32PTR32(ds32p
->_shm_internal
, dsp
->_shm_internal
);
627 netbsd32_to_semid_ds50(const struct netbsd32_semid_ds50
*s32dsp
,
628 struct semid_ds
*dsp
)
631 netbsd32_to_ipc_perm(&s32dsp
->sem_perm
, &dsp
->sem_perm
);
632 dsp
->_sem_base
= NETBSD32PTR64(s32dsp
->_sem_base
);
633 dsp
->sem_nsems
= (time_t)s32dsp
->sem_nsems
;
634 dsp
->sem_otime
= (time_t)s32dsp
->sem_otime
;
635 dsp
->sem_ctime
= (time_t)s32dsp
->sem_ctime
;
639 netbsd32_to_semid_ds(const struct netbsd32_semid_ds
*s32dsp
,
640 struct semid_ds
*dsp
)
643 netbsd32_to_ipc_perm(&s32dsp
->sem_perm
, &dsp
->sem_perm
);
644 dsp
->_sem_base
= NETBSD32PTR64(s32dsp
->_sem_base
);
645 dsp
->sem_nsems
= s32dsp
->sem_nsems
;
646 dsp
->sem_otime
= s32dsp
->sem_otime
;
647 dsp
->sem_ctime
= s32dsp
->sem_ctime
;
651 netbsd32_from_semid_ds50(const struct semid_ds
*dsp
,
652 struct netbsd32_semid_ds50
*s32dsp
)
655 netbsd32_from_ipc_perm(&dsp
->sem_perm
, &s32dsp
->sem_perm
);
656 NETBSD32PTR32(s32dsp
->_sem_base
, dsp
->_sem_base
);
657 s32dsp
->sem_nsems
= (int32_t)dsp
->sem_nsems
;
658 s32dsp
->sem_otime
= (int32_t)dsp
->sem_otime
;
659 s32dsp
->sem_ctime
= (int32_t)dsp
->sem_ctime
;
663 netbsd32_from_semid_ds(const struct semid_ds
*dsp
,
664 struct netbsd32_semid_ds
*s32dsp
)
667 netbsd32_from_ipc_perm(&dsp
->sem_perm
, &s32dsp
->sem_perm
);
668 NETBSD32PTR32(s32dsp
->_sem_base
, dsp
->_sem_base
);
669 s32dsp
->sem_nsems
= dsp
->sem_nsems
;
670 s32dsp
->sem_otime
= dsp
->sem_otime
;
671 s32dsp
->sem_ctime
= dsp
->sem_ctime
;
675 netbsd32_from_loadavg(struct netbsd32_loadavg
*av32
,
676 const struct loadavg
*av
)
679 av32
->ldavg
[0] = av
->ldavg
[0];
680 av32
->ldavg
[1] = av
->ldavg
[1];
681 av32
->ldavg
[2] = av
->ldavg
[2];
682 av32
->fscale
= (netbsd32_long
)av
->fscale
;
686 netbsd32_to_kevent(struct netbsd32_kevent
*ke32
, struct kevent
*ke
)
688 ke
->ident
= ke32
->ident
;
689 ke
->filter
= ke32
->filter
;
690 ke
->flags
= ke32
->flags
;
691 ke
->fflags
= ke32
->fflags
;
692 ke
->data
= ke32
->data
;
693 ke
->udata
= ke32
->udata
;
697 netbsd32_from_kevent(struct kevent
*ke
, struct netbsd32_kevent
*ke32
)
699 ke32
->ident
= ke
->ident
;
700 ke32
->filter
= ke
->filter
;
701 ke32
->flags
= ke
->flags
;
702 ke32
->fflags
= ke
->fflags
;
703 ke32
->data
= ke
->data
;
704 ke32
->udata
= ke
->udata
;
708 netbsd32_to_sigevent(const struct netbsd32_sigevent
*ev32
, struct sigevent
*ev
)
710 ev
->sigev_notify
= ev32
->sigev_notify
;
711 ev
->sigev_signo
= ev32
->sigev_signo
;
713 * XXX sival_ptr, sigev_notify_function and
714 * sigev_notify_attributes are currently unused
716 ev
->sigev_value
.sival_int
= ev32
->sigev_value
.sival_int
;
717 ev
->sigev_notify_function
= NETBSD32PTR64(ev32
->sigev_notify_function
);
718 ev
->sigev_notify_attributes
= NETBSD32PTR64(ev32
->sigev_notify_attributes
);
722 netbsd32_to_dirent12(char *buf
, int nbytes
)
724 struct dirent
*ndp
, *nndp
, *endp
;
725 struct dirent12
*odp
;
727 odp
= (struct dirent12
*)(void *)buf
;
728 ndp
= (struct dirent
*)(void *)buf
;
729 endp
= (struct dirent
*)(void *)&buf
[nbytes
];
732 * In-place conversion. This works because odp
733 * is smaller than ndp, but it has to be done
734 * in the right sequence.
736 for (; ndp
< endp
; ndp
= nndp
) {
737 nndp
= _DIRENT_NEXT(ndp
);
738 odp
->d_fileno
= (u_int32_t
)ndp
->d_fileno
;
739 if (ndp
->d_namlen
>= sizeof(odp
->d_name
))
740 odp
->d_namlen
= sizeof(odp
->d_name
) - 1;
742 odp
->d_namlen
= (u_int8_t
)ndp
->d_namlen
;
743 odp
->d_type
= ndp
->d_type
;
744 (void)memcpy(odp
->d_name
, ndp
->d_name
, (size_t)odp
->d_namlen
);
745 odp
->d_name
[odp
->d_namlen
] = '\0';
746 odp
->d_reclen
= _DIRENT_SIZE(odp
);
747 odp
= _DIRENT_NEXT(odp
);
749 return ((char *)(void *)odp
) - buf
;
752 #endif /* _COMPAT_NETBSD32_NETBSD32_CONV_H_ */