mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 13:27:01 +08:00
sched/clock/clock_getres.c: Support CLOCK_MONOTONIC
This commit is contained in:
+16
-13
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user