mq_receive.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * mq_receive.c - functions for receiving from message queue.
  3. */
  4. #include <errno.h>
  5. #include <stddef.h>
  6. #include <sys/syscall.h>
  7. #include <mqueue.h>
  8. #ifdef __NR_mq_timedreceive
  9. #define __NR___syscall_mq_timedreceive __NR_mq_timedreceive
  10. static _syscall5(int, __syscall_mq_timedreceive, int, mqdes,
  11. char *, msg_ptr, size_t, msg_len, unsigned int *,
  12. msg_prio, const void *, abs_timeout)
  13. # if defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__
  14. /*
  15. * Receive the oldest from highest priority messages.
  16. * Stop waiting if abs_timeout expires.
  17. */
  18. ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
  19. unsigned int *msg_prio,
  20. const struct timespec *abs_timeout)
  21. {
  22. return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio,
  23. abs_timeout);
  24. }
  25. # endif
  26. /* Receive the oldest from highest priority messages */
  27. ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
  28. unsigned int *msg_prio)
  29. {
  30. return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
  31. }
  32. #elif defined __UCLIBC_HAS_STUBS__
  33. # if defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__
  34. ssize_t mq_timedreceive(mqd_t mqdes attribute_unused, char *msg_ptr attribute_unused,
  35. size_t msg_len attribute_unused, unsigned int *msg_prio attribute_unused,
  36. const struct timespec *abs_timeout attribute_unused)
  37. {
  38. __set_errno(ENOSYS);
  39. return -1;
  40. }
  41. # endif
  42. ssize_t mq_receive(mqd_t mqdes attribute_unused, char *msg_ptr attribute_unused,
  43. size_t msg_len attribute_unused, unsigned int *msg_prio attribute_unused)
  44. {
  45. __set_errno(ENOSYS);
  46. return -1;
  47. }
  48. #endif