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>
This commit is contained in:
Benjamin Walsh 2016-09-21 11:05:56 -04:00
commit a9604bd895
2 changed files with 11 additions and 3 deletions

View file

@ -237,6 +237,16 @@ extern void *k_thread_custom_data_get(void);
* 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;

View file

@ -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 @@ 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)