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, May 7, 12:24 PM
Unknown Object (File)
Wed, May 6, 10:42 PM
Unknown Object (File)
Wed, May 6, 6:23 AM
Unknown Object (File)
Mon, May 4, 5:38 AM
Unknown Object (File)
Apr 27 2026, 6:07 AM
Unknown Object (File)
Apr 15 2026, 1:36 PM
Unknown Object (File)
Apr 15 2026, 1:26 PM
Unknown Object (File)
Apr 12 2026, 12:10 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