Edward O'Callaghan (eocallaghan@alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6198
-gerrit
commit 4e285ebbd3c301fc85fda0d6ac122b28c2cba574 Author: Edward O'Callaghan eocallaghan@alterapraxis.com Date: Mon Jul 7 20:33:09 2014 +1000
include/stdlib.h: Extend common macro collection
Add the following useful macros:
* Absolute Value Macro * Taking ceiling of (a / b) * Check if value x is a power of 2 or not
Change-Id: I4e9a326aea3cdd963f13548d1fb63331a57d84b1 Signed-off-by: Edward O'Callaghan eocallaghan@alterapraxis.com --- src/include/stdlib.h | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/include/stdlib.h b/src/include/stdlib.h index 44d7c01..9bc0ebc 100644 --- a/src/include/stdlib.h +++ b/src/include/stdlib.h @@ -12,6 +12,9 @@
#define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b)) +#define ABS(a) (((a) < 0) ? (-(a)) : (a)) +#define CEIL_DIV(a, b) (((a) + (b) - 1) / (b)) +#define IS_POWER_OF_2(x) (((x) & ((x) - 1)) == 0)
#define min(a,b) MIN((a),(b)) #define max(a,b) MAX((a),(b))