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 <benjamin.walsh@windriver.com>
diff --git a/include/kernel.h b/include/kernel.h
index 1828b01..f77584a 100644
--- a/include/kernel.h
+++ b/include/kernel.h
@@ -237,6 +237,16 @@
* kernel timing
*/
+#include <sys_clock.h>
+
+/* 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 d69963e..8a1b210 100644
--- a/include/legacy.h
+++ b/include/legacy.h
@@ -26,7 +26,6 @@
#include <stdint.h>
#include <errno.h>
#include <limits.h>
-#include <sys_clock.h>
/* nanokernel/microkernel execution context types */
#define NANO_CTX_ISR (K_ISR)
@@ -60,8 +59,7 @@
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)