From d1aee9f1535b02dc3db2a5bd1ac75213068a675a Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Tue, 12 May 2026 21:26:24 +0200 Subject: [PATCH] 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 5255d3bc9c7..ecde8a82649 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) {