sched/clock/clock_getres.c: Support CLOCK_MONOTONIC

This commit is contained in:
Xiang Xiao
2018-11-12 06:42:38 -06:00
committed by Gregory Nutt
parent 77098f8736
commit 1ef2602933
+16 -13
View File
@@ -64,22 +64,25 @@ int clock_getres(clockid_t clock_id, struct timespec *res)
sinfo("clock_id=%d\n", clock_id); sinfo("clock_id=%d\n", clock_id);
/* Only CLOCK_REALTIME is supported */ switch (clock_id)
if (clock_id != CLOCK_REALTIME)
{ {
serr("Returning ERROR\n"); default:
set_errno(EINVAL); serr("Returning ERROR\n");
ret = ERROR; set_errno(EINVAL);
} ret = ERROR;
else break;
{
/* Form the timspec using clock resolution in nanoseconds */
res->tv_sec = 0; #ifdef CONFIG_CLOCK_MONOTONIC
res->tv_nsec = NSEC_PER_TICK; case CLOCK_MONOTONIC:
#endif
case CLOCK_REALTIME:
/* Form the timspec using clock resolution in nanoseconds */
sinfo("Returning res=(%d,%d)\n", (int)res->tv_sec, (int)res->tv_nsec); res->tv_sec = 0;
res->tv_nsec = NSEC_PER_TICK;
sinfo("Returning res=(%d,%d)\n", (int)res->tv_sec, (int)res->tv_nsec);
break;
} }
return ret; return ret;