mq_receive.c 1.2 KB

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