fix static linking for FDPIC toolchains
[uclibc-ng.git] / librt / mq_unlink.c
blob3c490e0ce9617cf7c89ea212bd00eb568efad5fd
1 /*
2 * mq_unlink.c - remove a message queue.
3 */
5 #include <errno.h>
6 #include <sys/syscall.h>
8 #include <mqueue.h>
10 #ifdef __NR_mq_unlink
12 #define __NR___syscall_mq_unlink __NR_mq_unlink
13 static __inline__ _syscall1(int, __syscall_mq_unlink, const char *, name);
15 /* Remove message queue */
16 int mq_unlink(const char *name)
18 int ret;
20 if (name[0] != '/') {
21 __set_errno(EINVAL);
22 return -1;
25 ret = __syscall_mq_unlink(name + 1);
27 /* While unlink can return either EPERM or EACCES, mq_unlink should return just EACCES. */
28 if (ret < 0) {
29 ret = errno;
30 if (ret == EPERM)
31 ret = EACCES;
32 __set_errno(ret);
33 ret = -1;
36 return ret;
39 #endif