Skip to content

Commit d8b276e

Browse files
keith-packardjhedberg
authored andcommitted
sys/time_units.h: Make sys_clock_hw_cycles_per_sec() constant if possible
To be used in a global initializer, this must be a macro instead of a static inline when the return value is constant. Signed-off-by: Keith Packard <[email protected]>
1 parent ea61c8c commit d8b276e

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

include/zephyr/sys/time_units.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,11 @@ static inline int z_impl_sys_clock_hw_cycles_per_sec_runtime_get(void)
7070
* @brief Get the system timer frequency.
7171
* @return system timer frequency in Hz
7272
*/
73-
static TIME_CONSTEXPR inline int sys_clock_hw_cycles_per_sec(void)
74-
{
7573
#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
76-
return sys_clock_hw_cycles_per_sec_runtime_get();
74+
#define sys_clock_hw_cycles_per_sec() sys_clock_hw_cycles_per_sec_runtime_get()
7775
#else
78-
return CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
76+
#define sys_clock_hw_cycles_per_sec() CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC
7977
#endif
80-
}
8178

8279
/** @internal
8380
* Macro determines if fast conversion algorithm can be used. It checks if

0 commit comments

Comments
 (0)