1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief POSIX Message Queues |
---|
5 | * |
---|
6 | * This file contains the definitions related to POSIX Message Queues. |
---|
7 | * |
---|
8 | * The structure of the routines is identical to that of POSIX |
---|
9 | * Message_queues to leave the option of having unnamed message |
---|
10 | * queues at a future date. They are currently not part of the |
---|
11 | * POSIX standard but unnamed message_queues are. This is also |
---|
12 | * the reason for the apparently unnecessary tracking of |
---|
13 | * the process_shared attribute. [In addition to the fact that |
---|
14 | * it would be trivial to add pshared to the mq_attr structure |
---|
15 | * and have process private message queues.] |
---|
16 | * |
---|
17 | * This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open |
---|
18 | * time. |
---|
19 | */ |
---|
20 | |
---|
21 | /* |
---|
22 | * COPYRIGHT (c) 1989-2011. |
---|
23 | * On-Line Applications Research Corporation (OAR). |
---|
24 | * |
---|
25 | * The license and distribution terms for this file may be |
---|
26 | * found in the file LICENSE in this distribution or at |
---|
27 | * http://www.rtems.org/license/LICENSE. |
---|
28 | */ |
---|
29 | |
---|
30 | #ifndef _MQUEUE_H |
---|
31 | #define _MQUEUE_H |
---|
32 | |
---|
33 | |
---|
34 | #include <unistd.h> |
---|
35 | |
---|
36 | #if defined(_POSIX_MESSAGE_PASSING) |
---|
37 | |
---|
38 | #include <sys/types.h> |
---|
39 | |
---|
40 | /** |
---|
41 | * @defgroup POSIX_MQUEUE POSIX Message Queues |
---|
42 | * |
---|
43 | * @ingroup POSIXAPI |
---|
44 | * |
---|
45 | */ |
---|
46 | /**@{**/ |
---|
47 | |
---|
48 | #ifdef __cplusplus |
---|
49 | extern "C" { |
---|
50 | #endif |
---|
51 | |
---|
52 | /* |
---|
53 | * 15.1.1 Data Structures, P1003.1b-1993, p. 271 |
---|
54 | */ |
---|
55 | |
---|
56 | /** |
---|
57 | * Message queue id type. |
---|
58 | * |
---|
59 | * NOTE: Use uint32_t since all POSIX Ids are 32-bit currently. |
---|
60 | */ |
---|
61 | typedef uint32_t mqd_t; |
---|
62 | |
---|
63 | /** |
---|
64 | * This is the message queue attributes structure. |
---|
65 | */ |
---|
66 | struct mq_attr { |
---|
67 | /** This is the message queue flags */ |
---|
68 | long mq_flags; |
---|
69 | /** This is the maximum number of messages */ |
---|
70 | long mq_maxmsg; |
---|
71 | /** This is the maximum message size */ |
---|
72 | long mq_msgsize; |
---|
73 | /** This is the mumber of messages currently queued */ |
---|
74 | long mq_curmsgs; |
---|
75 | }; |
---|
76 | |
---|
77 | /** |
---|
78 | * 15.2.2 Open a Message Queue, P1003.1b-1993, p. 272 |
---|
79 | */ |
---|
80 | mqd_t mq_open( |
---|
81 | const char *name, |
---|
82 | int oflag, |
---|
83 | ... |
---|
84 | ); |
---|
85 | |
---|
86 | /** |
---|
87 | * 15.2.2 Close a Message Queue, P1003.1b-1993, p. 275 |
---|
88 | */ |
---|
89 | int mq_close( |
---|
90 | mqd_t mqdes |
---|
91 | ); |
---|
92 | |
---|
93 | /** |
---|
94 | * @brief Remove a message queue. |
---|
95 | * |
---|
96 | * 15.2.2 Remove a Message Queue, P1003.1b-1993, p. 276 |
---|
97 | * |
---|
98 | * NOTE: The structure of the routines is identical to that of POSIX |
---|
99 | * Message_queues to leave the option of having unnamed message |
---|
100 | * queues at a future date. They are currently not part of the |
---|
101 | * POSIX standard but unnamed message_queues are. This is also |
---|
102 | * the reason for the apparently unnecessary tracking of |
---|
103 | * the process_shared attribute. [In addition to the fact that |
---|
104 | * it would be trivial to add pshared to the mq_attr structure |
---|
105 | * and have process private message queues.] |
---|
106 | * |
---|
107 | * This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open |
---|
108 | * time. |
---|
109 | */ |
---|
110 | int mq_unlink( |
---|
111 | const char *name |
---|
112 | ); |
---|
113 | |
---|
114 | /** |
---|
115 | * 15.2.4 Send a Message to a Message Queue, P1003.1b-1993, p. 277 |
---|
116 | * |
---|
117 | * NOTE; P1003.4b/D8, p. 45 adds mq_timedsend(). |
---|
118 | */ |
---|
119 | int mq_send( |
---|
120 | mqd_t mqdes, |
---|
121 | const char *msg_ptr, |
---|
122 | size_t msg_len, |
---|
123 | unsigned int msg_prio |
---|
124 | ); |
---|
125 | |
---|
126 | #if defined(_POSIX_TIMEOUTS) |
---|
127 | |
---|
128 | #include <time.h> |
---|
129 | |
---|
130 | /** |
---|
131 | * @brief Send a message to a message queue. |
---|
132 | * |
---|
133 | * @see mq_send() |
---|
134 | */ |
---|
135 | int mq_timedsend( |
---|
136 | mqd_t mqdes, |
---|
137 | const char *msg_ptr, |
---|
138 | size_t msg_len, |
---|
139 | unsigned int msg_prio, |
---|
140 | const struct timespec *abstime |
---|
141 | ); |
---|
142 | |
---|
143 | #endif /* _POSIX_TIMEOUTS */ |
---|
144 | |
---|
145 | /** |
---|
146 | * @brief Receive a message from a message queue. |
---|
147 | * |
---|
148 | * 15.2.5 Receive a Message From a Message Queue, P1003.1b-1993, p. 279 |
---|
149 | * |
---|
150 | * NOTE: P1003.4b/D8, p. 45 adds mq_timedreceive(). |
---|
151 | */ |
---|
152 | ssize_t mq_receive( |
---|
153 | mqd_t mqdes, |
---|
154 | char *msg_ptr, |
---|
155 | size_t msg_len, |
---|
156 | unsigned int *msg_prio |
---|
157 | ); |
---|
158 | |
---|
159 | #if defined(_POSIX_TIMEOUTS) |
---|
160 | |
---|
161 | ssize_t mq_timedreceive( |
---|
162 | mqd_t mqdes, |
---|
163 | char *__restrict msg_ptr, |
---|
164 | size_t msg_len, |
---|
165 | unsigned int *__restrict msg_prio, |
---|
166 | const struct timespec *__restrict abstime |
---|
167 | ); |
---|
168 | |
---|
169 | #endif /* _POSIX_TIMEOUTS */ |
---|
170 | |
---|
171 | #if defined(_POSIX_REALTIME_SIGNALS) |
---|
172 | |
---|
173 | /** |
---|
174 | * @brief Notify process that a message is available on a queue. |
---|
175 | * |
---|
176 | * 15.2.6 Notify Process that a Message is Available on a Queue, |
---|
177 | * P1003.1b-1993, p. 280 |
---|
178 | */ |
---|
179 | int mq_notify( |
---|
180 | mqd_t mqdes, |
---|
181 | const struct sigevent *notification |
---|
182 | ); |
---|
183 | |
---|
184 | #endif /* _POSIX_REALTIME_SIGNALS */ |
---|
185 | |
---|
186 | /** |
---|
187 | * @brief Set message queue attributes. |
---|
188 | * |
---|
189 | * 15.2.7 Set Message Queue Attributes, P1003.1b-1993, p. 281 |
---|
190 | */ |
---|
191 | int mq_setattr( |
---|
192 | mqd_t mqdes, |
---|
193 | const struct mq_attr *__restrict mqstat, |
---|
194 | struct mq_attr *__restrict omqstat |
---|
195 | ); |
---|
196 | |
---|
197 | /* |
---|
198 | * 15.2.8 Get Message Queue Attributes, P1003.1b-1993, p. 283 |
---|
199 | */ |
---|
200 | |
---|
201 | int mq_getattr( |
---|
202 | mqd_t mqdes, |
---|
203 | struct mq_attr *mqstat |
---|
204 | ); |
---|
205 | |
---|
206 | /** @} */ |
---|
207 | |
---|
208 | #ifdef __cplusplus |
---|
209 | } |
---|
210 | #endif |
---|
211 | |
---|
212 | #endif /* _POSIX_MESSAGE_PASSING */ |
---|
213 | |
---|
214 | #endif |
---|
215 | /* end of include file */ |
---|