-struct ipc_perm {
- ushort cuid; /* creator user id */
- ushort cgid; /* creator group id */
- ushort uid; /* user id */
- ushort gid; /* group id */
- ushort mode; /* r/w permission */
- ushort seq; /* sequence # (to generate unique msg/sem/shm id) */
- key_t key; /* user specified msg/sem/shm key */
+#include <sys/appleapiopts.h>
+#include <sys/cdefs.h>
+
+#include <sys/_types.h>
+
+/*
+ * [XSI] The uid_t, gid_t, mode_t, and key_t types SHALL be defined as
+ * described in <sys/types.h>.
+ */
+#ifndef _UID_T
+typedef __darwin_uid_t uid_t; /* user id */
+#define _UID_T
+#endif
+
+#ifndef _GID_T
+typedef __darwin_gid_t gid_t;
+#define _GID_T
+#endif
+
+#ifndef _MODE_T
+typedef __darwin_mode_t mode_t;
+#define _MODE_T
+#endif
+
+#ifndef _KEY_T
+#define _KEY_T
+typedef __int32_t key_t;
+#endif
+
+#pragma pack(4)
+
+/*
+ * Technically, we should force all code references to the new structure
+ * definition, not in just the standards conformance case, and leave the
+ * legacy interface there for binary compatibility only. Currently, we
+ * are only forcing this for programs requesting standards conformance.
+ */
+#if __DARWIN_UNIX03 || defined(KERNEL)
+/*
+ * [XSI] Information used in determining permission to perform an IPC
+ * operation
+ */
+struct ipc_perm
+{
+ uid_t uid; /* [XSI] Owner's user ID */
+ gid_t gid; /* [XSI] Owner's group ID */
+ uid_t cuid; /* [XSI] Creator's user ID */
+ gid_t cgid; /* [XSI] Creator's group ID */
+ mode_t mode; /* [XSI] Read/write permission */
+ unsigned short _seq; /* Reserved for internal use */
+ key_t _key; /* Reserved for internal use */
+};
+#define __ipc_perm_new ipc_perm
+#else /* !__DARWIN_UNIX03 */
+#define ipc_perm __ipc_perm_old
+#endif /* !__DARWIN_UNIX03 */
+
+#if !__DARWIN_UNIX03
+/*
+ * Legacy structure; this structure is maintained for binary backward
+ * compatability with previous versions of the interface. New code
+ * should not use this interface, since ID values may be truncated.
+ */
+struct __ipc_perm_old {
+ __uint16_t cuid; /* Creator's user ID */
+ __uint16_t cgid; /* Creator's group ID */
+ __uint16_t uid; /* Owner's user ID */
+ __uint16_t gid; /* Owner's group ID */
+ mode_t mode; /* Read/Write permission */
+ __uint16_t seq; /* Reserved for internal use */
+ key_t key; /* Reserved for internal use */