1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Private Inlined Routines for POSIX Message Queue |
---|
5 | * |
---|
6 | * This include file contains the static inline implementation of the private |
---|
7 | * inlined routines for POSIX Message Queue. |
---|
8 | */ |
---|
9 | |
---|
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> |
---|
24 | #include <rtems/score/coremsgimpl.h> |
---|
25 | |
---|
26 | #include <rtems/seterr.h> |
---|
27 | |
---|
28 | #ifdef __cplusplus |
---|
29 | extern "C" { |
---|
30 | #endif |
---|
31 | |
---|
32 | /** |
---|
33 | * This defines the information control block used to manage |
---|
34 | * this class of objects. |
---|
35 | */ |
---|
36 | extern Objects_Information _POSIX_Message_queue_Information; |
---|
37 | |
---|
38 | /** |
---|
39 | * @brief Delete a POSIX Message Queue |
---|
40 | * |
---|
41 | * This routine supports the mq_unlink and mq_close routines by |
---|
42 | * doing most of the work involved with removing a message queue. |
---|
43 | */ |
---|
44 | void _POSIX_Message_queue_Delete( |
---|
45 | POSIX_Message_queue_Control *the_mq, |
---|
46 | ISR_lock_Context *lock_context |
---|
47 | ); |
---|
48 | |
---|
49 | /*@ |
---|
50 | * @brief POSIX Message Queue Receive Support |
---|
51 | * |
---|
52 | * This routine supports the various flavors of receiving a message. |
---|
53 | * |
---|
54 | * @note The structure of the routines is identical to that of POSIX |
---|
55 | * Message_queues to leave the option of having unnamed message |
---|
56 | * queues at a future date. They are currently not part of the |
---|
57 | * POSIX standard but unnamed message_queues are. This is also |
---|
58 | * the reason for the apparently unnecessary tracking of |
---|
59 | * the process_shared attribute. [In addition to the fact that |
---|
60 | * it would be trivial to add pshared to the mq_attr structure |
---|
61 | * and have process private message queues.] |
---|
62 | * |
---|
63 | * @note This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open time. |
---|
64 | */ |
---|
65 | ssize_t _POSIX_Message_queue_Receive_support( |
---|
66 | mqd_t mqdes, |
---|
67 | char *msg_ptr, |
---|
68 | size_t msg_len, |
---|
69 | unsigned int *msg_prio, |
---|
70 | bool wait, |
---|
71 | Watchdog_Interval timeout |
---|
72 | ); |
---|
73 | |
---|
74 | /** |
---|
75 | * @brief POSIX Message Queue Send Support |
---|
76 | * |
---|
77 | * This routine posts a message to a specified message queue. |
---|
78 | */ |
---|
79 | int _POSIX_Message_queue_Send_support( |
---|
80 | mqd_t mqdes, |
---|
81 | const char *msg_ptr, |
---|
82 | size_t msg_len, |
---|
83 | unsigned int msg_prio, |
---|
84 | bool wait, |
---|
85 | Watchdog_Interval timeout |
---|
86 | ); |
---|
87 | |
---|
88 | RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control * |
---|
89 | _POSIX_Message_queue_Allocate_unprotected( void ) |
---|
90 | { |
---|
91 | return (POSIX_Message_queue_Control *) |
---|
92 | _Objects_Allocate_unprotected( &_POSIX_Message_queue_Information ); |
---|
93 | } |
---|
94 | |
---|
95 | /** |
---|
96 | * @brief POSIX Message Queue Free |
---|
97 | * |
---|
98 | * This routine frees a message queue control block to the |
---|
99 | * inactive chain of free message queue control blocks. |
---|
100 | */ |
---|
101 | RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free( |
---|
102 | POSIX_Message_queue_Control *the_mq |
---|
103 | ) |
---|
104 | { |
---|
105 | _Objects_Free( &_POSIX_Message_queue_Information, &the_mq->Object ); |
---|
106 | } |
---|
107 | |
---|
108 | |
---|
109 | RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Get( |
---|
110 | Objects_Id id, |
---|
111 | ISR_lock_Context *lock_context |
---|
112 | ) |
---|
113 | { |
---|
114 | return (POSIX_Message_queue_Control *) |
---|
115 | _Objects_Get( id, lock_context, &_POSIX_Message_queue_Information ); |
---|
116 | } |
---|
117 | |
---|
118 | /* |
---|
119 | * @brief POSIX Message Queue Convert Message Priority to Score |
---|
120 | * |
---|
121 | * This method converts a POSIX message priority to the priorities used |
---|
122 | * by the Score. |
---|
123 | */ |
---|
124 | RTEMS_INLINE_ROUTINE CORE_message_queue_Submit_types |
---|
125 | _POSIX_Message_queue_Priority_to_core( |
---|
126 | unsigned int priority |
---|
127 | ) |
---|
128 | { |
---|
129 | return (CORE_message_queue_Submit_types) priority * -1; |
---|
130 | } |
---|
131 | |
---|
132 | |
---|
133 | /* |
---|
134 | * @brief POSIX Message Queue Convert Message Priority from Score |
---|
135 | * |
---|
136 | * This method converts a POSIX message priority from the priorities used |
---|
137 | * by the Score. |
---|
138 | */ |
---|
139 | RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core( |
---|
140 | CORE_message_queue_Submit_types priority |
---|
141 | ) |
---|
142 | { |
---|
143 | /* absolute value without a library dependency */ |
---|
144 | return (unsigned int) ((priority >= 0) ? priority : -priority); |
---|
145 | } |
---|
146 | |
---|
147 | /** |
---|
148 | * @brief POSIX Message Queue Translate Score Return Code |
---|
149 | * |
---|
150 | */ |
---|
151 | int _POSIX_Message_queue_Translate_core_message_queue_return_code( |
---|
152 | uint32_t the_message_queue_status |
---|
153 | ); |
---|
154 | |
---|
155 | /** |
---|
156 | * @brief POSIX Message Queue Remove from Namespace |
---|
157 | */ |
---|
158 | RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Namespace_remove ( |
---|
159 | POSIX_Message_queue_Control *the_mq |
---|
160 | ) |
---|
161 | { |
---|
162 | _Objects_Namespace_remove( |
---|
163 | &_POSIX_Message_queue_Information, &the_mq->Object ); |
---|
164 | } |
---|
165 | |
---|
166 | RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control * |
---|
167 | _POSIX_Message_queue_Get_by_name( |
---|
168 | const char *name, |
---|
169 | size_t *name_length_p, |
---|
170 | Objects_Get_by_name_error *error |
---|
171 | ) |
---|
172 | { |
---|
173 | return (POSIX_Message_queue_Control *) _Objects_Get_by_name( |
---|
174 | &_POSIX_Message_queue_Information, |
---|
175 | name, |
---|
176 | name_length_p, |
---|
177 | error |
---|
178 | ); |
---|
179 | } |
---|
180 | |
---|
181 | #ifdef __cplusplus |
---|
182 | } |
---|
183 | #endif |
---|
184 | |
---|
185 | #endif |
---|
186 | /* end of include file */ |
---|