mqueue.h 3.7 KB

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