clock/time: add CLOCK_BOOTTIME definition

Change-Id: I1adc0445dcdd8284d11aec44bd67b447b2b0490f
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2020-12-05 16:40:48 +08:00 committed by Xiang Xiao
parent 7a5f7d470f
commit 8ac184633b
4 changed files with 11 additions and 2 deletions

View file

@ -90,6 +90,12 @@
# define CLOCK_MONOTONIC 1
#endif
/* Monotonic system-wide clock that includes time spent in suspension. */
#ifdef CONFIG_CLOCK_MONOTONIC
# define CLOCK_BOOTTIME 2
#endif
/* This is a flag that may be passed to the timer_settime() and
* clock_nanosleep() functions.
*/

View file

@ -74,6 +74,7 @@ int clock_getres(clockid_t clock_id, struct timespec *res)
#ifdef CONFIG_CLOCK_MONOTONIC
case CLOCK_MONOTONIC:
case CLOCK_BOOTTIME:
#endif
case CLOCK_REALTIME:
@ -82,7 +83,8 @@ int clock_getres(clockid_t clock_id, struct timespec *res)
res->tv_sec = 0;
res->tv_nsec = NSEC_PER_TICK;
sinfo("Returning res=(%d,%d)\n", (int)res->tv_sec, (int)res->tv_nsec);
sinfo("Returning res=(%d,%d)\n", (int)res->tv_sec,
(int)res->tv_nsec);
break;
}

View file

@ -88,7 +88,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
* is invoked with a clock_id argument of CLOCK_MONOTONIC."
*/
if (clock_id == CLOCK_MONOTONIC)
if (clock_id == CLOCK_MONOTONIC || clock_id == CLOCK_BOOTTIME)
{
/* The the time elapsed since the timer was initialized at power on
* reset.

View file

@ -161,6 +161,7 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp,
if (timerid == NULL || (clockid != CLOCK_REALTIME
#ifdef CONFIG_CLOCK_MONOTONIC
&& clockid != CLOCK_MONOTONIC
&& clockid != CLOCK_BOOTTIME
#endif /* CONFIG_CLOCK_MONOTONIC */
))
{