From 50a6ac7fb90ad4008b354ff8e72c6ce511dbeb3a Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 11 Jan 2005 09:41:40 +0000 Subject: Patch from Paul Mundt (lethal) adding an initial librt implementation. I then reworked the syscall handling and made minor cleanups. With luck I've not completely broken his patch... --- librt/mq_open.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 librt/mq_open.c (limited to 'librt/mq_open.c') diff --git a/librt/mq_open.c b/librt/mq_open.c new file mode 100644 index 000000000..3648b5aa7 --- /dev/null +++ b/librt/mq_open.c @@ -0,0 +1,52 @@ +/* + * mq_open.c - open a message queue. + */ + +#include +#include +#include +#include + +#include + +#ifdef __NR_mq_open + +#define __NR___syscall_mq_open __NR_mq_open +static inline _syscall4(int, __syscall_mq_open, const char *, name, + int, oflag, __kernel_mode_t, mode, void *, attr); +/* + * Establish connection between a process and a message queue and + * return message queue descriptor or (mqd_t) -1 on error. + * oflag determines the type of access used. If O_CREAT is on oflag, the + * third argument is taken as a `mode_t', the mode of the created + * message queue, and the fourth argument is taken as `struct mq_attr *', + * pointer to message queue attributes. + * If the fourth argument is NULL, default attributes are used. + */ +mqd_t mq_open(const char *name, int oflag, ...) +{ + mode_t mode; + struct mq_attr *attr; + + if (name[0] != '/') { + __set_errno(EINVAL); + return -1; + } + + mode = 0; + attr = NULL; + + if (oflag & O_CREAT) { + va_list ap; + + va_start(ap, oflag); + mode = va_arg(ap, mode_t); + attr = va_arg(ap, struct mq_attr *); + + va_end(ap); + } + + return __syscall_mq_open(name + 1, oflag, mode, attr); +} + +#endif -- cgit v1.2.3