From 4a51c21afce7f84ed28792038854d3d37b71083e Mon Sep 17 00:00:00 2001 From: ligd Date: Wed, 11 Dec 2024 18:02:08 +0800 Subject: [PATCH] sched/clock: call up_timer_gettime() to get higher resolution Signed-off-by: ligd --- include/nuttx/clock.h | 6 ------ sched/clock/clock.h | 2 +- sched/clock/clock_systime_ticks.c | 12 +++--------- sched/clock/clock_systime_timespec.c | 9 +++------ 4 files changed, 7 insertions(+), 22 deletions(-) diff --git a/include/nuttx/clock.h b/include/nuttx/clock.h index 5afc8ed605e91..b750e5347dae8 100644 --- a/include/nuttx/clock.h +++ b/include/nuttx/clock.h @@ -334,10 +334,6 @@ extern "C" #ifdef __HAVE_KERNEL_GLOBALS EXTERN volatile clock_t g_system_ticks; - -# ifndef CONFIG_SYSTEM_TIME64 -# define clock_systime_ticks() g_system_ticks -# endif #endif /**************************************************************************** @@ -695,9 +691,7 @@ void clock_resynchronize(FAR struct timespec *rtc_diff); * ****************************************************************************/ -#if !defined(__HAVE_KERNEL_GLOBALS) || defined(CONFIG_SYSTEM_TIME64) clock_t clock_systime_ticks(void); -#endif /**************************************************************************** * Name: clock_systime_timespec diff --git a/sched/clock/clock.h b/sched/clock/clock.h index 9e49af0e9497a..507adac3476d8 100644 --- a/sched/clock/clock.h +++ b/sched/clock/clock.h @@ -56,7 +56,7 @@ * Public Data ****************************************************************************/ -#if !defined(CONFIG_SCHED_TICKLESS) && !defined(__HAVE_KERNEL_GLOBALS) +#if !defined(__HAVE_KERNEL_GLOBALS) /* The system clock exists (CONFIG_SCHED_TICKLESS), but it not prototyped * globally in include/nuttx/clock.h. */ diff --git a/sched/clock/clock_systime_ticks.c b/sched/clock/clock_systime_ticks.c index a638719f947dd..a99d8e10406c9 100644 --- a/sched/clock/clock_systime_ticks.c +++ b/sched/clock/clock_systime_ticks.c @@ -85,19 +85,13 @@ clock_t clock_systime_ticks(void) clock_systime_timespec(&ts); return clock_time2ticks(&ts); -#elif defined(CONFIG_SCHED_TICKLESS_TICK_ARGUMENT) +#elif defined(CONFIG_ALARM_ARCH) || \ + defined(CONFIG_TIMER_ARCH) || \ + defined(CONFIG_SCHED_TICKLESS) clock_t ticks = 0; up_timer_gettick(&ticks); return ticks; -#elif defined(CONFIG_SCHED_TICKLESS) - struct timespec ts = - { - 0 - }; - - up_timer_gettime(&ts); - return clock_time2ticks(&ts); #elif defined(CONFIG_SYSTEM_TIME64) clock_t sample; clock_t verify; diff --git a/sched/clock/clock_systime_timespec.c b/sched/clock/clock_systime_timespec.c index b27c548631f00..2e60b59a5becc 100644 --- a/sched/clock/clock_systime_timespec.c +++ b/sched/clock/clock_systime_timespec.c @@ -77,12 +77,9 @@ int clock_systime_timespec(FAR struct timespec *ts) ts->tv_sec = 0; ts->tv_nsec = 0; } -#elif defined(CONFIG_SCHED_TICKLESS_TICK_ARGUMENT) - clock_t ticks = 0; - - up_timer_gettick(&ticks); - clock_ticks2time(ts, ticks); -#elif defined(CONFIG_SCHED_TICKLESS) +#elif defined(CONFIG_ALARM_ARCH) || \ + defined(CONFIG_TIMER_ARCH) || \ + defined(CONFIG_SCHED_TICKLESS) up_timer_gettime(ts); #else clock_ticks2time(ts, g_system_ticks);