source: rtems/cpukit/include/rtems/posix/mqueueimpl.h @ 7038271

Last change on this file since 7038271 was 7038271, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 25, 2018 at 10:05:53 AM

Remove RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES

Enable support for string objects names unconditionally. Add const
qualifier throughout. Split _Objects_Namespace_remove() into
_Objects_Namespace_remove_u32() and _Objects_Namespace_remove_string()
to avoid an unnecessary dependency on _Workspace_Free().

Update #2514.

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