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

Function sys_timer_settime

components/lwp/lwp_syscall.c:3135–3157  ·  view source on GitHub ↗

* @brief Changes the time or interval of an existing timer. * * This system call modifies the expiration time or interval of a previously created * timer. It can either set a new expiration time for the timer or update the * interval for periodic timers. The timer can be started or modified based on * the flags provided. The current (old) timer settings can be retrieved if * requested. * *

Source from the content-addressed store, hash-verified

3133 * before making changes.
3134 */
3135sysret_t sys_timer_settime(timer_t timerid, int flags,
3136 const struct itimerspec *restrict new_value,
3137 struct itimerspec *restrict old_value)
3138{
3139 int ret = 0;
3140#ifdef ARCH_MM_MMU
3141 struct itimerspec new_value_k;
3142 struct itimerspec old_value_k;
3143
3144 if (!lwp_get_from_user(&new_value_k, (void *)new_value, sizeof(*new_value)) ||
3145 (old_value && !lwp_get_from_user(&old_value_k, (void *)old_value, sizeof(*old_value))))
3146 {
3147 return -EFAULT;
3148 }
3149
3150 ret = timer_settime(timerid, flags, &new_value_k, &old_value_k);
3151 lwp_put_to_user(old_value, (void *)&old_value_k, sizeof old_value_k);
3152
3153#else
3154 ret = timer_settime(timerid, flags, new_value, old_value);
3155#endif
3156 return (ret < 0 ? GET_ERRNO() : ret);
3157}
3158
3159/**
3160 * @brief Retrieves the current time and interval of a timer.

Callers

nothing calls this directly

Calls 3

lwp_get_from_userFunction · 0.85
timer_settimeFunction · 0.85
lwp_put_to_userFunction · 0.85

Tested by

no test coverage detected