* @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. *
| 2680 | * task or thread to block indefinitely if not properly handled. |
| 2681 | */ |
| 2682 | sysret_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. |
nothing calls this directly
no test coverage detected