diff --git a/include/kernel.h b/include/kernel.h index 1828b016fb4..f77584ac367 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -237,6 +237,16 @@ extern void *k_thread_custom_data_get(void); * kernel timing */ +#include + +/* private internal time manipulation (users should never play with ticks) */ + +static int64_t __ticks_to_ms(int64_t ticks) +{ + return (MSEC_PER_SEC * (uint64_t)ticks) / sys_clock_ticks_per_sec; +} + + /* timeouts */ struct _timeout; diff --git a/include/legacy.h b/include/legacy.h index d69963e1b1d..8a1b210e037 100644 --- a/include/legacy.h +++ b/include/legacy.h @@ -26,7 +26,6 @@ #include #include #include -#include /* nanokernel/microkernel execution context types */ #define NANO_CTX_ISR (K_ISR) @@ -60,8 +59,7 @@ typedef enum { static inline int32_t _ticks_to_ms(int32_t ticks) { - return (ticks == TICKS_UNLIMITED) ? K_FOREVER : - (MSEC_PER_SEC * (uint64_t)ticks) / sys_clock_ticks_per_sec; + return (ticks == TICKS_UNLIMITED) ? K_FOREVER : __ticks_to_ms(ticks); } static inline int _error_to_rc(int err)