mq_receive.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 inline _syscall5(int, __syscall_mq_timedreceive, int, mqdes,
  11. char *, msg_ptr, size_t, msg_len, unsigned int *, msg_prio,
  12. const void *, abs_timeout);
  13. #endif
  14. /*
  15. * Receive the oldest from highest priority messages.
  16. * Stop waiting if abs_timeout expires.
  17. */
  18. attribute_hidden
  19. ssize_t __mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
  20. unsigned int *msg_prio,
  21. const struct timespec *abs_timeout)
  22. {
  23. #ifdef __NR_mq_timedreceive
  24. return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abs_timeout);
  25. #else
  26. errno = ENOSYS;
  27. return -1;
  28. #endif
  29. }
  30. strong_alias(__mq_timedreceive,mq_timedreceive)
  31. /* Receive the oldest from highest priority messages */
  32. ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
  33. unsigned int *msg_prio)
  34. {
  35. return __mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
  36. }