sys/time.h: add bintime2us() helper
Add a microsecond conversion helper to complement the existing bintime2ns(). The body mirrors bintime2ns(). This will be used by an upcoming eventlog(9) framework as well as the TCP code in upcoming changes. Approved by: gallatin, tuexen Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D56972
This commit is contained in:
committed by
Michael Tuexen
parent
03bc95b060
commit
d1aee9f153
@@ -308,6 +308,17 @@ bintime2ns(const struct bintime *_bt)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static __inline uint64_t
|
||||
bintime2us(const struct bintime *_bt)
|
||||
{
|
||||
uint64_t ret;
|
||||
|
||||
ret = (uint64_t)(_bt->sec) * (uint64_t)1000000;
|
||||
ret += __utime64_scale64_floor(
|
||||
_bt->frac, 1000000, 1ULL << 32) >> 32;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
timespec2bintime(const struct timespec *_ts, struct bintime *_bt)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user