Page MenuHomeFreeBSD

sys/time: Add saturating sbt conversions
ClosedPublic

Authored by jfree on Mar 10 2026, 12:51 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 11, 11:42 AM
Unknown Object (File)
Wed, Apr 8, 10:29 PM
Unknown Object (File)
Wed, Apr 8, 9:54 AM
Unknown Object (File)
Mon, Apr 6, 4:41 PM
Unknown Object (File)
Mon, Apr 6, 12:18 PM
Unknown Object (File)
Sun, Apr 5, 1:17 PM
Unknown Object (File)
Sun, Apr 5, 6:28 AM
Unknown Object (File)
Thu, Apr 2, 8:05 AM
Subscribers
None

Details

Summary

When converting from timespec to sbintime, the timespec's 64-bit tv_sec
component is shifted to the left 32 bits, causing any information in the
upper 32 bits to be lost.

This data loss during conversion can turn timespecs with very large
tv_sec counters into sbintimes that represent much smaller time
durations.

Add tstosbt_sat() and tvtosbt_sat(), which are saturating versions of
tstosbt and tvtosbt. With these routines, any overflow resulting from
the conversion is clamped to [-SBT_MAX - 1, SBT_MAX].

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable