* @brief Suspends execution for a specified amount of time. * * This system call suspends the execution of the calling thread for the duration * specified by the `rqtp` argument. The `rqtp` argument is a pointer to a `struct timespec` * that defines the sleep time in seconds and nanoseconds. If the sleep is interrupted by a signal, * the function may return early with the remaining time in `r
| 1161 | * @see sys_sleep(), clock_nanosleep(), nanosleep() |
| 1162 | */ |
| 1163 | sysret_t sys_nanosleep(const struct timespec *rqtp, struct timespec *rmtp) |
| 1164 | { |
| 1165 | int ret = 0; |
| 1166 | LOG_D("sys_nanosleep\n"); |
| 1167 | if (!lwp_user_accessable((void *)rqtp, sizeof *rqtp)) |
| 1168 | return -EFAULT; |
| 1169 | |
| 1170 | #ifdef ARCH_MM_MMU |
| 1171 | struct timespec rqtp_k; |
| 1172 | struct timespec rmtp_k; |
| 1173 | |
| 1174 | lwp_get_from_user(&rqtp_k, (void *)rqtp, sizeof rqtp_k); |
| 1175 | ret = nanosleep(&rqtp_k, &rmtp_k); |
| 1176 | if ((ret != -1 || rt_get_errno() == EINTR) && rmtp && lwp_user_accessable((void *)rmtp, sizeof *rmtp)) |
| 1177 | { |
| 1178 | lwp_put_to_user(rmtp, (void *)&rmtp_k, sizeof rmtp_k); |
| 1179 | if(ret != 0) |
| 1180 | return -EINTR; |
| 1181 | } |
| 1182 | #else |
| 1183 | if (rmtp) |
| 1184 | { |
| 1185 | if (!lwp_user_accessable((void *)rmtp, sizeof *rmtp)) |
| 1186 | return -EFAULT; |
| 1187 | ret = nanosleep(rqtp, rmtp); |
| 1188 | } |
| 1189 | #endif |
| 1190 | return (ret < 0 ? GET_ERRNO() : ret); |
| 1191 | } |
| 1192 | |
| 1193 | /** |
| 1194 | * @brief Retrieves the current time and timezone information. |
nothing calls this directly
no test coverage detected