From 3ece5ac40c66c78b4abce74eeec6521ad661c53c Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Thu, 28 Mar 2013 16:17:11 -0500 Subject: 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 Reviewed-on: http://review.coreboot.org/2951 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- src/include/stdlib.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/include') 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)) -- cgit v1.2.3