mq_receive.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. librt_hidden_proto(mq_timedreceive)
  9. #ifdef __NR_mq_timedreceive
  10. #define __NR___syscall_mq_timedreceive __NR_mq_timedreceive
  11. static inline _syscall5(int, __syscall_mq_timedreceive, int, mqdes,
  12. char *, msg_ptr, size_t, msg_len, unsigned int *,
  13. msg_prio, const void *, abs_timeout);
  14. #endif
  15. /*
  16. * Receive the oldest from highest priority messages.
  17. * Stop waiting if abs_timeout expires.
  18. */
  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,
  25. abs_timeout);
  26. #else
  27. errno = ENOSYS;
  28. return -1;
  29. #endif
  30. }
  31. librt_hidden_def(mq_timedreceive)
  32. /* Receive the oldest from highest priority messages */
  33. ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
  34. unsigned int *msg_prio)
  35. {
  36. return mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
  37. }