frv: resurrect port somehow, totally untested
[uclibc-ng.git] / librt / mq_open.c
blob62c831032bfe203f6a3cefdd2efb80998592d8df
1 /*
2 * mq_open.c - open a message queue.
3 */
5 #include <errno.h>
6 #include <stdarg.h>
7 #include <stddef.h>
8 #include <sys/syscall.h>
10 #include <mqueue.h>
12 #ifdef __NR_mq_open
14 #define __NR___syscall_mq_open __NR_mq_open
15 static __inline__ _syscall4(int, __syscall_mq_open, const char *, name,
16 int, oflag, __kernel_mode_t, mode, void *, attr);
18 * Establish connection between a process and a message queue and
19 * return message queue descriptor or (mqd_t) -1 on error.
20 * oflag determines the type of access used. If O_CREAT is on oflag, the
21 * third argument is taken as a `mode_t', the mode of the created
22 * message queue, and the fourth argument is taken as `struct mq_attr *',
23 * pointer to message queue attributes.
24 * If the fourth argument is NULL, default attributes are used.
26 mqd_t mq_open(const char *name, int oflag, ...)
28 mode_t mode;
29 struct mq_attr *attr;
31 if (name[0] != '/') {
32 __set_errno(EINVAL);
33 return -1;
36 mode = 0;
37 attr = NULL;
39 if (oflag & O_CREAT) {
40 va_list ap;
42 va_start(ap, oflag);
43 mode = va_arg(ap, mode_t);
44 attr = va_arg(ap, struct mq_attr *);
46 va_end(ap);
49 return __syscall_mq_open(name + 1, oflag, mode, attr);
52 #endif