1/* $NetBSD: sem.h,v 1.6 2009/01/19 19:39:41 christos Exp $ */
2
3/*
4 * SVID compatible sem.h file
5 *
6 * Author: Daniel Boulet
7 */
8
9#ifndef _COMPAT_SYS_SEM_H_
10#define _COMPAT_SYS_SEM_H_
11
12#include <compat/sys/ipc.h>
13
14struct semid_ds14 {
15 struct ipc_perm14 sem_perm; /* operation permission struct */
16 struct __sem *sem_base; /* pointer to first semaphore in set */
17 unsigned short sem_nsems; /* number of sems in set */
18 int32_t sem_otime; /* last operation time */
19 long sem_pad1; /* SVABI/386 says I need this here */
20 int32_t sem_ctime; /* last change time */
21 /* Times measured in secs since */
22 /* 00:00:00 GMT, Jan. 1, 1970 */
23 long sem_pad2; /* SVABI/386 says I need this here */
24 long sem_pad3[4]; /* SVABI/386 says I need this here */
25};
26
27struct semid_ds13 {
28 struct ipc_perm sem_perm; /* operation permission structure */
29 unsigned short sem_nsems; /* number of semaphores in set */
30 int32_t sem_otime; /* last semop() time */
31 int32_t sem_ctime; /* last time changed by semctl() */
32
33 /*
34 * These members are private and used only in the internal
35 * implementation of this interface.
36 */
37 struct __sem *_sem_base; /* pointer to first semaphore in set */
38};
39
40/* Warning: 64-bit structure padding is needed here */
41struct semid_ds_sysctl50 {
42 struct ipc_perm_sysctl sem_perm;
43 int16_t sem_nsems;
44 int16_t pad2;
45 int32_t pad3;
46 int32_t sem_otime;
47 int32_t sem_ctime;
48};
49
50struct sem_sysctl_info50 {
51 struct seminfo seminfo;
52 struct semid_ds_sysctl50 semids[1];
53};
54
55__BEGIN_DECLS
56static __inline void __semid_ds14_to_native(const struct semid_ds14 *, struct semid_ds *);
57static __inline void __native_to_semid_ds14(const struct semid_ds *, struct semid_ds14 *);
58static __inline void __semid_ds13_to_native(const struct semid_ds13 *, struct semid_ds *);
59static __inline void __native_to_semid_ds13(const struct semid_ds *, struct semid_ds13 *);
60
61static __inline void
62__semid_ds13_to_native(const struct semid_ds13 *osembuf, struct semid_ds *sembuf)
63{
64
65 sembuf->sem_perm = osembuf->sem_perm;
66
67#define CVT(x) sembuf->x = osembuf->x
68 CVT(sem_nsems);
69 CVT(sem_otime);
70 CVT(sem_ctime);
71#undef CVT
72}
73
74static __inline void
75__native_to_semid_ds13(const struct semid_ds *sembuf, struct semid_ds13 *osembuf)
76{
77
78 osembuf->sem_perm = sembuf->sem_perm;
79
80#define CVT(x) osembuf->x = sembuf->x
81#define CVTI(x) osembuf->x = (int)sembuf->x
82 CVT(sem_nsems);
83 CVTI(sem_otime);
84 CVTI(sem_ctime);
85#undef CVT
86#undef CVTI
87}
88
89static __inline void
90__semid_ds14_to_native(const struct semid_ds14 *osembuf, struct semid_ds *sembuf)
91{
92
93 __ipc_perm14_to_native(&osembuf->sem_perm, &sembuf->sem_perm);
94
95#define CVT(x) sembuf->x = osembuf->x
96 CVT(sem_nsems);
97 CVT(sem_otime);
98 CVT(sem_ctime);
99#undef CVT
100}
101
102static __inline void
103__native_to_semid_ds14(const struct semid_ds *sembuf, struct semid_ds14 *osembuf)
104{
105
106 __native_to_ipc_perm14(&sembuf->sem_perm, &osembuf->sem_perm);
107
108#define CVT(x) osembuf->x = sembuf->x
109#define CVTI(x) osembuf->x = (int)sembuf->x
110 CVT(sem_nsems);
111 CVTI(sem_otime);
112 CVTI(sem_ctime);
113#undef CVT
114#undef CVTI
115}
116
117int semctl(int, int, int, ...);
118int __semctl(int, int, int, union __semun *);
119int __semctl13(int, int, int, ...);
120int __semctl14(int, int, int, ...);
121int __semctl50(int, int, int, ...);
122int ____semctl50(int, int, int, ...);
123__END_DECLS
124
125#endif /* !_COMPAT_SYS_SEM_H_ */
126