#ifndef _COMPAT_SYS_SHM_H_
#define _COMPAT_SYS_SHM_H_
#include <compat/sys/ipc.h>
struct shmid_ds14 {
struct ipc_perm14 shm_perm;
int shm_segsz;
pid_t shm_lpid;
pid_t shm_cpid;
short shm_nattch;
int32_t shm_atime;
int32_t shm_dtime;
int32_t shm_ctime;
void *shm_internal;
};
struct shmid_ds13 {
struct ipc_perm shm_perm;
size_t shm_segsz;
pid_t shm_lpid;
pid_t shm_cpid;
shmatt_t shm_nattch;
int32_t shm_atime;
int32_t shm_dtime;
int32_t shm_ctime;
void *_shm_internal;
};
struct shmid_ds_sysctl50 {
struct ipc_perm_sysctl shm_perm;
uint64_t shm_segsz;
pid_t shm_lpid;
pid_t shm_cpid;
int32_t shm_atime;
int32_t shm_dtime;
int32_t shm_ctime;
uint32_t shm_nattch;
};
struct shm_sysctl_info50 {
struct shminfo shminfo;
struct shmid_ds_sysctl50 shmids[1];
};
__BEGIN_DECLS
static __inline void __shmid_ds14_to_native(const struct shmid_ds14 *, struct shmid_ds *);
static __inline void __native_to_shmid_ds14(const struct shmid_ds *, struct shmid_ds14 *);
static __inline void __shmid_ds13_to_native(const struct shmid_ds13 *, struct shmid_ds *);
static __inline void __native_to_shmid_ds13(const struct shmid_ds *, struct shmid_ds13 *);
static __inline void
__shmid_ds14_to_native(const struct shmid_ds14 *oshmbuf, struct shmid_ds *shmbuf)
{
__ipc_perm14_to_native(&oshmbuf->shm_perm, &shmbuf->shm_perm);
#define CVT(x) shmbuf->x = oshmbuf->x
CVT(shm_segsz);
CVT(shm_lpid);
CVT(shm_cpid);
CVT(shm_nattch);
CVT(shm_atime);
CVT(shm_dtime);
CVT(shm_ctime);
#undef CVT
}
static __inline void
__native_to_shmid_ds14(const struct shmid_ds *shmbuf, struct shmid_ds14 *oshmbuf)
{
memset(oshmbuf, 0, sizeof *oshmbuf);
__native_to_ipc_perm14(&shmbuf->shm_perm, &oshmbuf->shm_perm);
#define CVT(x) oshmbuf->x = shmbuf->x
#define CVTI(x) oshmbuf->x = (int)shmbuf->x
CVTI(shm_segsz);
CVT(shm_lpid);
CVT(shm_cpid);
CVT(shm_nattch);
CVTI(shm_atime);
CVTI(shm_dtime);
CVTI(shm_ctime);
#undef CVT
#undef CVTI
}
static __inline void
__shmid_ds13_to_native(const struct shmid_ds13 *oshmbuf, struct shmid_ds *shmbuf)
{
shmbuf->shm_perm = oshmbuf->shm_perm;
#define CVT(x) shmbuf->x = oshmbuf->x
CVT(shm_segsz);
CVT(shm_lpid);
CVT(shm_cpid);
CVT(shm_nattch);
CVT(shm_atime);
CVT(shm_dtime);
CVT(shm_ctime);
#undef CVT
}
static __inline void
__native_to_shmid_ds13(const struct shmid_ds *shmbuf, struct shmid_ds13 *oshmbuf)
{
memset(oshmbuf, 0, sizeof *oshmbuf);
oshmbuf->shm_perm = shmbuf->shm_perm;
#define CVT(x) oshmbuf->x = shmbuf->x
#define CVTI(x) oshmbuf->x = (int)shmbuf->x
CVT(shm_segsz);
CVT(shm_lpid);
CVT(shm_cpid);
CVT(shm_nattch);
CVTI(shm_atime);
CVTI(shm_dtime);
CVTI(shm_ctime);
#undef CVT
#undef CVTI
}
int __shmctl13(int, int, struct shmid_ds13 *);
int __shmctl14(int, int, struct shmid_ds14 *);
int __shmctl50(int, int, struct shmid_ds *);
__END_DECLS
#endif