Add alignment macros.

Introduces align_up, align_down and is_aligned macros that use compiler
builtins if available.
Note: when we fallback to the non-builtin case we could cast back from
uintptr_t to the original type using __typeof() if we accept the
non-standard extension.

Change-Id: Ie0c56f19cb0edc8a211d8c1182b9af5eb329cd8c
diff --git a/src/load.c b/src/load.c
index a9c0e5d..60b4ef4 100644
--- a/src/load.c
+++ b/src/load.c
@@ -273,9 +273,8 @@
 
 	/* Round the last addresses down to the page size. */
 	for (i = 0; i < params->mem_ranges_count; ++i) {
-		mem_ranges_available[i].end =
-			pa_init(pa_addr(mem_ranges_available[i].end) &
-				~(PAGE_SIZE - 1));
+		mem_ranges_available[i].end = pa_init(align_down(
+			pa_addr(mem_ranges_available[i].end), PAGE_SIZE));
 	}
 
 	while (memiter_parse_uint(&it, &mem) && memiter_parse_uint(&it, &cpu) &&