Skip to content

Commit

Permalink
tests/timer_api: Make sure constant time conversions are constants
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
keith-packard authored and jhedberg committed Oct 6, 2023
1 parent d8b276e commit 1b057d6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/kernel/timer/timer_api/src/timer_convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
}
Expand Down

0 comments on commit 1b057d6

Please sign in to comment.