Page MenuHomeFreeBSD

roundup_pow_of_two: use ispower instead
ClosedPublic

Authored by dougm on Sep 28 2024, 7:05 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 2, 4:44 AM
Unknown Object (File)
Thu, Oct 2, 1:11 AM
Unknown Object (File)
Sep 2 2025, 12:30 AM
Unknown Object (File)
Aug 12 2025, 9:38 PM
Unknown Object (File)
Aug 9 2025, 5:23 AM
Unknown Object (File)
Aug 1 2025, 11:49 PM
Unknown Object (File)
Jul 26 2025, 8:25 PM
Unknown Object (File)
Jul 6 2025, 10:15 PM
Subscribers

Details

Summary

The fastest way to check if a number is a power of two is not to compute roundup_pow_of_two; it is to use ispower2 (param.h) or is_power_of_2 (log2.h in linux). Do that in two places.

Also, in one place, use order_base_2 instead of ilog2(roundup_pow_of_two()).

Diff Detail

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