Page MenuHomeFreeBSD

pps: Simplify the nsec calculation in pps_event()
Needs ReviewPublic

Authored by sebastian.huber_embedded-brains.de on Jul 26 2022, 8:26 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 9, 10:19 PM
Unknown Object (File)
Thu, May 2, 4:20 AM
Unknown Object (File)
Sat, Apr 27, 11:39 PM
Unknown Object (File)
Mon, Apr 22, 8:13 AM
Unknown Object (File)
Mar 18 2024, 5:08 PM
Unknown Object (File)
Dec 20 2023, 7:04 AM
Unknown Object (File)
Dec 16 2023, 6:10 PM
Unknown Object (File)
Dec 12 2023, 8:56 PM

Details

Reviewers
phk
gnn
delphij
Summary

The new calculation should have less problems with integer overflows.

Consider the following sample values with a tcount of 2000000100 and a
tc_frequency of 2000000000 (2GHz). The scale is 9223372036. Then scale *
tcount is 18446744994337203600 which is larger than
UINT64_MAX (18446744073709551615). The result is 49.

In the new calculation, 1000000000 * tcount is 2000000100000000000 which is
less than UINT64_MAX. This yields after the division with tc_frequency the
correct result of 1000000050.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 46581
Build 43470: arc lint + arc unit