RTEMS  5.0.0
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>
26 
27 #include <rtems/seterr.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
41  Thread_queue_Context *queue_context
42 );
43 
44 /*@
45  * @brief POSIX Message Queue Receive Support
46  *
47  * This routine supports the various flavors of receiving a message.
48  *
49  * @note The structure of the routines is identical to that of POSIX
50  * Message_queues to leave the option of having unnamed message
51  * queues at a future date. They are currently not part of the
52  * POSIX standard but unnamed message_queues are. This is also
53  * the reason for the apparently unnecessary tracking of
54  * the process_shared attribute. [In addition to the fact that
55  * it would be trivial to add pshared to the mq_attr structure
56  * and have process private message queues.]
57  *
58  * @note This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open time.
59  */
60 ssize_t _POSIX_Message_queue_Receive_support(
61  mqd_t mqdes,
62  char *msg_ptr,
63  size_t msg_len,
64  unsigned int *msg_prio,
65  const struct timespec *abstime,
66  Thread_queue_Enqueue_callout enqueue_callout
67 );
68 
75  mqd_t mqdes,
76  const char *msg_ptr,
77  size_t msg_len,
78  unsigned int msg_prio,
79  const struct timespec *abstime,
80  Thread_queue_Enqueue_callout enqueue_callout
81 );
82 
84  _POSIX_Message_queue_Allocate_unprotected( void )
85 {
88 }
89 
98 )
99 {
100  _Objects_Free( &_POSIX_Message_queue_Information, &the_mq->Object );
101 }
102 
103 
104 RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Get(
105  Objects_Id id,
106  Thread_queue_Context *queue_context
107 )
108 {
109  _Thread_queue_Context_initialize( queue_context );
111  id,
112  &queue_context->Lock_context.Lock_context,
114  );
115 }
116 
117 /*
118  * @brief POSIX Message Queue Convert Message Priority to Score
119  *
120  * This method converts a POSIX message priority to the priorities used
121  * by the Score.
122  */
124  _POSIX_Message_queue_Priority_to_core(
125  unsigned int priority
126 )
127 {
128  return (CORE_message_queue_Submit_types) priority * -1;
129 }
130 
131 
132 /*
133  * @brief POSIX Message Queue Convert Message Priority from Score
134  *
135  * This method converts a POSIX message priority from the priorities used
136  * by the Score.
137  */
138 RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core(
140 )
141 {
142  /* absolute value without a library dependency */
143  return (unsigned int) ((priority >= 0) ? priority : -priority);
144 }
145 
151 )
152 {
155  &the_mq->Object
156  );
157 }
158 
160 _POSIX_Message_queue_Get_by_name(
161  const char *name,
162  size_t *name_length_p,
163  Objects_Get_by_name_error *error
164 )
165 {
168  name,
169  name_length_p,
170  error
171  );
172 }
173 
174 #ifdef __cplusplus
175 }
176 #endif
177 
178 #endif
179 /* end of include file */
void _Objects_Free(Objects_Information *information, Objects_Control *the_object)
Frees an object.
Definition: objectfree.c:25
Data which Ease the Burden of Consistently Setting Errno.
Objects_Control * _Objects_Allocate_unprotected(Objects_Information *information)
Allocates an object without locking the allocator mutex.
Definition: objectallocate.c:33
Objects_Control * _Objects_Get_by_name(const Objects_Information *information, const char *name, size_t *name_length_p, Objects_Get_by_name_error *error)
Gets an object control block identified by its name.
Definition: objectnametoidstring.c:25
Thread queue context for the thread queue methods.
Definition: threadq.h:193
Inlined Routines in the Core Message Handler.
POSIX API Implementation.
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:65
Objects_Control * _Objects_Get(Objects_Id id, ISR_lock_Context *lock_context, const Objects_Information *information)
Maps the specified object identifier to the associated local object control block.
Definition: objectgetlocal.c:28
int CORE_message_queue_Submit_types
The modes in which a message may be submitted to a message queue.
Definition: coremsgimpl.h:66
void _POSIX_Message_queue_Delete(POSIX_Message_queue_Control *the_mq, Thread_queue_Context *queue_context)
Delete a POSIX Message Queue.
Definition: mqueuedeletesupp.c:23
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize(Thread_queue_Context *queue_context)
Initializes a thread queue context.
Definition: threadqimpl.h:108
void _Objects_Namespace_remove_string(const Objects_Information *information, Objects_Control *the_object)
Removes object with a string name from its namespace.
Definition: objectnamespaceremove.c:34
RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Namespace_remove(POSIX_Message_queue_Control *the_mq)
POSIX Message Queue Remove from Namespace.
Definition: mqueueimpl.h:149
Objects_Information _POSIX_Message_queue_Information
The POSIX Message Queue objects information.
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:198
void(* Thread_queue_Enqueue_callout)(Thread_queue_Queue *queue, Thread_Control *the_thread, struct Per_CPU_Control *cpu_self, Thread_queue_Context *queue_context)
Thread queue enqueue callout.
Definition: threadq.h:67
POSIX Message Queues Private Private Support.
RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free(POSIX_Message_queue_Control *the_mq)
POSIX Message Queue Free.
Definition: mqueueimpl.h:96
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:125
Definition: mqueue.h:57
uint32_t Objects_Id
Definition: object.h:75
int _POSIX_Message_queue_Send_support(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec *abstime, Thread_queue_Enqueue_callout enqueue_callout)
POSIX Message Queue Send Support.
Definition: mqueuesendsupp.c:37