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)
Sun, Feb 8, 12:27 AM
Unknown Object (File)
Fri, Jan 30, 12:19 AM
Unknown Object (File)
Dec 27 2025, 1:05 PM
Unknown Object (File)
Dec 27 2025, 1:05 PM
Unknown Object (File)
Dec 27 2025, 1:05 PM
Unknown Object (File)
Dec 25 2025, 8:07 PM
Unknown Object (File)
Dec 24 2025, 10:12 PM
Unknown Object (File)
Dec 20 2025, 2:09 AM
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