* @brief Receives a message from a message queue. * * This system call attempts to receive a message from the specified message queue. * The message is copied into the provided buffer. If no message is available * in the queue, the function will block for a specified timeout period before * returning. If the timeout expires without receiving a message, an error is returned. * * @param[in]
| 2796 | * blocking, potentially resulting in deadlocks if no message is received. |
| 2797 | */ |
| 2798 | sysret_t sys_mq_recv(rt_mq_t mq, |
| 2799 | void *buffer, |
| 2800 | rt_size_t size, |
| 2801 | rt_int32_t timeout) |
| 2802 | { |
| 2803 | int ret = 0; |
| 2804 | void *kbuffer = RT_NULL; |
| 2805 | |
| 2806 | if (!lwp_user_accessable((void *)buffer, size)) |
| 2807 | { |
| 2808 | return -EFAULT; |
| 2809 | } |
| 2810 | |
| 2811 | kbuffer = kmem_get(size); |
| 2812 | if (kbuffer == RT_NULL) |
| 2813 | { |
| 2814 | return -ENOMEM; |
| 2815 | } |
| 2816 | |
| 2817 | ret = rt_mq_recv(mq, kbuffer, size, timeout); |
| 2818 | if (ret > 0) |
| 2819 | lwp_put_to_user((void *)buffer, (void *)kbuffer, ret); |
| 2820 | |
| 2821 | kmem_put(kbuffer); |
| 2822 | |
| 2823 | return ret; |
| 2824 | } |
| 2825 | |
| 2826 | static void timer_timeout_callback(void *parameter) |
| 2827 | { |
nothing calls this directly
no test coverage detected