Raul Rangel has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/40761 )
Change subject: src/include/lib.h: Add is_power_of_two ......................................................................
src/include/lib.h: Add is_power_of_two
Used to check if a number is a power of two at runtime.
BUG=b:147042464
Signed-off-by: Raul E Rangel rrangel@chromium.org Change-Id: Ia238773b15b600b7b6062b741a24a93081398a43 --- M src/include/lib.h 1 file changed, 6 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/40761/1
diff --git a/src/include/lib.h b/src/include/lib.h index 168d8ca..f353ce5 100644 --- a/src/include/lib.h +++ b/src/include/lib.h @@ -55,4 +55,10 @@ /* Integer binary logarithm (rounding up): log2_ceil(0) == -1, log2(5) == 3 */ static inline int log2_ceil(u32 x) { return (x == 0) ? -1 : log2(x * 2 - 1); }
+/* Return 1 if number is power of two */ +static inline unsigned int is_power_of_two(unsigned int x) +{ + return (x != 0) && ((x & (x - 1)) == 0); +} + #endif /* __LIB_H__ */
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40761 )
Change subject: src/include/lib.h: Add is_power_of_two ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/40761/1/src/include/lib.h File src/include/lib.h:
https://review.coreboot.org/c/coreboot/+/40761/1/src/include/lib.h@61 PS1, Line 61: return (x != 0) && ((x & (x - 1)) == 0); please, no spaces at the start of a line
Raul Rangel has uploaded a new patch set (#2). ( https://review.coreboot.org/c/coreboot/+/40761 )
Change subject: src/include/lib.h: Add is_power_of_two ......................................................................
src/include/lib.h: Add is_power_of_two
Used to check if a number is a power of two at runtime.
BUG=b:147042464
Signed-off-by: Raul E Rangel rrangel@chromium.org Change-Id: Ia238773b15b600b7b6062b741a24a93081398a43 --- M src/include/lib.h 1 file changed, 6 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/40761/2
Furquan Shaikh has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/40761 )
Change subject: src/include/lib.h: Add is_power_of_two ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/40761/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/40761/1//COMMIT_MSG@7 PS1, Line 7: Add is_power_of_two Use https://review.coreboot.org/cgit/coreboot.git/tree/src/commonlib/bsd/include... instead?
Raul Rangel has abandoned this change. ( https://review.coreboot.org/c/coreboot/+/40761 )
Change subject: src/include/lib.h: Add is_power_of_two ......................................................................
Abandoned
There already exists IS_POWER_OF_2