mqueue.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* Copyright (C) 2004, 2005 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. <http://www.gnu.org/licenses/>. */
  14. #ifndef _MQUEUE_H
  15. #define _MQUEUE_H 1
  16. #include <features.h>
  17. #if defined __UCLIBC_HAS_REALTIME__ || \
  18. defined __UCLIBC_HAS_ADVANCED_REALTIME__
  19. #include <sys/types.h>
  20. #include <fcntl.h>
  21. #define __need_sigevent_t
  22. #include <bits/siginfo.h>
  23. #define __need_timespec
  24. #include <time.h>
  25. /* Get the definition of mqd_t and struct mq_attr. */
  26. #include <bits/mqueue.h>
  27. #endif
  28. __BEGIN_DECLS
  29. #if defined __UCLIBC_HAS_REALTIME__
  30. /* Establish connection between a process and a message queue NAME and
  31. return message queue descriptor or (mqd_t) -1 on error. OFLAG determines
  32. the type of access used. If O_CREAT is on OFLAG, the third argument is
  33. taken as a `mode_t', the mode of the created message queue, and the fourth
  34. argument is taken as `struct mq_attr *', pointer to message queue
  35. attributes. If the fourth argument is NULL, default attributes are
  36. used. */
  37. extern mqd_t mq_open (const char *__name, int __oflag, ...) __THROW;
  38. /* Removes the association between message queue descriptor MQDES and its
  39. message queue. */
  40. extern int mq_close (mqd_t __mqdes) __THROW;
  41. /* Query status and attributes of message queue MQDES. */
  42. extern int mq_getattr (mqd_t __mqdes, struct mq_attr *__mqstat) __THROW;
  43. /* Set attributes associated with message queue MQDES and if OMQSTAT is
  44. not NULL also query its old attributes. */
  45. extern int mq_setattr (mqd_t __mqdes,
  46. const struct mq_attr *__restrict __mqstat,
  47. struct mq_attr *__restrict __omqstat) __THROW;
  48. /* Remove message queue named NAME. */
  49. extern int mq_unlink (const char *__name) __THROW;
  50. /* Register notification issued upon message arrival to an empty
  51. message queue MQDES. */
  52. extern int mq_notify (mqd_t __mqdes, const struct sigevent *__notification)
  53. __THROW;
  54. /* Receive the oldest from highest priority messages in message queue
  55. MQDES. */
  56. extern ssize_t mq_receive (mqd_t __mqdes, char *__msg_ptr, size_t __msg_len,
  57. unsigned int *__msg_prio);
  58. /* Add message pointed by MSG_PTR to message queue MQDES. */
  59. extern int mq_send (mqd_t __mqdes, const char *__msg_ptr, size_t __msg_len,
  60. unsigned int __msg_prio);
  61. #endif
  62. #if defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__
  63. /* Receive the oldest from highest priority messages in message queue
  64. MQDES, stop waiting if ABS_TIMEOUT expires. */
  65. extern ssize_t mq_timedreceive (mqd_t __mqdes, char *__restrict __msg_ptr,
  66. size_t __msg_len,
  67. unsigned int *__restrict __msg_prio,
  68. const struct timespec *__restrict __abs_timeout);
  69. /* Add message pointed by MSG_PTR to message queue MQDES, stop blocking
  70. on full message queue if ABS_TIMEOUT expires. */
  71. extern int mq_timedsend (mqd_t __mqdes, const char *__msg_ptr,
  72. size_t __msg_len, unsigned int __msg_prio,
  73. const struct timespec *__abs_timeout);
  74. #endif
  75. __END_DECLS
  76. #endif /* mqueue.h */