clock/time: add CLOCK_BOOTTIME definition
Change-Id: I1adc0445dcdd8284d11aec44bd67b447b2b0490f Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
7a5f7d470f
commit
8ac184633b
4 changed files with 11 additions and 2 deletions
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 */
|
||||
))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue