From f22e1421a425776be7fcf0b58fcbdd95e719acc2 Mon Sep 17 00:00:00 2001 From: Salvatore Benedetto Date: Thu, 11 Sep 2008 14:52:35 +0000 Subject: [PATCH] * Adding sys/msg.h header and relative syscalls git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27416 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/posix/sys/msg.h | 44 ++++++++++++++++ .../libroot/posix/sys/xsi_msg_queue.cpp | 51 +++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 headers/posix/sys/msg.h create mode 100644 src/system/libroot/posix/sys/xsi_msg_queue.cpp diff --git a/headers/posix/sys/msg.h b/headers/posix/sys/msg.h new file mode 100644 index 0000000000..03a66f4eb6 --- /dev/null +++ b/headers/posix/sys/msg.h @@ -0,0 +1,44 @@ +/* + * Copyright 2008, Haiku Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _SYS_MSG_H +#define _SYS_MSG_H + +#include +#include +#include + +typedef unsigned long msgqnum_t; +typedef unsigned long msglen_t; + +/* No error if big message */ +#define MSG_NOERROR 010000 + +struct msqid_ds { + struct ipc_perm msg_perm; /* Operation permission structure */ + msgqnum_t msg_qnum; /* Number of messages currently on queue */ + msglen_t msg_qbytes; /* Max number of bytes allowed on queue */ + pid_t msg_lspid; /* PID of last msgsnd */ + pid_t msg_lrpid; /* PID of last msgrcv */ + time_t msg_stime; /* Time of last msgsnd */ + time_t msg_rtime; /* Time of last msgrcv */ + time_t msg_ctime; /* Time of last change */ +}; + +/* Structure used to send/receive a message */ +struct msgbuf { + long mtype; /* message type */ + char mtext[1]; /* message text */ +}; + +__BEGIN_DECLS + +int msgctl(int, int, struct msqid_ds *); +int msgget(key_t, int); +ssize_t msgrcv(int, void *, size_t, long, int); +int msgsnd(int, const void *, size_t, int); + +__END_DECLS + +#endif /* _SYS_MSG_H */ diff --git a/src/system/libroot/posix/sys/xsi_msg_queue.cpp b/src/system/libroot/posix/sys/xsi_msg_queue.cpp new file mode 100644 index 0000000000..cf3429718e --- /dev/null +++ b/src/system/libroot/posix/sys/xsi_msg_queue.cpp @@ -0,0 +1,51 @@ +/* + * Copyright 2008, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Salvatore Benedetto + */ + +#include + +#include +#include +#include +#include + +#include + +#include +#include + + +int +msgctl(int messageQueueID, int command, struct msqid_ds *buffer) +{ + RETURN_AND_SET_ERRNO(_kern_xsi_msgctl(messageQueueID, command, buffer)); +} + + +int +msgget(key_t key, int messageQueueFlags) +{ + RETURN_AND_SET_ERRNO(_kern_xsi_msgget(key, messageQueueFlags)); +} + + +ssize_t +msgrcv(int messageQueueID, void *messagePointer, size_t messageSize, + long messageType, int messageFlags) +{ + RETURN_AND_SET_ERRNO(_kern_xsi_msgrcv(messageQueueID, messagePointer, + messageSize, messageType, messageFlags)); +} + + +int +msgsnd(int messageQueueID, const void *messagePointer, size_t messageSize, + int messageFlags) +{ + RETURN_AND_SET_ERRNO(_kern_xsi_msgsnd(messageQueueID, messagePointer, + messageSize, messageFlags)); +}