mq_receive.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. # ifndef __UCLIBC_HAS_ADVANCED_REALTIME__
  10. extern ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
  11. unsigned int *msg_prio,
  12. const struct timespec *abs_timeout);
  13. # endif
  14. librt_hidden_proto(mq_timedreceive)
  15. #else
  16. # define __NR___syscall_mq_timedreceive __NR_mq_timedreceive
  17. static _syscall5(int, __syscall_mq_timedreceive, int, mqdes,
  18. char *, msg_ptr, size_t, msg_len, unsigned int *,
  19. msg_prio, const void *, abs_timeout)
  20. # ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
  21. /*
  22. * Receive the oldest from highest priority messages.
  23. * Stop waiting if abs_timeout expires.
  24. */
  25. ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
  26. unsigned int *msg_prio,
  27. const struct timespec *abs_timeout)
  28. {
  29. return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio,
  30. abs_timeout);
  31. }
  32. # endif
  33. #endif
  34. /* Receive the oldest from highest priority messages */
  35. ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
  36. unsigned int *msg_prio)
  37. {
  38. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  39. return mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
  40. #else
  41. return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
  42. #endif
  43. }
  44. #endif