#pragma weak _msgctl = msgctl
#pragma weak _msgget = msgget
#pragma weak _msgids = msgids
#pragma weak _msgsnap = msgsnap
#include "lint.h"
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/ipc_impl.h>
#include <sys/msg.h>
#include <sys/msg_impl.h>
#include <sys/syscall.h>
#include <errno.h>
#include <limits.h>
int
msgget(key_t key, int msgflg)
{
return (syscall(SYS_msgsys, MSGGET, key, msgflg));
}
int
msgctl(int msqid, int cmd, struct msqid_ds *buf)
{
if (cmd == IPC_SET64 || cmd == IPC_STAT64) {
(void) __set_errno(EINVAL);
return (-1);
}
return (syscall(SYS_msgsys, MSGCTL, msqid, cmd, buf));
}
int
msgctl64(int msqid, int cmd, struct msqid_ds64 *buf)
{
if (cmd != IPC_SET64 && cmd != IPC_STAT64) {
(void) __set_errno(EINVAL);
return (-1);
}
return (syscall(SYS_msgsys, MSGCTL, msqid, cmd, buf));
}
ssize_t
__msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
{
if (msgsz > INT_MAX) {
sysret_t rval;
int error;
error = __systemcall(&rval, SYS_msgsys, MSGRCV, msqid,
msgp, msgsz, msgtyp, msgflg);
if (error)
(void) __set_errno(error);
return ((ssize_t)rval.sys_rval1);
}
return ((ssize_t)syscall(SYS_msgsys, MSGRCV, msqid,
msgp, msgsz, msgtyp, msgflg));
}
int
__msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg)
{
if (msgsz > INT_MAX) {
sysret_t rval;
int error;
error = __systemcall(&rval, SYS_msgsys, MSGSND, msqid,
msgp, msgsz, msgflg);
if (error)
(void) __set_errno(error);
return ((int)rval.sys_rval1);
}
return (syscall(SYS_msgsys, MSGSND, msqid, msgp, msgsz, msgflg));
}
int
msgids(int *buf, uint_t nids, uint_t *pnids)
{
return (syscall(SYS_msgsys, MSGIDS, buf, nids, pnids));
}
int
msgsnap(int msqid, void *buf, size_t bufsz, long msgtyp)
{
return (syscall(SYS_msgsys, MSGSNAP, msqid, buf, bufsz, msgtyp));
}