mq_send.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. # ifndef __UCLIBC_HAS_ADVANCED_REALTIME__
  10. extern int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
  11. unsigned int msg_prio, const struct timespec *abs_timeout);
  12. # endif
  13. librt_hidden_proto(mq_timedsend)
  14. #else
  15. # define __NR___syscall_mq_timedsend __NR_mq_timedsend
  16. static _syscall5(int, __syscall_mq_timedsend, int, mqdes,
  17. const char *, msg_ptr, size_t, msg_len, unsigned int,
  18. msg_prio, const void *, abs_timeout)
  19. # ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
  20. /*
  21. * Add a message to queue. If O_NONBLOCK is set and queue is full, wait
  22. * for sufficient room in the queue until abs_timeout expires.
  23. */
  24. int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
  25. unsigned int msg_prio, const struct timespec *abs_timeout)
  26. {
  27. return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio,
  28. abs_timeout);
  29. }
  30. # endif
  31. #endif
  32. /* Add a message to queue */
  33. int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
  34. unsigned int msg_prio)
  35. {
  36. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  37. return mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
  38. #else
  39. return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
  40. #endif
  41. }
  42. #endif