Remove some unnecessary inclusions of <sys/cdefs.h> across the tree.
[dragonfly.git] / lib / librt / mq.c
1 /*-
2  * Copyright (c) 2006 David Xu <davidxu@freebsd.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28
29 #include <sys/types.h>
30 #include <sys/syscall.h>
31 #include <sys/sysproto.h>
32 #include <sys/mqueue.h>
33
34 #include <errno.h>
35 #include <stddef.h>
36 #include <stdlib.h>
37 #include <signal.h>
38
39 extern int      __sys_mq_open(const char *, int, mode_t,
40     const struct mq_attr *);
41 extern int      __sys_mq_close(int fd);
42 extern int      __sys_mq_getattr(mqd_t mqd, struct mq_attr *attr);
43 extern int      __sys_mq_notify(int, const struct sigevent *);
44 extern ssize_t  __sys_mq_receive(mqd_t mqd, char *buf, size_t len,
45     unsigned *prio);
46 extern ssize_t  __sys_mq_send(mqd_t mqd, char *buf, size_t len, unsigned prio);
47 extern int      __sys_mq_setattr(int, const struct mq_attr *__restrict,
48     struct mq_attr *__restrict);
49 extern ssize_t  __sys_mq_timedreceive(int, char *__restrict, size_t,
50     unsigned *__restrict, const struct timespec *__restrict);
51 extern int      __sys_mq_timedsend(int, const char *, size_t, unsigned,
52     const struct timespec *);
53 extern int      __sys_mq_unlink(const char *);
54
55 __weak_reference(__mq_open, mq_open);
56 __weak_reference(__mq_open, _mq_open);
57 __weak_reference(__mq_close, mq_close);
58 __weak_reference(__mq_close, _mq_close);
59 __weak_reference(__mq_notify, mq_notify);
60 __weak_reference(__mq_notify, _mq_notify);
61 __weak_reference(__mq_getattr, mq_getattr);
62 __weak_reference(__mq_getattr, _mq_getattr);
63 __weak_reference(__mq_setattr, mq_setattr);
64 __weak_reference(__mq_setattr, _mq_setattr);
65 __weak_reference(__mq_timedreceive, mq_timedreceive);
66 __weak_reference(__mq_timedreceive, _mq_timedreceive);
67 __weak_reference(__mq_timedsend, mq_timedsend);
68 __weak_reference(__mq_timedsend, _mq_timedsend);
69 __weak_reference(__mq_unlink, mq_unlink);
70 __weak_reference(__mq_unlink, _mq_unlink);
71 __weak_reference(__mq_send, mq_send);
72 __weak_reference(__mq_send, _mq_send);
73 __weak_reference(__mq_receive, mq_receive);
74 __weak_reference(__mq_receive, _mq_receive);
75
76 mqd_t
77 __mq_open(const char *name, int oflag, mode_t mode,
78         const struct mq_attr *attr)
79 {
80         return (__sys_mq_open(name, oflag, mode, attr));
81 }
82
83 int
84 __mq_close(mqd_t mqd)
85 {
86         return (__sys_mq_close(mqd));
87 }
88
89 int
90 __mq_notify(mqd_t mqd, const struct sigevent *evp)
91 {
92         return (__sys_mq_notify(mqd, evp));
93 }
94
95 int
96 __mq_getattr(mqd_t mqd, struct mq_attr *attr)
97 {
98         return (__sys_mq_getattr(mqd, attr));
99 }
100
101 int
102 __mq_setattr(mqd_t mqd, const struct mq_attr *newattr, struct mq_attr *oldattr)
103 {
104         return (__sys_mq_setattr(mqd, newattr, oldattr));
105 }
106
107 ssize_t
108 __mq_timedreceive(mqd_t mqd, char *buf, size_t len,
109         unsigned *prio, const struct timespec *timeout)
110 {
111         return (__sys_mq_timedreceive(mqd, buf, len, prio, timeout));
112 }
113
114 ssize_t
115 __mq_receive(mqd_t mqd, char *buf, size_t len, unsigned *prio)
116 {
117         return (__sys_mq_receive(mqd, buf, len, prio));
118 }
119
120 ssize_t
121 __mq_timedsend(mqd_t mqd, char *buf, size_t len,
122         unsigned prio, const struct timespec *timeout)
123 {
124         return (__sys_mq_timedsend(mqd, buf, len, prio, timeout));
125 }
126
127 ssize_t
128 __mq_send(mqd_t mqd, char *buf, size_t len, unsigned prio)
129 {
130         return (__sys_mq_send(mqd, buf, len, prio));
131 }
132
133 int
134 __mq_unlink(const char *path)
135 {
136         return (__sys_mq_unlink(path));
137 }