From 1b057d6295cba9ef73048185ace4b5d8e4ee2101 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 5 Oct 2023 13:35:04 -0700 Subject: [PATCH] tests/timer_api: Make sure constant time conversions are constants When the timer frequency is known at compile time, make sure we can use any time conversion macro as a global initializer. Signed-off-by: Keith Packard --- tests/kernel/timer/timer_api/src/timer_convert.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/kernel/timer/timer_api/src/timer_convert.c b/tests/kernel/timer/timer_api/src/timer_convert.c index f29af361cee2..19b96419d1b3 100644 --- a/tests/kernel/timer/timer_api/src/timer_convert.c +++ b/tests/kernel/timer/timer_api/src/timer_convert.c @@ -33,7 +33,16 @@ struct test_rec { (void *)test_##src##_to_##dst##_##round##prec \ } \ +#ifdef CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME +#define TESTVAR(src, dst, round, prec) +#else +#define TESTVAR(src, dst, round, prec) \ + uint##prec##_t test_##src##_to_##dst##_##round##prec##_val = \ + k_##src##_to_##dst##_##round##prec(42); +#endif + #define TESTFUNC(src, dst, round, prec) \ + TESTVAR(src, dst, round, prec) \ static uint##prec##_t test_##src##_to_##dst##_##round##prec(uint##prec##_t t) { \ return k_##src##_to_##dst##_##round##prec(t); \ }