Skip to contentSkip to conversation

Add ALIGN() macro

PATCH New Andy Fleming 2 participants 2 messages May 20, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add ALIGN() macro

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

---
 include/common.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/common.h +3 -0
index d0f5704..68e0cbc 100644
@@ -671,6 +671,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);
Signature · 1 line
1.5.4.GIT
#1 lore raw

PATCH 1/1 Add ALIGN() macro

Quoted 4 lines · Andy Fleming

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

Shoot, let me do that again with numbering. If they are applied out of order, there's badness. Please ignore the 4 patches I sent out.