diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-06-07 01:52:27 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-06-07 01:52:27 -0400 |
commit | ab11386aaaffc93755ff86199bf753a6d5ef4b45 (patch) | |
tree | 1b10227c0f62b2974127b437537466b6c63f3593 /src/mq | |
parent | cbf35978a9870fb1f5c73a852c986d4fcca6c2d4 (diff) | |
download | musl-ab11386aaaffc93755ff86199bf753a6d5ef4b45.tar.gz musl-ab11386aaaffc93755ff86199bf753a6d5ef4b45.tar.xz musl-ab11386aaaffc93755ff86199bf753a6d5ef4b45.zip |
add support for POSIX message queues, except mq_notify
Diffstat (limited to 'src/mq')
-rw-r--r-- | src/mq/mq_close.c | 7 | ||||
-rw-r--r-- | src/mq/mq_getattr.c | 7 | ||||
-rw-r--r-- | src/mq/mq_notify.c | 10 | ||||
-rw-r--r-- | src/mq/mq_open.c | 23 | ||||
-rw-r--r-- | src/mq/mq_receive.c | 6 | ||||
-rw-r--r-- | src/mq/mq_send.c | 6 | ||||
-rw-r--r-- | src/mq/mq_setattr.c | 7 | ||||
-rw-r--r-- | src/mq/mq_timedreceive.c | 7 | ||||
-rw-r--r-- | src/mq/mq_timedsend.c | 7 | ||||
-rw-r--r-- | src/mq/mq_unlink.c | 19 |
10 files changed, 99 insertions, 0 deletions
diff --git a/src/mq/mq_close.c b/src/mq/mq_close.c new file mode 100644 index 00000000..a61f094d --- /dev/null +++ b/src/mq/mq_close.c @@ -0,0 +1,7 @@ +#include <mqueue.h> +#include "syscall.h" + +int mq_close(mqd_t mqd) +{ + return syscall(SYS_close, mqd); +} diff --git a/src/mq/mq_getattr.c b/src/mq/mq_getattr.c new file mode 100644 index 00000000..dce18069 --- /dev/null +++ b/src/mq/mq_getattr.c @@ -0,0 +1,7 @@ +#include <mqueue.h> +#include "syscall.h" + +int mq_getattr(mqd_t mqd, struct mq_attr *attr) +{ + return mq_setattr(mqd, 0, attr); +} diff --git a/src/mq/mq_notify.c b/src/mq/mq_notify.c new file mode 100644 index 00000000..d85db1da --- /dev/null +++ b/src/mq/mq_notify.c @@ -0,0 +1,10 @@ +#include <mqueue.h> +#include <pthread.h> +#include <errno.h> +#include "syscall.h" + +int mq_notify(mqd_t mqd, const struct sigevent *sev) +{ + errno = ENOSYS; + return -1; +} diff --git a/src/mq/mq_open.c b/src/mq/mq_open.c new file mode 100644 index 00000000..57220a2b --- /dev/null +++ b/src/mq/mq_open.c @@ -0,0 +1,23 @@ +#include <mqueue.h> +#include <fcntl.h> +#include <errno.h> +#include <stdarg.h> +#include "syscall.h" + +mqd_t mq_open(const char *name, int flags, ...) +{ + mode_t mode = 0; + struct mq_attr *attr = 0; + if (*name++ != '/') { + errno = EINVAL; + return -1; + } + if (flags & O_CREAT) { + va_list ap; + va_start(ap, flags); + mode = va_arg(ap, mode_t); + attr = va_arg(ap, struct mq_attr *); + va_end(ap); + } + return syscall(SYS_mq_open, name, flags, mode, attr); +} diff --git a/src/mq/mq_receive.c b/src/mq/mq_receive.c new file mode 100644 index 00000000..0b1bb4e4 --- /dev/null +++ b/src/mq/mq_receive.c @@ -0,0 +1,6 @@ +#include <mqueue.h> + +ssize_t mq_receive(mqd_t mqd, char *msg, size_t len, unsigned *prio) +{ + return mq_timedreceive(mqd, msg, len, prio, 0); +} diff --git a/src/mq/mq_send.c b/src/mq/mq_send.c new file mode 100644 index 00000000..1acb1b78 --- /dev/null +++ b/src/mq/mq_send.c @@ -0,0 +1,6 @@ +#include <mqueue.h> + +int mq_send(mqd_t mqd, const char *msg, size_t len, unsigned prio) +{ + return mq_timedsend(mqd, msg, len, prio, 0); +} diff --git a/src/mq/mq_setattr.c b/src/mq/mq_setattr.c new file mode 100644 index 00000000..9064fa07 --- /dev/null +++ b/src/mq/mq_setattr.c @@ -0,0 +1,7 @@ +#include <mqueue.h> +#include "syscall.h" + +int mq_setattr(mqd_t mqd, const struct mq_attr *new, struct mq_attr *old) +{ + return syscall(SYS_mq_getsetattr, mqd, new, old); +} diff --git a/src/mq/mq_timedreceive.c b/src/mq/mq_timedreceive.c new file mode 100644 index 00000000..ad705f8b --- /dev/null +++ b/src/mq/mq_timedreceive.c @@ -0,0 +1,7 @@ +#include <mqueue.h> +#include "syscall.h" + +ssize_t mq_timedreceive(mqd_t mqd, char *msg, size_t len, unsigned *prio, const struct timespec *at) +{ + return syscall(SYS_mq_timedreceive, mqd, msg, len, prio, at); +} diff --git a/src/mq/mq_timedsend.c b/src/mq/mq_timedsend.c new file mode 100644 index 00000000..edbaccf9 --- /dev/null +++ b/src/mq/mq_timedsend.c @@ -0,0 +1,7 @@ +#include <mqueue.h> +#include "syscall.h" + +int mq_timedsend(mqd_t mqd, const char *msg, size_t len, unsigned prio, const struct timespec *at) +{ + return syscall(SYS_mq_timedsend, mqd, msg, len, prio, at); +} diff --git a/src/mq/mq_unlink.c b/src/mq/mq_unlink.c new file mode 100644 index 00000000..1bb92af1 --- /dev/null +++ b/src/mq/mq_unlink.c @@ -0,0 +1,19 @@ +#include <mqueue.h> +#include <errno.h> +#include "syscall.h" + +int mq_unlink(const char *name) +{ + int ret; + if (*name++ != '/') { + errno = EINVAL; + return -1; + } + ret = __syscall(SYS_mq_unlink, name); + if (ret < 0) { + if (ret == -EPERM) ret = -EACCES; + errno = -ret; + return -1; + } + return ret; +} |