mqueue.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef __MQUEUE_H__
  2. #define __MQUEUE_H__
  3. #include <rtthread.h>
  4. #include <sys/types.h>
  5. #include <sys/time.h>
  6. #include <sys/signal.h>
  7. #include <pthread.h>
  8. struct mqdes
  9. {
  10. /* reference count and unlinked */
  11. rt_uint16_t refcount;
  12. rt_uint16_t unlinked;
  13. /* RT-Thread message queue */
  14. rt_mq_t mq;
  15. /* next posix mqueue */
  16. struct mqdes* next;
  17. };
  18. typedef struct mqdes* mqd_t;
  19. struct mq_attr
  20. {
  21. long mq_flags; /* Message queue flags. */
  22. long mq_maxmsg; /* Maximum number of messages. */
  23. long mq_msgsize; /* Maximum message size. */
  24. long mq_curmsgs; /* Number of messages currently queued. */
  25. };
  26. int mq_close(mqd_t mqdes);
  27. int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat);
  28. int mq_notify(mqd_t mqdes, const struct sigevent *notification);
  29. mqd_t mq_open(const char *name, int oflag, ...);
  30. ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio);
  31. int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio);
  32. int mq_setattr(mqd_t mqdes, const struct mq_attr *mqstat,
  33. struct mq_attr *omqstat);
  34. ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
  35. unsigned *msg_prio, const struct timespec *abs_timeout);
  36. int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio,
  37. const struct timespec *abs_timeout);
  38. int mq_unlink(const char *name);
  39. #endif