mq_send.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * mq_send.c - functions for sending to message queue.
  3. */
  4. #include <sys/syscall.h>
  5. #ifdef __NR_mq_timedsend
  6. #include <stddef.h>
  7. #include <mqueue.h>
  8. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  9. librt_hidden_proto(mq_timedsend)
  10. #else
  11. # define __NR___syscall_mq_timedsend __NR_mq_timedsend
  12. static _syscall5(int, __syscall_mq_timedsend, int, mqdes,
  13. const char *, msg_ptr, size_t, msg_len, unsigned int,
  14. msg_prio, const void *, abs_timeout);
  15. # ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
  16. /*
  17. * Add a message to queue. If O_NONBLOCK is set and queue is full, wait
  18. * for sufficient room in the queue until abs_timeout expires.
  19. */
  20. int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
  21. unsigned int msg_prio, const struct timespec *abs_timeout)
  22. {
  23. return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio,
  24. abs_timeout);
  25. }
  26. # endif
  27. #endif
  28. /* Add a message to queue */
  29. int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
  30. unsigned int msg_prio)
  31. {
  32. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  33. return mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
  34. #else
  35. return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
  36. #endif
  37. }
  38. #endif