blob: f75b506117f4c41a69f63e5b8f53b84fc792dcfc [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
18
19#ifndef _MQUEUE_H
20#define _MQUEUE_H 1
21
22#include <features.h>
23#if defined __UCLIBC_HAS_REALTIME__ || \
24 defined __UCLIBC_HAS_ADVANCED_REALTIME__
25#include <sys/types.h>
26#include <fcntl.h>
27#define __need_sigevent_t
28#include <bits/siginfo.h>
29#define __need_timespec
30#include <time.h>
31/* Get the definition of mqd_t and struct mq_attr. */
32#include <bits/mqueue.h>
33#endif
34
35__BEGIN_DECLS
36#if defined __UCLIBC_HAS_REALTIME__
37/* Establish connection between a process and a message queue NAME and
38 return message queue descriptor or (mqd_t) -1 on error. OFLAG determines
39 the type of access used. If O_CREAT is on OFLAG, the third argument is
40 taken as a `mode_t', the mode of the created message queue, and the fourth
41 argument is taken as `struct mq_attr *', pointer to message queue
42 attributes. If the fourth argument is NULL, default attributes are
43 used. */
44extern mqd_t mq_open (const char *__name, int __oflag, ...) __THROW;
45
46/* Removes the association between message queue descriptor MQDES and its
47 message queue. */
48extern int mq_close (mqd_t __mqdes) __THROW;
49
50/* Query status and attributes of message queue MQDES. */
51extern int mq_getattr (mqd_t __mqdes, struct mq_attr *__mqstat) __THROW;
52
53/* Set attributes associated with message queue MQDES and if OMQSTAT is
54 not NULL also query its old attributes. */
55extern int mq_setattr (mqd_t __mqdes,
56 const struct mq_attr *__restrict __mqstat,
57 struct mq_attr *__restrict __omqstat) __THROW;
58
59/* Remove message queue named NAME. */
60extern int mq_unlink (const char *__name) __THROW;
61
62/* Register notification issued upon message arrival to an empty
63 message queue MQDES. */
64extern int mq_notify (mqd_t __mqdes, const struct sigevent *__notification)
65 __THROW;
66
67/* Receive the oldest from highest priority messages in message queue
68 MQDES. */
69extern ssize_t mq_receive (mqd_t __mqdes, char *__msg_ptr, size_t __msg_len,
70 unsigned int *__msg_prio);
71
72/* Add message pointed by MSG_PTR to message queue MQDES. */
73extern int mq_send (mqd_t __mqdes, const char *__msg_ptr, size_t __msg_len,
74 unsigned int __msg_prio);
75#endif
76
77#if defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__
78/* Receive the oldest from highest priority messages in message queue
79 MQDES, stop waiting if ABS_TIMEOUT expires. */
80extern ssize_t mq_timedreceive (mqd_t __mqdes, char *__restrict __msg_ptr,
81 size_t __msg_len,
82 unsigned int *__restrict __msg_prio,
83 const struct timespec *__restrict __abs_timeout);
84
85/* Add message pointed by MSG_PTR to message queue MQDES, stop blocking
86 on full message queue if ABS_TIMEOUT expires. */
87extern int mq_timedsend (mqd_t __mqdes, const char *__msg_ptr,
88 size_t __msg_len, unsigned int __msg_prio,
89 const struct timespec *__abs_timeout);
90#endif
91
92__END_DECLS
93
94#endif /* mqueue.h */