Browse Source

Add ALIGN() macro

ALIGN() returns the smallest aligned value greater than the passed
in address or size.  Taken from Linux.

Signed-off-by: Andy Fleming <afleming@freescale.com>
Andy Fleming 17 years ago
parent
commit
4b03ac8b51
1 changed files with 3 additions and 0 deletions
  1. 3 0
      include/common.h

+ 3 - 0
include/common.h

@@ -682,6 +682,9 @@ void __attribute__((weak)) show_boot_progress (int val);
 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
 #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
 
+#define ALIGN(x,a)		__ALIGN_MASK((x),(typeof(x))(a)-1)
+#define __ALIGN_MASK(x,mask)	(((x)+(mask))&~(mask))
+
 /* Multicore arch functions */
 #ifdef CONFIG_MP
 int cpu_status(int nr);