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

Function sys_clock_nanosleep

components/lwp/lwp_syscall.c:8168–8196  ·  view source on GitHub ↗

* @brief Suspends the execution of the calling thread for the specified time duration. * * This function causes the calling thread to sleep for the specified time duration, which is provided as a * `struct timespec` containing seconds and nanoseconds. The sleep is done based on the specified clock (identified by `clk`). * If the `flags` parameter is set to `TIMER_ABSTIME`, the specified time r

Source from the content-addressed store, hash-verified

8166 * @see sys_clock_gettime(), sys_clock_settime(), sys_nanosleep()
8167 */
8168sysret_t sys_clock_nanosleep(clockid_t clk, int flags, const struct timespec *rqtp, struct timespec *rmtp)
8169{
8170 int ret = 0;
8171 LOG_D("sys_nanosleep\n");
8172 if (!lwp_user_accessable((void *)rqtp, sizeof *rqtp))
8173 return -EFAULT;
8174
8175#ifdef ARCH_MM_MMU
8176 struct timespec rqtp_k;
8177 struct timespec rmtp_k;
8178
8179 lwp_get_from_user(&rqtp_k, (void *)rqtp, sizeof rqtp_k);
8180 ret = clock_nanosleep(clk, flags, &rqtp_k, &rmtp_k);
8181 if ((ret != -1 || rt_get_errno() == EINTR) && rmtp && lwp_user_accessable((void *)rmtp, sizeof *rmtp))
8182 {
8183 lwp_put_to_user(rmtp, (void *)&rmtp_k, sizeof rmtp_k);
8184 if(ret != 0)
8185 return -EINTR;
8186 }
8187#else
8188 if (rmtp)
8189 {
8190 if (!lwp_user_accessable((void *)rmtp, sizeof *rmtp))
8191 return -EFAULT;
8192 ret = clock_nanosleep(clk, flags, rqtp, rmtp);
8193 }
8194#endif
8195 return (ret < 0 ? GET_ERRNO() : ret);
8196}
8197
8198/**
8199 * @brief Get the resolution of the specified clock.

Callers

nothing calls this directly

Calls 5

lwp_user_accessableFunction · 0.85
lwp_get_from_userFunction · 0.85
clock_nanosleepFunction · 0.85
rt_get_errnoFunction · 0.85
lwp_put_to_userFunction · 0.85

Tested by

no test coverage detected