os/time: Add function to convert to a timespec struct

This commit is contained in:
Jakob Bornecrantz 2020-06-23 18:01:13 +01:00
parent b75f4f844b
commit ef282c7df2

View file

@ -82,6 +82,17 @@ os_timespec_to_ns(struct timespec *spec)
ns += (uint64_t)spec->tv_nsec;
return ns;
}
/*!
* @brief Convert an nanosecond integer to a timespec struct.
* @ingroup aux_os_time_extra
*/
static inline void
os_ns_to_timespec(uint64_t ns, struct timespec *spec)
{
spec->tv_sec = (ns / (1000 * 1000 * 1000));
spec->tv_nsec = (ns % (1000 * 1000 * 1000));
}
#endif // XRT_HAVE_TIMESPEC