mqueue.h 3.6 KB

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