mqueue.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. /* next posix mqueue */
  22. struct mqdes* next;
  23. };
  24. typedef struct mqdes* mqd_t;
  25. struct mq_attr
  26. {
  27. long mq_flags; /* Message queue flags. */
  28. long mq_maxmsg; /* Maximum number of messages. */
  29. long mq_msgsize; /* Maximum message size. */
  30. long mq_curmsgs; /* Number of messages currently queued. */
  31. };
  32. int mq_close(mqd_t mqdes);
  33. int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat);
  34. int mq_notify(mqd_t mqdes, const struct sigevent *notification);
  35. mqd_t mq_open(const char *name, int oflag, ...);
  36. ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio);
  37. int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio);
  38. int mq_setattr(mqd_t mqdes,
  39. const struct mq_attr *mqstat,
  40. struct mq_attr *omqstat);
  41. ssize_t mq_timedreceive(mqd_t mqdes,
  42. char *msg_ptr,
  43. size_t msg_len,
  44. unsigned *msg_prio,
  45. const struct timespec *abs_timeout);
  46. int mq_timedsend(mqd_t mqdes,
  47. const char *msg_ptr,
  48. size_t msg_len,
  49. unsigned msg_prio,
  50. const struct timespec *abs_timeout);
  51. int mq_unlink(const char *name);
  52. #endif