blob: 78308d8d972fd988fa8dca7d66a7381bd36149c7 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*
2 * mq_send.c - functions for sending to message queue.
3 */
4
5#include <sys/syscall.h>
6
7#ifdef __NR_mq_timedsend
8
9#include <stddef.h>
10#include <mqueue.h>
11
12#ifdef __UCLIBC_HAS_THREADS_NATIVE__
13librt_hidden_proto(mq_timedsend)
14#else
15
16# define __NR___syscall_mq_timedsend __NR_mq_timedsend
17static _syscall5(int, __syscall_mq_timedsend, int, mqdes,
18 const char *, msg_ptr, size_t, msg_len, unsigned int,
19 msg_prio, const void *, abs_timeout);
20
21# ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
22/*
23 * Add a message to queue. If O_NONBLOCK is set and queue is full, wait
24 * for sufficient room in the queue until abs_timeout expires.
25 */
26int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
27 unsigned int msg_prio, const struct timespec *abs_timeout)
28{
29 return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio,
30 abs_timeout);
31}
32# endif
33#endif
34
35/* Add a message to queue */
36int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
37 unsigned int msg_prio)
38{
39#ifdef __UCLIBC_HAS_THREADS_NATIVE__
40 return mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
41#else
42 return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
43#endif
44}
45
46#endif