source: rtems/cpukit/include/rtems/posix/mqueueimpl.h @ 21275b58

5
Last change on this file since 21275b58 was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on 11/22/18 at 18:14:51

score: Static Objects_Information initialization

Statically allocate the objects information together with the initial
set of objects either via <rtems/confdefs.h>. Provide default object
informations with zero objects via librtemscpu.a. This greatly
simplifies the workspace size estimate. RTEMS applications which do not
use the unlimited objects option are easier to debug since all objects
reside now in statically allocated objects of the right types.

Close #3621.

  • Property mode set to 100644
File size: 4.7 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 * @brief Delete a POSIX Message Queue
35 *
36 * This routine supports the mq_unlink and mq_close routines by
37 * doing most of the work involved with removing a message queue.
38 */
39void _POSIX_Message_queue_Delete(
40  POSIX_Message_queue_Control *the_mq,
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 */
60ssize_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
69/**
70 *  @brief POSIX Message Queue Send Support
71 *
72 *  This routine posts a message to a specified message queue.
73 */
74int _POSIX_Message_queue_Send_support(
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
83RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *
84  _POSIX_Message_queue_Allocate_unprotected( void )
85{
86  return (POSIX_Message_queue_Control *)
87    _Objects_Allocate_unprotected( &_POSIX_Message_queue_Information );
88}
89
90/**
91 *  @brief POSIX Message Queue Free
92 *
93 *  This routine frees a message queue control block to the
94 *  inactive chain of free message queue control blocks.
95 */
96RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free(
97  POSIX_Message_queue_Control *the_mq
98)
99{
100  _Objects_Free( &_POSIX_Message_queue_Information, &the_mq->Object );
101}
102
103
104RTEMS_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 );
110  return (POSIX_Message_queue_Control *) _Objects_Get(
111    id,
112    &queue_context->Lock_context.Lock_context,
113    &_POSIX_Message_queue_Information
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 */
123RTEMS_INLINE_ROUTINE CORE_message_queue_Submit_types
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 */
138RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core(
139  CORE_message_queue_Submit_types priority
140)
141{
142  /* absolute value without a library dependency */
143  return (unsigned int) ((priority >= 0) ? priority : -priority);
144}
145
146/**
147 *  @brief POSIX Message Queue Remove from Namespace
148 */
149RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Namespace_remove (
150  POSIX_Message_queue_Control *the_mq
151)
152{
153  _Objects_Namespace_remove_string(
154    &_POSIX_Message_queue_Information,
155    &the_mq->Object
156  );
157}
158
159RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *
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{
166  return (POSIX_Message_queue_Control *) _Objects_Get_by_name(
167    &_POSIX_Message_queue_Information,
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 */
Note: See TracBrowser for help on using the repository browser.