---@meta posix.sys.msg

---@class posix_msg_perm*
---@field uid integer
---@field gid integer
---@field cuid integer
---@field cgid integer
---@field mode integer

---@class posix_msqid_ds*
---@field msg_perm posix_msg_perm*
---@field msg_stime integer
---@field msg_rtime integer
---@field msg_ctime integer
---@field msg_cbytes integer
---@field msg_qnum integer
---@field msg_qbytes integer
---@field msg_lspid integer
---@field msg_lrpid integer

---@class posix_sys_msg*
---@field version string
---@field IPC_CREAT integer
---@field MSG_EXCEPT integer
---@field IPC_EXCL integer
---@field MSG_NOERROR integer
---@field IPC_NOWAIT integer
---@field IPC_PRIVATE integer
---@field IPC_RMID integer
---@field IPC_SET integer
---@field IPC_STAT integer
---@type posix_sys_msg*
local M = {}

---@param msqid integer
---@param cmd integer
---@param buf? posix_msqid_ds*
---@return posix_msqid_ds|integer|nil result
---@return string? errMsg
---@return integer? errno
function M.msgctl(msqid, cmd, buf) end

---@param key integer
---@param flags integer
---@return integer? msqid
---@return string? errMsg
---@return integer? errno
function M.msgget(key, flags) end

---@param msqid integer
---@param msg string
---@param msgtype? integer
---@param flags? integer
---@return integer? ok
---@return string? errMsg
---@return integer? errno
function M.msgsnd(msqid, msg, msgtype, flags) end

---@param msqid integer
---@param size integer
---@param msgtype? integer
---@param flags? integer
---@return string? msg
---@return integer? msgtype
---@return string? errMsg
---@return integer? errno
function M.msgrcv(msqid, size, msgtype, flags) end

return M
