From 8b54953e4b545408d4e1c40e9f559a36aaef59d6 Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Tue, 25 Sep 2018 08:19:21 -0700 Subject: [PATCH] kernel/sys_clock: Fix build when !SYS_CLOCK_EXISTS This got broken. Add some #ifery to handle the case. Not clean, will clean up in a future pass once the API is final. Signed-off-by: Andy Ross --- kernel/idle.c | 2 ++ kernel/include/timeout_q.h | 7 +++++++ kernel/sys_clock.c | 8 ++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/kernel/idle.c b/kernel/idle.c index a59defcee8a..920d05272cd 100644 --- a/kernel/idle.c +++ b/kernel/idle.c @@ -65,7 +65,9 @@ static void sys_power_save_idle(s32_t ticks) * saves no power and does not improve latency. But it's an * API we need to honor... */ +#ifdef CONFIG_SYS_CLOCK_EXISTS z_clock_set_timeout(ticks < IDLE_THRESH ? 1 : ticks, true); +#endif set_kernel_idle_time_in_ticks(ticks); #if (defined(CONFIG_SYS_POWER_LOW_POWER_STATE) || \ diff --git a/kernel/include/timeout_q.h b/kernel/include/timeout_q.h index ef68b0a351e..936291398fb 100644 --- a/kernel/include/timeout_q.h +++ b/kernel/include/timeout_q.h @@ -18,6 +18,11 @@ extern "C" { #endif +/* If no clock, these get defined in wait_q.h instead. Weird header + * convention, should fix. + */ +#ifdef CONFIG_SYS_CLOCK_EXISTS + extern u64_t z_last_tick_announced; void _init_timeout(struct _timeout *t, _timeout_func_t func); @@ -36,6 +41,8 @@ int _abort_thread_timeout(struct k_thread *thread); s32_t _get_next_timeout_expiry(void); +#endif + #ifdef __cplusplus } #endif diff --git a/kernel/sys_clock.c b/kernel/sys_clock.c index c428a725c53..13b8a16a16d 100644 --- a/kernel/sys_clock.c +++ b/kernel/sys_clock.c @@ -21,6 +21,7 @@ #endif #ifdef CONFIG_SYS_CLOCK_EXISTS +static void _handle_expired_timeouts(sys_dlist_t *expired); #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME) int z_clock_hw_cycles_per_sec = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC; #endif @@ -50,8 +51,6 @@ int _sys_clock_always_on = 1; static u32_t next_ts; #endif -static void _handle_expired_timeouts(sys_dlist_t *expired); - u32_t z_tick_get_32(void) { #ifdef CONFIG_TICKLESS_KERNEL @@ -359,6 +358,8 @@ void k_disable_sys_clock_always_on(void) #endif } +#ifdef CONFIG_SYS_CLOCK_EXISTS + extern u64_t z_last_tick_announced; /* initialize the timeouts part of k_thread when enabled in the kernel */ @@ -413,6 +414,7 @@ static inline void _unpend_thread_timing_out(struct k_thread *thread, } } + /* * Handle one timeout from the expired timeout queue. Removes it from the wait * queue it is on if waiting for an object; in this case, the return value is @@ -620,3 +622,5 @@ void _add_thread_timeout(struct k_thread *thread, { _add_timeout(thread, &thread->base.timeout, wait_q, timeout_in_ticks); } + +#endif /* CONFIG_SYS_CLOCK_EXISTS */