Xenomai API  2.6.5
mqueue.h
1 /*
2  * Copyright (C) 2005 Philippe Gerum <[email protected]>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18 
19 #ifndef _XENO_POSIX_MQUEUE_H
20 #define _XENO_POSIX_MQUEUE_H
21 
22 #if defined(__KERNEL__) || defined(__XENO_SIM__)
23 
24 #include <nucleus/xenomai.h>
25 
26 #ifdef __KERNEL__
27 #include <linux/types.h>
28 #include <linux/signal.h>
29 #include <linux/fcntl.h>
30 #endif /* !__KERNEL__ */
31 
32 #ifdef __XENO_SIM__
33 #include <posix_overrides.h>
34 #endif /* __XENO_SIM__ */
35 
36 #else /* !(__KERNEL__ || __XENO_SIM__) */
37 
38 #include <xeno_config.h>
39 #include <fcntl.h>
40 
41 #endif /* !(__KERNEL__ || __XENO_SIM__) */
42 
43 #if defined(__KERNEL__) || defined(__XENO_SIM__) || !defined(CONFIG_XENO_HAVE_MQUEUE_H)
44 
45 #ifndef MQ_PRIO_MAX
46 #define MQ_PRIO_MAX 32768
47 #endif
48 
49 #ifndef __KERNEL__
50 typedef unsigned long mqd_t;
51 #endif /* !__KERNEL__ */
52 
53 struct mq_attr {
54  long mq_flags;
55  long mq_maxmsg;
56  long mq_msgsize;
57  long mq_curmsgs;
58 };
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 int mq_getattr(mqd_t qd,
65  struct mq_attr *attr);
66 
67 int mq_setattr(mqd_t qd,
68  const struct mq_attr *__restrict__ attr,
69  struct mq_attr *__restrict__ oattr);
70 
71 int mq_send(mqd_t qd,
72  const char *buffer,
73  size_t len,
74  unsigned prio);
75 
76 int mq_close(mqd_t qd);
77 
78 ssize_t mq_receive(mqd_t q,
79  char *buffer,
80  size_t len,
81  unsigned *prio);
82 
83 ssize_t mq_timedreceive(mqd_t q,
84  char *__restrict__ buffer,
85  size_t len,
86  unsigned *__restrict__ prio,
87  const struct timespec *__restrict__ timeout);
88 
89 int mq_timedsend(mqd_t q,
90  const char *buffer,
91  size_t len,
92  unsigned prio,
93  const struct timespec *timeout);
94 
95 int mq_notify(mqd_t mqdes, const struct sigevent *notification);
96 
97 mqd_t mq_open(const char *name,
98  int oflags,
99  ...);
100 
101 int mq_unlink(const char *name);
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #else /* !(__KERNEL__ || __XENO_SIM__ || !CONFIG_XENO_HAVE_MQUEUE_H) */
108 
109 #pragma GCC system_header
110 
111 #include_next <mqueue.h>
112 
113 #ifdef __cplusplus
114 extern "C" {
115 #endif
116 
117 mqd_t __real_mq_open(const char *name,
118  int oflags,
119  ...);
120 
121 int __real_mq_close(mqd_t qd);
122 
123 int __real_mq_unlink(const char *name);
124 
125 int __real_mq_getattr(mqd_t qd,
126  struct mq_attr *attr);
127 
128 int __real_mq_setattr(mqd_t qd,
129  const struct mq_attr *__restrict__ attr,
130  struct mq_attr *__restrict__ oattr);
131 
132 int __real_mq_send(mqd_t qd,
133  const char *buffer,
134  size_t len,
135  unsigned prio);
136 
137 int __real_mq_timedsend(mqd_t q,
138  const char * buffer,
139  size_t len,
140  unsigned prio,
141  const struct timespec *timeout);
142 
143 ssize_t __real_mq_receive(mqd_t q,
144  char *buffer,
145  size_t len,
146  unsigned *prio);
147 
148 ssize_t __real_mq_timedreceive(mqd_t q,
149  char *__restrict__ buffer,
150  size_t len,
151  unsigned *__restrict__ prio,
152  const struct timespec *__restrict__ timeout);
153 
154 int __real_mq_notify(mqd_t mqdes, const struct sigevent *notification);
155 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif /* !(__KERNEL__ || __XENO_SIM__ || !CONFIG_XENO_HAVE_MQUEUE_H) */
161 
162 #endif /* _XENO_POSIX_MQUEUE_H */
int mq_send(mqd_t qd, const char *buffer, size_t len, unsigned prio)
Send a message to a message queue.
Definition: mq.c:798
ssize_t mq_receive(mqd_t q, char *buffer, size_t len, unsigned *prio)
Receive a message from a message queue.
Definition: mq.c:930
int mq_setattr(mqd_t qd, const struct mq_attr *__restrict__ attr, struct mq_attr *__restrict__ oattr)
Set flags of a message queue.
Definition: mq.c:1105
int mq_timedsend(mqd_t q, const char *buffer, size_t len, unsigned prio, const struct timespec *timeout)
Attempt, during a bounded time, to send a message to a message queue.
Definition: mq.c:861
int mq_unlink(const char *name)
Unlink a message queue.
Definition: mq.c:436
mqd_t mq_open(const char *name, int oflags,...)
Open a message queue.
Definition: mq.c:241
ssize_t mq_timedreceive(mqd_t q, char *__restrict__ buffer, size_t len, unsigned *__restrict__ prio, const struct timespec *__restrict__ timeout)
Attempt, during a bounded time, to receive a message from a message queue.
Definition: mq.c:997
int mq_notify(mqd_t mqdes, const struct sigevent *notification)
Register the current thread to be notified of message arrival at an empty message queue...
Definition: mq.c:1180
int mq_getattr(mqd_t qd, struct mq_attr *attr)
Get the attributes object of a message queue.
Definition: mq.c:1052
int mq_close(mqd_t qd)
Close a message queue.
Definition: mq.c:358