lib: Add __fls() (Find Last Set)
Implement __fls() as an alias for log2(), and remove the duplicate definitions in commonlib/storage/sdhci.c. Signed-off-by: Jianjun Wang <jianjun.wang@mediatek.com> Change-Id: Ib458abfec7e03b2979569a8440a6e69b0285ac32 Reviewed-on: https://review.coreboot.org/c/coreboot/+/59738 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
This commit is contained in:
committed by
Hung-Te Lin
parent
5588f34a35
commit
8bb59ca2fa
@ -37,6 +37,15 @@ void test_ffs(void **state)
|
||||
assert_int_equal(__ffs(0xffffffff), 0);
|
||||
}
|
||||
|
||||
void test_fls(void **state)
|
||||
{
|
||||
assert_int_equal(__fls(0x0), -1);
|
||||
assert_int_equal(__fls(0x1), 0);
|
||||
assert_int_equal(__fls(0x5), 2);
|
||||
assert_int_equal(__fls(0x80000000), 31);
|
||||
assert_int_equal(__fls(0xffffffff), 31);
|
||||
}
|
||||
|
||||
void test_log2_ceil(void **state)
|
||||
{
|
||||
assert_int_equal(log2_ceil(0x0), -1);
|
||||
@ -53,6 +62,7 @@ int main(void)
|
||||
cmocka_unit_test(test_clz),
|
||||
cmocka_unit_test(test_log2),
|
||||
cmocka_unit_test(test_ffs),
|
||||
cmocka_unit_test(test_fls),
|
||||
cmocka_unit_test(test_log2_ceil),
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user