mq_send.c 1.6 KB

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