OSDN Git Service

make sure mq_timedreceive() and mq_receive() is always defined
[uclinux-h8/uClibc.git] / librt / mq_receive.c
1 /*
2  * mq_receive.c - functions for receiving from message queue.
3  */
4
5 #include <errno.h>
6 #include <stddef.h>
7 #include <sys/syscall.h>
8
9 #include <mqueue.h>
10
11 #ifdef __NR_mq_timedreceive
12 #define __NR___syscall_mq_timedreceive __NR_mq_timedreceive
13 static inline _syscall5(int, __syscall_mq_timedreceive, int, mqdes,
14         char *, msg_ptr, size_t, msg_len, unsigned int *, msg_prio,
15         const void *, abs_timeout);
16 #endif
17
18 /*
19  * Receive the oldest from highest priority messages.
20  * Stop waiting if abs_timeout expires.
21  */
22 ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
23                         unsigned int *msg_prio,
24                         const struct timespec *abs_timeout)
25 {
26 #ifdef __NR_mq_timedreceive
27         return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abs_timeout);
28 #else
29         errno = ENOSYS;
30         return -1;
31 #endif
32 }
33
34 /* Receive the oldest from highest priority messages */
35 ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
36                         unsigned int *msg_prio)
37 {
38         return mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
39 }