Page MenuHomeFreeBSD

roundup_pow_of_two: use ispower instead
ClosedPublic

Authored by dougm on Sep 28 2024, 7:05 PM.
Tags
None
Referenced Files
F167409260: D46838.id143881.diff
Fri, Aug 21, 2:44 PM
Unknown Object (File)
Thu, Aug 20, 8:08 PM
Unknown Object (File)
Thu, Aug 20, 12:32 PM
Unknown Object (File)
Thu, Aug 20, 1:01 AM
Unknown Object (File)
Wed, Aug 19, 10:52 AM
Unknown Object (File)
Tue, Aug 18, 8:26 PM
Unknown Object (File)
Sat, Aug 15, 4:00 PM
Unknown Object (File)
Tue, Aug 11, 8:51 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