RTEMS CPU Kit with SuperCore  4.11.3
mqueueimpl.h
Go to the documentation of this file.
1 
10 /*
11  * COPYRIGHT (c) 1989-2013.
12  * On-Line Applications Research Corporation (OAR).
13  *
14  * The license and distribution terms for this file may be
15  * found in the file LICENSE in this distribution or at
16  * http://www.rtems.org/license/LICENSE.
17  */
18 
19 #ifndef _RTEMS_POSIX_MQUEUE_INL
20 #define _RTEMS_POSIX_MQUEUE_INL
21 
22 #include <rtems/posix/mqueue.h>
23 #include <rtems/posix/posixapi.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
35 
41 
60 
68  const char *name,
69  size_t name_len,
70  int pshared,
71  struct mq_attr *attr,
72  POSIX_Message_queue_Control **message_queue
73 );
74 
83 );
84 
85 /*@
86  * @brief POSIX Message Queue Receive Support
87  *
88  * This routine supports the various flavors of receiving a message.
89  *
90  * @note The structure of the routines is identical to that of POSIX
91  * Message_queues to leave the option of having unnamed message
92  * queues at a future date. They are currently not part of the
93  * POSIX standard but unnamed message_queues are. This is also
94  * the reason for the apparently unnecessary tracking of
95  * the process_shared attribute. [In addition to the fact that
96  * it would be trivial to add pshared to the mq_attr structure
97  * and have process private message queues.]
98  *
99  * @note This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open time.
100  */
101 ssize_t _POSIX_Message_queue_Receive_support(
102  mqd_t mqdes,
103  char *msg_ptr,
104  size_t msg_len,
105  unsigned int *msg_prio,
106  bool wait,
107  Watchdog_Interval timeout
108 );
109 
116  mqd_t mqdes,
117  const char *msg_ptr,
118  size_t msg_len,
119  unsigned int msg_prio,
120  bool wait,
121  Watchdog_Interval timeout
122 );
123 
132 {
133  return (POSIX_Message_queue_Control *)
134  _Objects_Allocate( &_POSIX_Message_queue_Information );
135 }
136 
145 )
146 {
147  _Objects_Free( &_POSIX_Message_queue_Information, &the_mq->Object );
148 }
149 
150 
163  Objects_Id id,
164  Objects_Locations *location
165 )
166 {
167  return (POSIX_Message_queue_Control *)
168  _Objects_Get( &_POSIX_Message_queue_Information, id, location );
169 }
170 
171 /*
172  * @brief POSIX Message Queue Convert Message Priority to Score
173  *
174  * This method converts a POSIX message priority to the priorities used
175  * by the Score.
176  */
178  _POSIX_Message_queue_Priority_to_core(
179  unsigned int priority
180 )
181 {
182  return (CORE_message_queue_Submit_types) priority * -1;
183 }
184 
185 
186 /*
187  * @brief POSIX Message Queue Convert Message Priority from Score
188  *
189  * This method converts a POSIX message priority from the priorities used
190  * by the Score.
191  */
192 RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core(
194 )
195 {
196  /* absolute value without a library dependency */
197  return (unsigned int) ((priority >= 0) ? priority : -priority);
198 }
199 
205  uint32_t the_message_queue_status
206 );
207 
213 {
215  _Objects_Allocate( &_POSIX_Message_queue_Information_fds );
216 }
217 
223 )
224 {
225  _Objects_Free( &_POSIX_Message_queue_Information_fds, &the_mq_fd->Object );
226 }
227 
233 )
234 {
236  &_POSIX_Message_queue_Information, &the_mq->Object );
237 }
238 
239 /*
240  * @brief POSIX Message Queue Get File Descriptor
241  */
242 RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control_fd *_POSIX_Message_queue_Get_fd (
243  mqd_t id,
244  Objects_Locations *location
245 )
246 {
248  &_POSIX_Message_queue_Information_fds,
249  (Objects_Id)id,
250  location
251  );
252 }
253 
255 _POSIX_Message_queue_Get_fd_interrupt_disable(
256  mqd_t id,
257  Objects_Locations *location,
258  ISR_lock_Context *lock_context
259 )
260 {
262  &_POSIX_Message_queue_Information_fds,
263  (Objects_Id)id,
264  location,
265  lock_context
266  );
267 }
268 
273  const char *name,
274  Objects_Id *id,
275  size_t *len
276 )
277 {
278  return _POSIX_Name_to_id( &_POSIX_Message_queue_Information, name, id, len );
279 }
280 
281 #ifdef __cplusplus
282 }
283 #endif
284 
285 #endif
286 /* end of include file */
void _Objects_Free(Objects_Information *information, Objects_Control *the_object)
Frees an object.
Definition: objectfree.c:25
Inlined Routines in the Core Message Handler.
Objects_Control * _Objects_Allocate(Objects_Information *information)
Allocates an object.
Definition: objectallocate.c:101
POSIX API Implementation.
#define RTEMS_INLINE_ROUTINE
The following (in conjunction with compiler arguments) are used to choose between the use of static i...
Definition: basedefs.h:135
int CORE_message_queue_Submit_types
The modes in which a message may be submitted to a message queue.
Definition: coremsgimpl.h:65
RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control * _POSIX_Message_queue_Allocate(void)
POSIX Message Queue Allocate.
Definition: mqueueimpl.h:131
Objects_Control * _Objects_Get(Objects_Information *information, Objects_Id id, Objects_Locations *location)
Maps object ids to object control blocks.
Definition: objectget.c:23
RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control * _POSIX_Message_queue_Get(Objects_Id id, Objects_Locations *location)
POSIX Message Queue Get.
Definition: mqueueimpl.h:162
Definition: mqueue.h:65
RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Namespace_remove(POSIX_Message_queue_Control *the_mq)
POSIX Message Queue Remove from Namespace.
Definition: mqueueimpl.h:231
RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free_fd(POSIX_Message_queue_Control_fd *the_mq_fd)
POSIX Message Queue Free File Descriptor.
Definition: mqueueimpl.h:221
int _POSIX_Name_to_id(Objects_Information *information, const char *name, Objects_Id *id, size_t *len)
Queries the object identifier id for a name.
Definition: psxnametoid.c:30
RTEMS_INLINE_ROUTINE int _POSIX_Message_queue_Name_to_id(const char *name, Objects_Id *id, size_t *len)
Definition: mqueueimpl.h:272
The following defines the structure for the information used to manage each class of objects...
Definition: objectimpl.h:136
POSIX_EXTERN Objects_Information _POSIX_Message_queue_Information
This defines the information control block used to manage this class of objects.
Definition: mqueueimpl.h:34
POSIX_EXTERN Objects_Information _POSIX_Message_queue_Information_fds
The is used to manage the set of "file descriptors" associated with the message queues.
Definition: mqueueimpl.h:40
POSIX Message Queues Private Private Support.
RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control_fd * _POSIX_Message_queue_Allocate_fd(void)
POSIX Message Queue Allocate File Descriptor.
Definition: mqueueimpl.h:212
RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free(POSIX_Message_queue_Control *the_mq)
POSIX Message Queue Free.
Definition: mqueueimpl.h:143
int _POSIX_Message_queue_Create_support(const char *name, size_t name_len, int pshared, struct mq_attr *attr, POSIX_Message_queue_Control **message_queue)
POSIX Message Queue Create Support.
Definition: mqueuecreatesupp.c:51
int _POSIX_Message_queue_Translate_core_message_queue_return_code(uint32_t the_message_queue_status)
POSIX Message Queue Translate Score Return Code.
Definition: mqueuetranslatereturncode.c:54
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdog.h:47
int _POSIX_Message_queue_Send_support(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, bool wait, Watchdog_Interval timeout)
POSIX Message Queue Send Support.
Definition: mqueuesendsupp.c:52
Objects_Locations
This enumerated type lists the locations which may be returned by _Objects_Get.
Definition: objectimpl.h:117
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
Definition: mqueue.h:55
uint32_t Objects_Id
The following type defines the control block used to manage object IDs.
Definition: object.h:122
Objects_Control * _Objects_Get_isr_disable(Objects_Information *information, Objects_Id id, Objects_Locations *location, ISR_lock_Context *lock_context)
Maps object ids to object control blocks.
Definition: objectgetisr.c:23
#define POSIX_EXTERN
The following ensures that all data is declared in the space of the initialization routine for either...
Definition: basedefs.h:123
void _Objects_Namespace_remove(Objects_Information *information, Objects_Control *the_object)
Removes object from namespace.
Definition: objectnamespaceremove.c:25
void _POSIX_Message_queue_Manager_initialization(void)
Initialize message_queue manager related data structures.
Definition: mqueue.c:46
void _POSIX_Message_queue_Delete(POSIX_Message_queue_Control *the_mq)
Delete a POSIX Message Queue.
Definition: mqueuedeletesupp.c:39