* @brief Send a message to a message queue with a timeout. * * This function sends a message to the specified message queue, but it allows the sender * to specify a timeout. If the message queue is full, the function will block until either * space becomes available or the specified timeout expires. If the timeout expires without * space being available, the function returns an error. * * @
| 9174 | * @see sys_mq_send |
| 9175 | */ |
| 9176 | sysret_t sys_mq_timedsend(mqd_t mqd, const char *msg, size_t len, unsigned prio, const struct timespec *at) |
| 9177 | { |
| 9178 | int ret = 0; |
| 9179 | #ifdef ARCH_MM_MMU |
| 9180 | char *kmsg = RT_NULL; |
| 9181 | struct timespec at_k; |
| 9182 | |
| 9183 | kmsg = (char *)kmem_get(len + 1); |
| 9184 | if (!kmsg) |
| 9185 | return -ENOMEM; |
| 9186 | |
| 9187 | lwp_get_from_user(&at_k, (void *)at, sizeof(struct timespec)); |
| 9188 | lwp_get_from_user(kmsg, (void *)msg, len + 1); |
| 9189 | ret = mq_timedsend(mqd, kmsg, len, prio, &at_k); |
| 9190 | if (ret < 0) |
| 9191 | { |
| 9192 | ret = GET_ERRNO(); |
| 9193 | } |
| 9194 | |
| 9195 | kmem_put(kmsg); |
| 9196 | |
| 9197 | return ret; |
| 9198 | #else |
| 9199 | ret = mq_timedsend(mqd, msg, len, prio, at); |
| 9200 | return (ret < 0 ? GET_ERRNO() : ret); |
| 9201 | #endif |
| 9202 | } |
| 9203 | |
| 9204 | /** |
| 9205 | * @brief Receive a message from a message queue with a timeout. |
nothing calls this directly
no test coverage detected