From fd570665ce9eb76e02d1fe5fb958e87ea017fd73 Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Mon, 7 Jul 2014 20:33:09 +1000 Subject: 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 Reviewed-on: http://review.coreboot.org/6198 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- src/include/stdlib.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/include') diff --git a/src/include/stdlib.h b/src/include/stdlib.h index 44d7c0126b..9bc0ebc97b 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)) -- cgit v1.2.3