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/layout.c b/src/layout.c
index 15dec5d..fe11c91 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -16,6 +16,8 @@
 
 #include "hf/layout.h"
 
+#include "hf/std.h"
+
 /**
  * Get the address the .text section begins at.
  */
@@ -136,5 +138,5 @@
 	/* TODO: This is a hack. We must read the alignment from the binary. */
 	paddr_t bin_end = layout_bin_end();
 
-	return pa_init((pa_addr(bin_end) + 0x80000 - 1) & ~(0x80000 - 1));
+	return pa_init(align_up(pa_addr(bin_end), 0x80000));
 }