mq_send.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * mq_send.c - functions for sending to 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_timedsend)
  9. #ifdef __NR_mq_timedsend
  10. #define __NR___syscall_mq_timedsend __NR_mq_timedsend
  11. static inline _syscall5(int, __syscall_mq_timedsend, int, mqdes,
  12. const char *, msg_ptr, size_t, msg_len, unsigned int, msg_prio,
  13. const void *, abs_timeout);
  14. #endif
  15. /*
  16. * Add a message to queue. If O_NONBLOCK is set and queue is full, wait
  17. * for sufficient room in the queue until abs_timeout expires.
  18. */
  19. int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
  20. unsigned int msg_prio,
  21. const struct timespec *abs_timeout)
  22. {
  23. #ifdef __NR_mq_timedsend
  24. return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, abs_timeout);
  25. #else
  26. errno = ENOSYS;
  27. return -1;
  28. #endif
  29. }
  30. librt_hidden_def(mq_timedsend)
  31. /* Add a message to queue */
  32. int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
  33. unsigned int msg_prio)
  34. {
  35. return mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
  36. }