helpers: Add a helper macro for calculating power of 2

This change adds a helper macro POWER_OF_2 that is useful for
calculating the requested power of 2.

Change-Id: Ie70f93b6ac175699c11cae7d8f023a52cce01e88
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/39881
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Furquan Shaikh 2020-03-27 10:46:35 -07:00 committed by Patrick Georgi
parent 654d9d6b36
commit f79f8b4e33
1 changed files with 2 additions and 0 deletions

View File

@ -52,6 +52,8 @@
(_power_local_x & (_power_local_x - 1)) == 0; \ (_power_local_x & (_power_local_x - 1)) == 0; \
}) })
#define POWER_OF_2(x) (1ULL << (x))
#define DIV_ROUND_UP(x, y) ({ \ #define DIV_ROUND_UP(x, y) ({ \
__typeof__(x) _div_local_x = (x); \ __typeof__(x) _div_local_x = (x); \
__typeof__(y) _div_local_y = (y); \ __typeof__(y) _div_local_y = (y); \