mq_receive.c 1.2 KB

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