mqueue.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * mqueue.h - definitions and function prototypes for POSIX mqueue support.
  3. */
  4. #ifndef _MQUEUE_H
  5. #define _MQUEUE_H
  6. #include <features.h>
  7. #include <sys/types.h>
  8. #include <fcntl.h>
  9. #define __need_sigevent_t
  10. #include <bits/siginfo.h>
  11. #define __need_timespec
  12. #include <time.h>
  13. typedef int mqd_t;
  14. struct mq_attr {
  15. long int mq_flags; /* Message queue flags */
  16. long int mq_maxmsg; /* Maximum number of messages */
  17. long int mq_msgsize; /* Maximum message size */
  18. long int mq_curmsgs; /* Number of messages currently queued */
  19. long int __pad[4];
  20. };
  21. __BEGIN_DECLS
  22. /*
  23. * Establish connection between a process and a message queue __name and
  24. * return message queue descriptor or (mqd_t) -1 on error. __oflag determines
  25. * the type of access used. If O_CREAT is on __oflag, the third argument is
  26. * taken as a `mode_t', the mode of the created message queue, and the fourth
  27. * argument is taken as `struct mq_attr *', pointer to message queue
  28. * attributes. If the fourth argument is NULL, default attributes are used.
  29. */
  30. extern mqd_t mq_open(const char *__name, int __oflag, ...) __THROW;
  31. /*
  32. * Remove the association between message queue descriptor __mqdes and its
  33. * message queue.
  34. */
  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) __THROW;
  38. /*
  39. * Set attributes associated with message queue __mqdes and if __omqstat is
  40. * not NULL also query its old attributes.
  41. */
  42. extern int mq_setattr(mqd_t __mqdes,
  43. const struct mq_attr *__restrict __mqstat,
  44. struct mq_attr *__restrict __omqstat) __THROW;
  45. /* Remove message queue named __name */
  46. extern int mq_unlink(const char *__name) __THROW;
  47. /*
  48. * Register notification upon message arrival to an empty message queue
  49. * __mqdes
  50. */
  51. extern int mq_notify(mqd_t __mqdes, const struct sigevent *__notification)
  52. __THROW;
  53. /*
  54. * Receive the oldest from highest priority messages in message queue
  55. * __mqdes
  56. */
  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. #ifdef __USE_XOPEN2K
  63. /*
  64. * Receive the oldest from highest priority messages in message queue
  65. * __mqdes, stop waiting if __abs_timeout expires.
  66. */
  67. extern ssize_t mq_timedreceive(mqd_t __mqdes, char *__restrict __msg_ptr,
  68. size_t __msg_len,
  69. unsigned int *__restrict __msg_prio,
  70. const struct timespec *__restrict __abs_timeout);
  71. /*
  72. * Add message pointed by __msg_ptr to message queue __mqdes, stop blocking
  73. * on full message queue if __abs_timeout expires.
  74. */
  75. extern int mq_timedsend(mqd_t __mqdes, const char *__msg_ptr,
  76. size_t __msg_len, unsigned int __msg_prio,
  77. const struct timespec *__abs_timeout);
  78. #endif
  79. __END_DECLS
  80. #endif