Commit 05f51137 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/libwr: add functions get_monotonic_*

Add function get_monotonic_tics and get_monotonic_sec to the libwr to keep
them in the one place.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent ccdc9a56
......@@ -8,5 +8,9 @@
void shw_udelay_init(void);
void shw_udelay(uint32_t microseconds);
/* get monotonic number of useconds */
uint64_t get_monotonic_tics(void);
/* get monotonic number of seconds */
time_t get_monotonic_sec(void);
#endif /* __LIBWR_HW_UTIL_H */
......@@ -52,3 +52,21 @@ void shw_udelay(uint32_t microseconds)
for (i = 0; i < loops_per_msec * microseconds / 1000; i++)
;
}
/* get monotonic number of useconds */
uint64_t get_monotonic_tics(void)
{
struct timespec tv;
clock_gettime(CLOCK_MONOTONIC, &tv);
return (uint64_t) tv.tv_sec * 1000000ULL +
(uint64_t) (tv.tv_nsec / 1000);
}
/* get monotonic number of seconds */
time_t get_monotonic_sec(void)
{
struct timespec tv;
clock_gettime(CLOCK_MONOTONIC, &tv);
return tv.tv_sec;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment