+ * [XSI] The pid_t, time_t, key_t, size_t, and ssize_t types shall be
+ * defined as described in <sys/types.h>.
+ *
+ * NOTE: The definition of the key_t type is implicit from the
+ * inclusion of <sys/ipc.h>
+ */
+#include <sys/_types/_pid_t.h>
+#include <sys/_types/_time_t.h>
+#include <sys/_types/_size_t.h>
+#include <sys/_types/_ssize_t.h>
+
+/* [XSI] Used for the number of messages in the message queue */
+typedef unsigned long msgqnum_t;
+
+/* [XSI] Used for the number of bytes allowed in a message queue */
+typedef unsigned long msglen_t;
+
+/*
+ * Possible values for the fifth parameter to msgrcv(), in addition to the
+ * IPC_NOWAIT flag, which is permitted.
+ */
+#define MSG_NOERROR 010000 /* [XSI] No error if big message */
+
+
+/*
+ * 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)
+#pragma pack(4)
+/*
+ * Structure used internally.
+ *
+ * Structure whose address is passed as the third parameter to msgctl()
+ * when the second parameter is IPC_SET or IPC_STAT. In the case of the
+ * IPC_SET command, only the msg_perm.{uid|gid|perm} and msg_qbytes are
+ * honored. In the case of IPC_STAT, only the fields indicated as [XSI]
+ * mandated fields are guaranteed to meaningful: DO NOT depend on the
+ * contents of the other fields.
+ *
+ * NOTES: Reserved fields are not preserved across IPC_SET/IPC_STAT.
+ */
+#if (defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE))
+struct msqid_ds
+#else
+#define msqid_ds __msqid_ds_new
+struct __msqid_ds_new
+#endif
+{
+ struct __ipc_perm_new msg_perm; /* [XSI] msg queue permissions */
+ __int32_t msg_first; /* RESERVED: kernel use only */
+ __int32_t msg_last; /* RESERVED: kernel use only */
+ msglen_t msg_cbytes; /* # of bytes on the queue */
+ msgqnum_t msg_qnum; /* [XSI] number of msgs on the queue */
+ msglen_t msg_qbytes; /* [XSI] max bytes on the queue */
+ pid_t msg_lspid; /* [XSI] pid of last msgsnd() */
+ pid_t msg_lrpid; /* [XSI] pid of last msgrcv() */
+ time_t msg_stime; /* [XSI] time of last msgsnd() */
+ __int32_t msg_pad1; /* RESERVED: DO NOT USE */
+ time_t msg_rtime; /* [XSI] time of last msgrcv() */
+ __int32_t msg_pad2; /* RESERVED: DO NOT USE */
+ time_t msg_ctime; /* [XSI] time of last msgctl() */
+ __int32_t msg_pad3; /* RESERVED: DO NOT USE */
+ __int32_t msg_pad4[4]; /* RESERVED: DO NOT USE */
+};
+#pragma pack()
+#else /* !__DARWIN_UNIX03 */
+#define msqid_ds __msqid_ds_old
+#endif /* !__DARWIN_UNIX03 */
+
+#if !__DARWIN_UNIX03
+struct __msqid_ds_old {
+ struct __ipc_perm_old msg_perm; /* [XSI] msg queue permissions */
+ __int32_t msg_first; /* RESERVED: kernel use only */
+ __int32_t msg_last; /* RESERVED: kernel use only */
+ msglen_t msg_cbytes; /* # of bytes on the queue */
+ msgqnum_t msg_qnum; /* [XSI] number of msgs on the queue */
+ msglen_t msg_qbytes; /* [XSI] max bytes on the queue */
+ pid_t msg_lspid; /* [XSI] pid of last msgsnd() */
+ pid_t msg_lrpid; /* [XSI] pid of last msgrcv() */
+ time_t msg_stime; /* [XSI] time of last msgsnd() */
+ __int32_t msg_pad1; /* RESERVED: DO NOT USE */
+ time_t msg_rtime; /* [XSI] time of last msgrcv() */
+ __int32_t msg_pad2; /* RESERVED: DO NOT USE */
+ time_t msg_ctime; /* [XSI] time of last msgctl() */
+ __int32_t msg_pad3; /* RESERVED: DO NOT USE */
+ __int32_t msg_pad4[4]; /* RESERVED: DO NOT USE */
+};
+#endif /* !__DARWIN_UNIX03 */
+
+#ifdef KERNEL
+#ifdef __APPLE_API_PRIVATE
+#include <machine/types.h>
+
+#if __DARWIN_ALIGN_NATURAL
+#pragma options align=natural
+#endif
+
+typedef user_ulong_t user_msgqnum_t;
+typedef user64_ulong_t user64_msgqnum_t;
+typedef user32_ulong_t user32_msgqnum_t;
+
+typedef user_ulong_t user_msglen_t;
+typedef user64_ulong_t user64_msglen_t;
+typedef user32_ulong_t user32_msglen_t;
+
+/* kernel version */
+struct user_msqid_ds {
+ struct ipc_perm msg_perm; /* [XSI] msg queue permissions */
+ struct msg *msg_first; /* first message in the queue */
+ struct msg *msg_last; /* last message in the queue */
+ user_msglen_t msg_cbytes; /* # of bytes on the queue */
+ user_msgqnum_t msg_qnum; /* [XSI] number of msgs on the queue */
+ user_msglen_t msg_qbytes; /* [XSI] max bytes on the queue */
+ pid_t msg_lspid; /* [XSI] pid of last msgsnd() */
+ pid_t msg_lrpid; /* [XSI] pid of last msgrcv() */
+ user_time_t msg_stime; /* [XSI] time of last msgsnd() */
+ __int32_t msg_pad1; /* RESERVED: DO NOT USE */
+ user_time_t msg_rtime; /* [XSI] time of last msgrcv() */
+ __int32_t msg_pad2; /* RESERVED: DO NOT USE */
+ user_time_t msg_ctime; /* [XSI] time of last msgctl() */
+ __int32_t msg_pad3; /* RESERVED: DO NOT USE */
+ __int32_t msg_pad4[4];
+};
+
+/*
+ * user64 version - this structure only has to be correct if
+ * compiled LP64, because the 32 bit kernel doesn't need it