RTEMS 6.3
Loading...
Searching...
No Matches
mqueueimpl.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11
12/*
13 * COPYRIGHT (c) 1989-2013.
14 * On-Line Applications Research Corporation (OAR).
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _RTEMS_POSIX_MQUEUE_INL
39#define _RTEMS_POSIX_MQUEUE_INL
40
41#include <rtems/posix/mqueue.h>
45
46#include <rtems/seterr.h>
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
60 Thread_queue_Context *queue_context
61);
62
63/*@
64 * @brief POSIX Message Queue Receive Support
65 *
66 * This routine supports the various flavors of receiving a message.
67 *
68 * @note The structure of the routines is identical to that of POSIX
69 * Message_queues to leave the option of having unnamed message
70 * queues at a future date. They are currently not part of the
71 * POSIX standard but unnamed message_queues are. This is also
72 * the reason for the apparently unnecessary tracking of
73 * the process_shared attribute. [In addition to the fact that
74 * it would be trivial to add pshared to the mq_attr structure
75 * and have process private message queues.]
76 *
77 * @note This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open time.
78 */
79ssize_t _POSIX_Message_queue_Receive_support(
80 mqd_t mqdes,
81 char *msg_ptr,
82 size_t msg_len,
83 unsigned int *msg_prio,
84 const struct timespec *abstime,
85 Thread_queue_Enqueue_callout enqueue_callout
86);
87
94 mqd_t mqdes,
95 const char *msg_ptr,
96 size_t msg_len,
97 unsigned int msg_prio,
98 const struct timespec *abstime,
99 Thread_queue_Enqueue_callout enqueue_callout
100);
101
102static inline POSIX_Message_queue_Control *
103 _POSIX_Message_queue_Allocate_unprotected( void )
104{
106 _Objects_Allocate_unprotected( &_POSIX_Message_queue_Information );
107}
108
115static inline void _POSIX_Message_queue_Free(
117)
118{
119 _Objects_Free( &_POSIX_Message_queue_Information, &the_mq->Object );
120}
121
122
123static inline POSIX_Message_queue_Control *_POSIX_Message_queue_Get(
124 Objects_Id id,
125 Thread_queue_Context *queue_context
126)
127{
128 _Thread_queue_Context_initialize( queue_context );
130 id,
131 &queue_context->Lock_context.Lock_context,
133 );
134}
135
136/*
137 * @brief POSIX Message Queue Convert Message Priority to Score
138 *
139 * This method converts a POSIX message priority to the priorities used
140 * by the Score.
141 */
143 _POSIX_Message_queue_Priority_to_core(
144 unsigned int priority
145)
146{
147 return (CORE_message_queue_Submit_types) priority * -1;
148}
149
150
151/*
152 * @brief POSIX Message Queue Convert Message Priority from Score
153 *
154 * This method converts a POSIX message priority from the priorities used
155 * by the Score.
156 */
157static inline unsigned int _POSIX_Message_queue_Priority_from_core(
159)
160{
161 /* absolute value without a library dependency */
162 return (unsigned int) ((priority >= 0) ? priority : -priority);
163}
164
168static inline void _POSIX_Message_queue_Namespace_remove (
170)
171{
174 &the_mq->Object
175 );
176}
177
178static inline POSIX_Message_queue_Control *
179_POSIX_Message_queue_Get_by_name(
180 const char *name,
181 size_t *name_length_p,
182 Objects_Get_by_name_error *error
183)
184{
187 name,
188 name_length_p,
189 error
190 );
191}
192
193#ifdef __cplusplus
194}
195#endif
196
197#endif
198/* end of include file */
This header file provides interfaces of the Message Queue Handler which are used by the implementatio...
Objects_Information _POSIX_Message_queue_Information
The POSIX Message Queue objects information.
int CORE_message_queue_Submit_types
The modes in which a message may be submitted to a message queue.
Definition coremsgimpl.h:87
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:46
uint32_t Objects_Id
Definition object.h:101
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:43
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:45
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:90
void _POSIX_Message_queue_Delete(POSIX_Message_queue_Control *the_mq, Thread_queue_Context *queue_context)
Delete a POSIX Message Queue.
Definition mqueuedeletesupp.c:42
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:57
This header file provides interfaces used by the POSIX API implementation.
POSIX Message Queues Private Private Support.
This header file defines macros to set errno and return minus one.
Definition mqueue.h:76
Thread queue context for the thread queue methods.
Definition threadq.h:216
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition threadq.h:221
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition threadq.h:148
This header file provides interfaces of the Thread Queue Handler which are only used by the implement...