OSDN Git Service

h8300: O_DIRECT and O_DIRECTIRY swapping.
[uclinux-h8/uclibc-ng.git] / librt / mq_receive.c
1 /*
2  * mq_receive.c - functions for receiving from message queue.
3  */
4
5 #include <sys/syscall.h>
6
7 #ifdef __NR_mq_timedreceive
8
9 #include <stddef.h>
10 #include <mqueue.h>
11
12 #ifdef __UCLIBC_HAS_THREADS_NATIVE__
13 # ifndef __UCLIBC_HAS_ADVANCED_REALTIME__
14 extern ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
15                                unsigned int *msg_prio,
16                                const struct timespec *abs_timeout);
17 # endif
18 librt_hidden_proto(mq_timedreceive)
19 #else
20
21 # define __NR___syscall_mq_timedreceive __NR_mq_timedreceive
22 static _syscall5(int, __syscall_mq_timedreceive, int, mqdes,
23                  char *, msg_ptr, size_t, msg_len, unsigned int *,
24                  msg_prio, const void *, abs_timeout)
25
26 # ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
27 /*
28  * Receive the oldest from highest priority messages.
29  * Stop waiting if abs_timeout expires.
30  */
31 ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
32                         unsigned int *msg_prio,
33                         const struct timespec *abs_timeout)
34 {
35         return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio,
36                                          abs_timeout);
37 }
38 # endif
39
40 #endif
41
42 /* Receive the oldest from highest priority messages */
43 ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
44                    unsigned int *msg_prio)
45 {
46 #ifdef __UCLIBC_HAS_THREADS_NATIVE__
47         return mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
48 #else
49         return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
50 #endif
51 }
52
53 #endif