mq_receive.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #warning FIXME: hard dependency on ADVANCED REALTIME feature
  9. librt_hidden_proto(mq_timedreceive)
  10. #ifdef __NR_mq_timedreceive
  11. #define __NR___syscall_mq_timedreceive __NR_mq_timedreceive
  12. static inline _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. #endif
  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. #ifdef __NR_mq_timedreceive
  25. return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio,
  26. abs_timeout);
  27. #else
  28. errno = ENOSYS;
  29. return -1;
  30. #endif
  31. }
  32. librt_hidden_def(mq_timedreceive)
  33. /* Receive the oldest from highest priority messages */
  34. ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
  35. unsigned int *msg_prio)
  36. {
  37. return mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
  38. }