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

Function sys_channel_send

components/lwp/lwp_syscall.c:4145–4170  ·  view source on GitHub ↗

* @brief Sends a message through a communication channel. * * This system call is used to send a message through a specified communication channel identified * by the file descriptor `fd`. The message to be sent is provided in the `data` parameter. * It allows inter-process or inter-thread communication by transmitting the given message over * the open channel. * * @param[in] fd The fil

Source from the content-addressed store, hash-verified

4143 * to errors, data loss, or undefined behavior.
4144 */
4145sysret_t sys_channel_send(int fd, rt_channel_msg_t data)
4146{
4147 rt_size_t ret = 0;
4148 rt_channel_msg_t kdata = RT_NULL;
4149
4150 if (!lwp_user_accessable((void *)data, sizeof(*data)))
4151 {
4152 return -EFAULT;
4153 }
4154
4155 kdata = kmem_get(sizeof(*data));
4156 if (kdata == RT_NULL)
4157 return -ENOMEM;
4158
4159 if (lwp_get_from_user(kdata, data, sizeof(*kdata)) != sizeof(*kdata))
4160 {
4161 kmem_put(kdata);
4162 return -EFAULT;
4163 }
4164
4165 ret = lwp_channel_send(FDT_TYPE_LWP, fd, kdata);
4166
4167 kmem_put(kdata);
4168
4169 return ret;
4170}
4171
4172/**
4173 * @brief Sends a message through a communication channel and waits for a response with a timeout.

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
lwp_channel_sendFunction · 0.85

Tested by

no test coverage detected