diff --git a/include/kernel.h b/include/kernel.h index e9691db95a2..e7be91cc23e 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -2057,6 +2057,17 @@ static inline void *z_impl_k_timer_user_data_get(struct k_timer *timer) * @{ */ +/** + * @brief Get system uptime, in ticks. + * + * This routine returns the elapsed time since the system booted, in + * ticks (c.f. :option:`CONFIG_SYS_CLOCK_TICKS_PER_SEC`), which is the + * fundamental unit of resolution of kernel timekeeping. + * + * @return Current uptime in ticks. + */ +__syscall s64_t k_uptime_ticks(void); + /** * @brief Get system uptime. * @@ -2072,7 +2083,10 @@ static inline void *z_impl_k_timer_user_data_get(struct k_timer *timer) * * @return Current uptime in milliseconds. */ -__syscall s64_t k_uptime_get(void); +static inline s64_t k_uptime_get(void) +{ + return k_ticks_to_ms_floor64(k_uptime_ticks()); +} /** * @brief Enable clock always on in tickless kernel diff --git a/kernel/timeout.c b/kernel/timeout.c index cd797abdbce..eb1418000ff 100644 --- a/kernel/timeout.c +++ b/kernel/timeout.c @@ -268,17 +268,17 @@ u32_t z_tick_get_32(void) #endif } -s64_t z_impl_k_uptime_get(void) +s64_t z_impl_k_uptime_ticks(void) { - return k_ticks_to_ms_floor64(z_tick_get()); + return z_tick_get(); } #ifdef CONFIG_USERSPACE -static inline s64_t z_vrfy_k_uptime_get(void) +static inline s64_t z_vrfy_k_uptime_ticks(void) { - return z_impl_k_uptime_get(); + return z_impl_k_uptime_ticks(); } -#include +#include #endif /* Returns the uptime expiration (relative to an unlocked "now"!) of a