xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1 | /* Copyright (C) 2004-2016 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, see |
| 16 | <http://www.gnu.org/licenses/>. */ |
| 17 | |
| 18 | #ifndef _MQUEUE_H |
| 19 | #define _MQUEUE_H 1 |
| 20 | |
| 21 | #include <features.h> |
| 22 | #include <sys/types.h> |
| 23 | #include <fcntl.h> |
| 24 | #define __need_sigevent_t |
| 25 | #include <bits/siginfo.h> |
| 26 | #define __need_timespec |
| 27 | #include <time.h> |
| 28 | /* Get the definition of mqd_t and struct mq_attr. */ |
| 29 | #include <bits/mqueue.h> |
| 30 | |
| 31 | __BEGIN_DECLS |
| 32 | |
| 33 | /* Establish connection between a process and a message queue NAME and |
| 34 | return message queue descriptor or (mqd_t) -1 on error. OFLAG determines |
| 35 | the type of access used. If O_CREAT is on OFLAG, the third argument is |
| 36 | taken as a `mode_t', the mode of the created message queue, and the fourth |
| 37 | argument is taken as `struct mq_attr *', pointer to message queue |
| 38 | attributes. If the fourth argument is NULL, default attributes are |
| 39 | used. */ |
| 40 | extern mqd_t mq_open (const char *__name, int __oflag, ...) |
| 41 | __THROW __nonnull ((1)); |
| 42 | |
| 43 | /* Removes the association between message queue descriptor MQDES and its |
| 44 | message queue. */ |
| 45 | extern int mq_close (mqd_t __mqdes) __THROW; |
| 46 | |
| 47 | /* Query status and attributes of message queue MQDES. */ |
| 48 | extern int mq_getattr (mqd_t __mqdes, struct mq_attr *__mqstat) |
| 49 | __THROW __nonnull ((2)); |
| 50 | |
| 51 | /* Set attributes associated with message queue MQDES and if OMQSTAT is |
| 52 | not NULL also query its old attributes. */ |
| 53 | extern int mq_setattr (mqd_t __mqdes, |
| 54 | const struct mq_attr *__restrict __mqstat, |
| 55 | struct mq_attr *__restrict __omqstat) |
| 56 | __THROW __nonnull ((2)); |
| 57 | |
| 58 | /* Remove message queue named NAME. */ |
| 59 | extern int mq_unlink (const char *__name) __THROW __nonnull ((1)); |
| 60 | |
| 61 | /* Register notification issued upon message arrival to an empty |
| 62 | message queue MQDES. */ |
| 63 | extern int mq_notify (mqd_t __mqdes, const struct sigevent *__notification) |
| 64 | __THROW; |
| 65 | |
| 66 | /* Receive the oldest from highest priority messages in message queue |
| 67 | MQDES. */ |
| 68 | extern ssize_t mq_receive (mqd_t __mqdes, char *__msg_ptr, size_t __msg_len, |
| 69 | unsigned int *__msg_prio) __nonnull ((2)); |
| 70 | |
| 71 | /* Add message pointed by MSG_PTR to message queue MQDES. */ |
| 72 | extern int mq_send (mqd_t __mqdes, const char *__msg_ptr, size_t __msg_len, |
| 73 | unsigned int __msg_prio) __nonnull ((2)); |
| 74 | |
| 75 | #ifdef __USE_XOPEN2K |
| 76 | /* Receive the oldest from highest priority messages in message queue |
| 77 | MQDES, stop waiting if ABS_TIMEOUT expires. */ |
| 78 | extern ssize_t mq_timedreceive (mqd_t __mqdes, char *__restrict __msg_ptr, |
| 79 | size_t __msg_len, |
| 80 | unsigned int *__restrict __msg_prio, |
| 81 | const struct timespec *__restrict __abs_timeout) |
| 82 | __nonnull ((2, 5)); |
| 83 | |
| 84 | /* Add message pointed by MSG_PTR to message queue MQDES, stop blocking |
| 85 | on full message queue if ABS_TIMEOUT expires. */ |
| 86 | extern int mq_timedsend (mqd_t __mqdes, const char *__msg_ptr, |
| 87 | size_t __msg_len, unsigned int __msg_prio, |
| 88 | const struct timespec *__abs_timeout) |
| 89 | __nonnull ((2, 5)); |
| 90 | #endif |
| 91 | |
| 92 | /* Define some inlines helping to catch common problems. */ |
| 93 | #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function \ |
| 94 | && defined __va_arg_pack_len |
| 95 | # include <bits/mqueue2.h> |
| 96 | #endif |
| 97 | |
| 98 | __END_DECLS |
| 99 | |
| 100 | #endif /* mqueue.h */ |