MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / sys_mq_recv

Function sys_mq_recv

components/lwp/lwp_syscall.c:2798–2824  ·  view source on GitHub ↗

* @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]

Source from the content-addressed store, hash-verified

2796 * blocking, potentially resulting in deadlocks if no message is received.
2797 */
2798sysret_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
2826static void timer_timeout_callback(void *parameter)
2827{

Callers

nothing calls this directly

Calls 5

lwp_user_accessableFunction · 0.85
kmem_getFunction · 0.85
rt_mq_recvFunction · 0.85
lwp_put_to_userFunction · 0.85
kmem_putFunction · 0.85

Tested by

no test coverage detected