mq_send.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #define __USE_XOPEN2K
  8. #include <mqueue.h>
  9. librt_hidden_proto(mq_timedsend)
  10. #ifdef __NR_mq_timedsend
  11. #define __NR___syscall_mq_timedsend __NR_mq_timedsend
  12. static inline _syscall5(int, __syscall_mq_timedsend, int, mqdes,
  13. const char *, msg_ptr, size_t, msg_len, unsigned int, msg_prio,
  14. const void *, abs_timeout);
  15. #endif
  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,
  22. const struct timespec *abs_timeout)
  23. {
  24. #ifdef __NR_mq_timedsend
  25. return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, abs_timeout);
  26. #else
  27. errno = ENOSYS;
  28. return -1;
  29. #endif
  30. }
  31. librt_hidden_def(mq_timedsend)
  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. return mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
  37. }