kernel/timeout: Add k_uptime_ticks() API
Add a call to get the system tick count as an official API (and redefine the existing millisecond API in terms of it). Sophisticated applications need to be able to count ticks directly, and the newer timeout API supports that. Uptime should too, for symmetry. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
5a5d3daf6f
commit
914205ca85
2 changed files with 20 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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 <syscalls/k_uptime_get_mrsh.c>
|
||||
#include <syscalls/k_uptime_ticks_mrsh.c>
|
||||
#endif
|
||||
|
||||
/* Returns the uptime expiration (relative to an unlocked "now"!) of a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue