mq_send.c 1.2 KB

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