summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward O'Callaghan <eocallaghan@alterapraxis.com>2014-07-07 20:33:09 +1000
committerEdward O'Callaghan <eocallaghan@alterapraxis.com>2014-07-10 20:50:16 +0200
commitfd570665ce9eb76e02d1fe5fb958e87ea017fd73 (patch)
tree5d11e7124936be0fdb961c87eabcee3c33fcf389
parent4793328fbd00776046f43ef8d5f0775c54a7e572 (diff)
downloadcoreboot-fd570665ce9eb76e02d1fe5fb958e87ea017fd73.tar.xz
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> Reviewed-on: http://review.coreboot.org/6198 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
-rw-r--r--src/include/stdlib.h3
1 files changed, 3 insertions, 0 deletions
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))