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

Function sys_mq_send

components/lwp/lwp_syscall.c:2682–2709  ·  view source on GitHub ↗

* @brief Sends a message to a message queue. * * This system call sends a message to the specified message queue. The message * is copied into the queue's buffer. If the queue is full, the behavior will * depend on the flags set during queue creation (e.g., whether it is blocking * or non-blocking). * * @param[in] mq The handle to the message queue where the message will be sent. *

Source from the content-addressed store, hash-verified

2680 * task or thread to block indefinitely if not properly handled.
2681 */
2682sysret_t sys_mq_send(rt_mq_t mq, void *buffer, rt_size_t size)
2683{
2684 int ret = 0;
2685 void *kbuffer = RT_NULL;
2686
2687 if (!lwp_user_accessable((void *)buffer, size))
2688 {
2689 return -EFAULT;
2690 }
2691
2692 kbuffer = kmem_get(size);
2693 if (kbuffer == RT_NULL)
2694 {
2695 return -ENOMEM;
2696 }
2697
2698 if (lwp_get_from_user(kbuffer, buffer, size) != size)
2699 {
2700 kmem_put(kbuffer);
2701 return -EINVAL;
2702 }
2703
2704 ret = rt_mq_send(mq, kbuffer, size);
2705
2706 kmem_put(kbuffer);
2707
2708 return ret;
2709}
2710
2711/**
2712 * @brief Sends an urgent message to a message queue.

Callers

nothing calls this directly

Calls 5

lwp_user_accessableFunction · 0.85
kmem_getFunction · 0.85
lwp_get_from_userFunction · 0.85
kmem_putFunction · 0.85
rt_mq_sendFunction · 0.85

Tested by

no test coverage detected