git: d1aee9f1535b - main - sys/time.h: add bintime2us() helper
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 12 May 2026 19:30:19 UTC
The branch main has been updated by tuexen:
URL: https://cgit.FreeBSD.org/src/commit/?id=d1aee9f1535b02dc3db2a5bd1ac75213068a675a
commit d1aee9f1535b02dc3db2a5bd1ac75213068a675a
Author: Nick Banks <nickbanks@netflix.com>
AuthorDate: 2026-05-12 19:26:24 +0000
Commit: Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-05-12 19:26:24 +0000
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
---
sys/sys/time.h | 11 +++++++++++
1 file changed, 11 insertions(+)
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)
{