mqueue.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. */
  9. #ifndef __MQUEUE_H__
  10. #define __MQUEUE_H__
  11. #include <sys/signal.h>
  12. #include <sys/time.h>
  13. #include <rtdef.h>
  14. struct mqdes
  15. {
  16. /* reference count and unlinked */
  17. rt_uint16_t refcount;
  18. rt_uint16_t unlinked;
  19. /* RT-Thread message queue */
  20. rt_mq_t mq;
  21. int mq_id;
  22. /* next posix mqueue */
  23. struct mqdes* next;
  24. };
  25. typedef struct mqdes* mqdes_t;
  26. typedef int mqd_t;
  27. struct mq_attr
  28. {
  29. long mq_flags; /* Message queue flags. */
  30. long mq_maxmsg; /* Maximum number of messages. */
  31. long mq_msgsize; /* Maximum message size. */
  32. long mq_curmsgs; /* Number of messages currently queued. */
  33. };
  34. int mq_close(mqd_t mqdes);
  35. int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat);
  36. int mq_notify(mqd_t mqdes, const struct sigevent *notification);
  37. mqd_t mq_open(const char *name, int oflag, ...);
  38. ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio);
  39. int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio);
  40. int mq_setattr(mqd_t mqdes,
  41. const struct mq_attr *mqstat,
  42. struct mq_attr *omqstat);
  43. ssize_t mq_timedreceive(mqd_t mqdes,
  44. char *msg_ptr,
  45. size_t msg_len,
  46. unsigned *msg_prio,
  47. const struct timespec *abs_timeout);
  48. int mq_timedsend(mqd_t mqdes,
  49. const char *msg_ptr,
  50. size_t msg_len,
  51. unsigned msg_prio,
  52. const struct timespec *abs_timeout);
  53. int mq_unlink(const char *name);
  54. #endif