From a9604bd895352512d2a6bee110c5b3c29c2c4ead Mon Sep 17 00:00:00 2001 From: Benjamin Walsh Date: Wed, 21 Sep 2016 11:05:56 -0400 Subject: [PATCH] unified: move basic ticks-to-ms conversion to kernel.h The basic conversion, i.e. not handling the TICKS_UNLIMITED case, is useful internally since the kernel is still tick-based. Change-Id: I00a01047ec48dad6834dd8ea5dc831eb8c0c2501 Signed-off-by: Benjamin Walsh --- include/kernel.h | 10 ++++++++++ include/legacy.h | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-) 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)