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>
This commit is contained in:
parent
4fa5fa5088
commit
3ece5ac40c
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1UL)
|
#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1UL)
|
||||||
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
|
#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 MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||||
|
|
Loading…
Reference in New Issue