aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Banks <nickbanks@netflix.com>2026-05-12 19:26:24 +0000
committerMichael Tuexen <tuexen@FreeBSD.org>2026-05-12 19:26:24 +0000
commitd1aee9f1535b02dc3db2a5bd1ac75213068a675a (patch)
tree34a16d6570f9bc2978f3e079cd0d50d381b8c6bd
parent03bc95b060a91ed9d410270d00d1dd4f8edcdcc7 (diff)
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
-rw-r--r--sys/sys/time.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/sys/time.h b/sys/sys/time.h
index 5255d3bc9c7e..ecde8a826499 100644
--- a/sys/sys/time.h
+++ b/sys/sys/time.h
@@ -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)
{