1/* $NetBSD: sem.h,v 1.7 2019/02/21 03:37:19 mrg 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 memset(osembuf, 0, sizeof *osembuf); 79 osembuf->sem_perm = sembuf->sem_perm; 80 81#define CVT(x) osembuf->x = sembuf->x 82#define CVTI(x) osembuf->x = (int)sembuf->x 83 CVT(sem_nsems); 84 CVTI(sem_otime); 85 CVTI(sem_ctime); 86#undef CVT 87#undef CVTI 88} 89 90static __inline void 91__semid_ds14_to_native(const struct semid_ds14 *osembuf, struct semid_ds *sembuf) 92{ 93 94 __ipc_perm14_to_native(&osembuf->sem_perm, &sembuf->sem_perm); 95 96#define CVT(x) sembuf->x = osembuf->x 97 CVT(sem_nsems); 98 CVT(sem_otime); 99 CVT(sem_ctime); 100#undef CVT 101} 102 103static __inline void 104__native_to_semid_ds14(const struct semid_ds *sembuf, struct semid_ds14 *osembuf) 105{ 106 107 memset(osembuf, 0, sizeof *osembuf); 108 __native_to_ipc_perm14(&sembuf->sem_perm, &osembuf->sem_perm); 109 110#define CVT(x) osembuf->x = sembuf->x 111#define CVTI(x) osembuf->x = (int)sembuf->x 112 CVT(sem_nsems); 113 CVTI(sem_otime); 114 CVTI(sem_ctime); 115#undef CVT 116#undef CVTI 117} 118 119int semctl(int, int, int, ...); 120int __semctl(int, int, int, union __semun *); 121int __semctl13(int, int, int, ...); 122int __semctl14(int, int, int, ...); 123int __semctl50(int, int, int, ...); 124int ____semctl50(int, int, int, ...); 125__END_DECLS 126 127#endif /* !_COMPAT_SYS_SEM_H_ */ 128