mqueue.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * File : mqueue.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2012, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. */
  23. #ifndef __MQUEUE_H__
  24. #define __MQUEUE_H__
  25. #include <rtthread.h>
  26. #include <pthread.h>
  27. struct mqdes
  28. {
  29. /* reference count and unlinked */
  30. rt_uint16_t refcount;
  31. rt_uint16_t unlinked;
  32. /* RT-Thread message queue */
  33. rt_mq_t mq;
  34. /* next posix mqueue */
  35. struct mqdes* next;
  36. };
  37. typedef struct mqdes* mqd_t;
  38. struct mq_attr
  39. {
  40. long mq_flags; /* Message queue flags. */
  41. long mq_maxmsg; /* Maximum number of messages. */
  42. long mq_msgsize; /* Maximum message size. */
  43. long mq_curmsgs; /* Number of messages currently queued. */
  44. };
  45. int mq_close(mqd_t mqdes);
  46. int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat);
  47. int mq_notify(mqd_t mqdes, const struct sigevent *notification);
  48. mqd_t mq_open(const char *name, int oflag, ...);
  49. ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio);
  50. int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio);
  51. int mq_setattr(mqd_t mqdes,
  52. const struct mq_attr *mqstat,
  53. struct mq_attr *omqstat);
  54. ssize_t mq_timedreceive(mqd_t mqdes,
  55. char *msg_ptr,
  56. size_t msg_len,
  57. unsigned *msg_prio,
  58. const struct timespec *abs_timeout);
  59. int mq_timedsend(mqd_t mqdes,
  60. const char *msg_ptr,
  61. size_t msg_len,
  62. unsigned msg_prio,
  63. const struct timespec *abs_timeout);
  64. int mq_unlink(const char *name);
  65. #endif