source: rtems/cpukit/include/mqueue.h

Last change on this file was 3d435898, checked in by Joel Sherrill <joel@…>, on 03/25/22 at 16:02:56

cpukit/include/*.h: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 5.8 KB
RevLine 
[3d435898]1/* SPDX-License-Identifier: BSD-2-Clause */
2
[6c2675d]3/**
[3cf4031]4 * @file
[21242c2]5 *
[3cf4031]6 * @brief POSIX Message Queues
7 *
[21242c2]8 * This file contains the definitions related to POSIX Message Queues.
[e43f4758]9 *
10 * The structure of the routines is identical to that of POSIX
11 * Message_queues to leave the option of having unnamed message
12 * queues at a future date.  They are currently not part of the
13 * POSIX standard but unnamed message_queues are.  This is also
14 * the reason for the apparently unnecessary tracking of
15 * the process_shared attribute.  [In addition to the fact that
16 * it would be trivial to add pshared to the mq_attr structure
17 * and have process private message queues.]
18 *
19 * This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open
20 * time.
[6c2675d]21 */
22
23/*
[21242c2]24 *  COPYRIGHT (c) 1989-2011.
[feaa007]25 *  On-Line Applications Research Corporation (OAR).
26 *
[3d435898]27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 *    notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 *    notice, this list of conditions and the following disclaimer in the
34 *    documentation and/or other materials provided with the distribution.
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
37 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
40 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
41 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
42 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
43 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
44 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46 * POSSIBILITY OF SUCH DAMAGE.
[5e9b32b]47 */
48
[5ec2f12d]49#ifndef _MQUEUE_H
50#define _MQUEUE_H
[5e9b32b]51
[c7aa9d6]52
[0ff3df03]53#include <unistd.h>
[5e9b32b]54
55#if defined(_POSIX_MESSAGE_PASSING)
56
57#include <sys/types.h>
58
[a0e6c73]59/**
[cf301c9]60 * @defgroup POSIX_MQUEUE POSIX Message Queues
[a0e6c73]61 *
[a15eaaf]62 * @ingroup POSIXAPI
[cf301c9]63 *
[a0e6c73]64 */
[b697bc6]65/**@{**/
[a0e6c73]66
[b69e6cd]67#ifdef __cplusplus
68extern "C" {
69#endif
70
[5e9b32b]71/*
72 *  15.1.1 Data Structures, P1003.1b-1993, p. 271
73 */
74
[6a0898b]75/**
[cf301c9]76 * Message queue id type.
[3507c6df]77 *
[cf301c9]78 * NOTE: Use uint32_t since all POSIX Ids are 32-bit currently.
[6a0898b]79 */
[3507c6df]80typedef uint32_t  mqd_t;
[5e9b32b]81
[6a0898b]82/**
[cf301c9]83 * This is the message queue attributes structure.
[6a0898b]84 */
[5e9b32b]85struct mq_attr {
[6a0898b]86  /** This is the message queue flags */
87  long  mq_flags;
88  /** This is the maximum number of messages */
89  long  mq_maxmsg;
90  /** This is the maximum message size */
91  long  mq_msgsize;
92  /** This is the mumber of messages currently queued */
93  long  mq_curmsgs;
[5e9b32b]94};
95
[6a0898b]96/**
[cf301c9]97 * 15.2.2 Open a Message Queue, P1003.1b-1993, p. 272
[5e9b32b]98 */
99mqd_t mq_open(
100  const char *name,
101  int         oflag,
102  ...
103);
104
[6a0898b]105/**
[cf301c9]106 * 15.2.2 Close a Message Queue, P1003.1b-1993, p. 275
[5e9b32b]107 */
108int mq_close(
109  mqd_t  mqdes
110);
111
[6a0898b]112/**
[cf301c9]113 * @brief Remove a message queue.
[a0e6c73]114 *
[cf301c9]115 * 15.2.2 Remove a Message Queue, P1003.1b-1993, p. 276
[a0e6c73]116 *
[cf301c9]117 * NOTE:  The structure of the routines is identical to that of POSIX
118 *        Message_queues to leave the option of having unnamed message
119 *        queues at a future date.  They are currently not part of the
120 *        POSIX standard but unnamed message_queues are.  This is also
121 *        the reason for the apparently unnecessary tracking of
122 *        the process_shared attribute.  [In addition to the fact that
123 *        it would be trivial to add pshared to the mq_attr structure
124 *        and have process private message queues.]
[a0e6c73]125 *
[cf301c9]126 *        This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open
127 *        time.
[5e9b32b]128 */
129int mq_unlink(
130  const char *name
131);
132
[6a0898b]133/**
[cf301c9]134 * 15.2.4 Send a Message to a Message Queue, P1003.1b-1993, p. 277
[5e9b32b]135 *
[cf301c9]136 * NOTE; P1003.4b/D8, p. 45 adds mq_timedsend().
[5e9b32b]137 */
138int mq_send(
139  mqd_t         mqdes,
140  const char   *msg_ptr,
141  size_t        msg_len,
[874297f3]142  unsigned int  msg_prio
[5e9b32b]143);
144
145#if defined(_POSIX_TIMEOUTS)
146
147#include <time.h>
148
[e43f4758]149/**
[cf301c9]150 * @brief Send a message to a message queue.
[e43f4758]151 *
[cf301c9]152 * @see mq_send()
[e43f4758]153 */
[5e9b32b]154int mq_timedsend(
155  mqd_t                  mqdes,
156  const char            *msg_ptr,
157  size_t                 msg_len,
158  unsigned int           msg_prio,
[6a0898b]159  const struct timespec *abstime
[5e9b32b]160);
161
162#endif /* _POSIX_TIMEOUTS */
163
[e43f4758]164/**
[cf301c9]165 * @brief Receive a message from a message queue.
[e43f4758]166 *
[cf301c9]167 * 15.2.5 Receive a Message From a Message Queue, P1003.1b-1993, p. 279
[5e9b32b]168 *
[cf301c9]169 * NOTE: P1003.4b/D8, p. 45 adds mq_timedreceive().
[5e9b32b]170 */
171ssize_t mq_receive(
172  mqd_t         mqdes,
173  char         *msg_ptr,
174  size_t        msg_len,
175  unsigned int *msg_prio
176);
177
178#if defined(_POSIX_TIMEOUTS)
179
[fffda815]180ssize_t mq_timedreceive(
[5e9b32b]181  mqd_t                  mqdes,
[f74a492c]182  char                  *__restrict msg_ptr,
[5e9b32b]183  size_t                 msg_len,
[f74a492c]184  unsigned int          *__restrict msg_prio,
185  const struct timespec *__restrict abstime
[5e9b32b]186);
187
188#endif /* _POSIX_TIMEOUTS */
189
190#if defined(_POSIX_REALTIME_SIGNALS)
191
[d86308b]192/**
[cf301c9]193 * @brief Notify process that a message is available on a queue.
[d86308b]194 *
195 * 15.2.6 Notify Process that a Message is Available on a Queue,
196 *        P1003.1b-1993, p. 280
[5e9b32b]197 */
198int mq_notify(
199  mqd_t                  mqdes,
200  const struct sigevent *notification
201);
202
203#endif /* _POSIX_REALTIME_SIGNALS */
204
[d86308b]205/**
[cf301c9]206 * @brief Set message queue attributes.
[d86308b]207 *
208 * 15.2.7 Set Message Queue Attributes, P1003.1b-1993, p. 281
[5e9b32b]209 */
210int mq_setattr(
211  mqd_t                 mqdes,
[f74a492c]212  const struct mq_attr *__restrict mqstat,
213  struct mq_attr       *__restrict omqstat
[5e9b32b]214);
215
216/*
217 *  15.2.8 Get Message Queue Attributes, P1003.1b-1993, p. 283
218 */
219
220int mq_getattr(
221  mqd_t           mqdes,
222  struct mq_attr *mqstat
223);
224
[cf301c9]225/** @} */
226
[c7aa9d6]227#ifdef __cplusplus
228}
229#endif
230
[b69e6cd]231#endif /* _POSIX_MESSAGE_PASSING */
[cf301c9]232
[5e9b32b]233#endif
234/* end of include file */
Note: See TracBrowser for help on using the repository browser.