mqueue.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 posix_mq
  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 posix_mq* next;
  17. };
  18. typedef struct posix_mq posix_mq_t;
  19. struct mqdes
  20. {
  21. rt_uint32_t flags;
  22. posix_mq_t* mq;
  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, const struct mq_attr *mqstat,
  39. struct mq_attr *omqstat);
  40. ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
  41. unsigned *msg_prio, const struct timespec *abs_timeout);
  42. int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio,
  43. const struct timespec *abs_timeout);
  44. int mq_unlink(const char *name);
  45. #endif