summaryrefslogtreecommitdiff
path: root/lib/libc/mqueue/mq_open.c
blob: 15ae9e18f489d2b3c85b9c572cc9a7b28ca1abfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <fcntl.h>
#include <mqueue.h>
#include <stdarg.h>
#include <syscall.h>

mqd_t mq_open(const char *name, int oflag, ...)
{
	mode_t mode;
	struct mq_attr *attr;

	if (*name == '/')
		name++;

	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);
	} else {
		mode = 0;
		attr = 0;
	}

	return syscall(mq_open, name, oflag, mode, attr);
}