OSDN Git Service

nptl: proper soname handling
[uclinux-h8/uclibc-ng.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 #include <mqueue.h>
9 #warning FIXME: hard dependency on ADVANCED REALTIME feature
10
11 librt_hidden_proto(mq_timedreceive)
12
13 #ifndef __UCLIBC_HAS_THREADS_NATIVE__
14 #ifdef __NR_mq_timedreceive
15 #define __NR___syscall_mq_timedreceive __NR_mq_timedreceive
16 static __inline__ _syscall5(int, __syscall_mq_timedreceive, int, mqdes,
17                         char *, msg_ptr, size_t, msg_len, unsigned int *,
18                         msg_prio, const void *, abs_timeout);
19 #endif
20
21 /*
22  * Receive the oldest from highest priority messages.
23  * Stop waiting if abs_timeout expires.
24  */
25 ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
26                         unsigned int *msg_prio,
27                         const struct timespec *abs_timeout)
28 {
29 #ifdef __NR_mq_timedreceive
30         return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio,
31                                          abs_timeout);
32 #else
33         errno = ENOSYS;
34         return -1;
35 #endif
36 }
37
38 librt_hidden_def(mq_timedreceive)
39 #endif
40
41 /* Receive the oldest from highest priority messages */
42 ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
43                    unsigned int *msg_prio)
44 {
45         return mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
46 }