sched: return 0 from clock_systime_ticks if failed

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
This commit is contained in:
Xu Xingliang 2023-09-15 16:12:39 +08:00 committed by Xiang Xiao
parent 415fe60695
commit 3cd5e20f74
2 changed files with 28 additions and 11 deletions

View File

@ -1655,7 +1655,7 @@ void up_timer_initialize(void);
* set a time in the future and get an event when that alarm goes off.
*
* int up_alarm_cancel(void): Cancel the alarm.
* int up_alarm_start(FAR const struct timespec *ts): Enable (or re-anable
* int up_alarm_start(FAR const struct timespec *ts): Enable (or re-enable
* the alarm.
* #else
* int up_timer_cancel(void): Cancels the interval timer.

View File

@ -84,13 +84,18 @@ clock_t clock_systime_ticks(void)
/* Get the time from the platform specific hardware */
clock_systime_timespec(&ts);
if (clock_systime_timespec(&ts) == OK)
{
/* Convert to a 64-bit value in microseconds,
* then in clock tick units.
*/
/* Convert to a 64-bit value in microseconds,
* then in clock tick units.
*/
return timespec_to_tick(&ts);
return timespec_to_tick(&ts);
}
else
{
return 0;
}
}
else
#endif
@ -101,12 +106,24 @@ clock_t clock_systime_ticks(void)
#if defined(CONFIG_SCHED_TICKLESS_TICK_ARGUMENT)
clock_t ticks;
up_timer_gettick(&ticks);
return ticks;
if (up_timer_gettick(&ticks) == OK)
{
return ticks;
}
else
{
return 0;
}
#elif defined(CONFIG_SCHED_TICKLESS)
struct timespec ts;
up_timer_gettime(&ts);
return timespec_to_tick(&ts);
if (up_timer_gettime(&ts) == OK)
{
return timespec_to_tick(&ts);
}
else
{
return 0;
}
#elif defined(CONFIG_SYSTEM_TIME64)
clock_t sample;