summaryrefslogtreecommitdiff
path: root/src/include/stdlib.h
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2013-03-28 16:17:11 -0500
committerStefan Reinauer <stefan.reinauer@coreboot.org>2013-03-29 19:54:47 +0100
commit3ece5ac40c66c78b4abce74eeec6521ad661c53c (patch)
tree79d51d1479584789f6c6bcb0ed355ec86af96f50 /src/include/stdlib.h
parent4fa5fa5088503ff5c168b4fb8d548dd90034d29e (diff)
stdlib: add ALIGN_UP and ALIGN_DOWN macros
There wasn't an equivalent to align down so add ALIGN_DOWN. For symmetry provide an ALIGN_UP macro as well. Change-Id: I7033109311eeb15c8c69c649878785378790feb9 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/2951 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/include/stdlib.h')
-rw-r--r--src/include/stdlib.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/include/stdlib.h b/src/include/stdlib.h
index 83eb966b25..cb5a6ca703 100644
--- a/src/include/stdlib.h
+++ b/src/include/stdlib.h
@@ -7,6 +7,8 @@
#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1UL)
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
+#define ALIGN_UP(x,a) ALIGN((x),(a))
+#define ALIGN_DOWN(x,a) ((x) & ~((typeof(x))(a)-1UL))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))