CommonFuncs: Convert ROUND_UP_POW2 macro to a function

Also move it to MathUtils where it belongs with the rest of the
power-of-two functions. This gets rid of pollution of the current scope
of any translation unit with b<value> macros that aren't intended to be
used directly.
This commit is contained in:
Lioncash 2018-05-10 19:06:19 -04:00
parent 3cca051850
commit ba01f6dba3
7 changed files with 29 additions and 23 deletions

View file

@ -30,3 +30,11 @@ TEST(MathUtil, IntLog2)
EXPECT_EQ(3, IntLog2(15));
EXPECT_EQ(63, IntLog2(0xFFFFFFFFFFFFFFFFull));
}
TEST(MathUtil, NextPowerOf2)
{
EXPECT_EQ(4, MathUtil::NextPowerOf2(3));
EXPECT_EQ(4, MathUtil::NextPowerOf2(4));
EXPECT_EQ(8, MathUtil::NextPowerOf2(6));
EXPECT_EQ(0x40000000, MathUtil::NextPowerOf2(0x23456789));
}