From: Jean-Christophe PLAGNIOL-VILLARD Date: Tue, 20 May 2008 23:09:14 +0200 Subject: [U-Boot-Users] [PATCH 1/4] Add ALIGN() macro In-Reply-To: <1211315046-8460-1-git-send-email-afleming@freescale.com> References: <1211315046-8460-1-git-send-email-afleming@freescale.com> Message-ID: <20080520210914.GB18756@game.jcrosoft.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 15:24 Tue 20 May , Andy Fleming wrote: > ALIGN() returns the smallest aligned value greater than the passed > in address or size. Taken from Linux. > > Signed-off-by: Andy Fleming > --- > include/common.h | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/include/common.h b/include/common.h > index d0f5704..68e0cbc 100644 > --- a/include/common.h > +++ b/include/common.h > @@ -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)) please fix coding style and use tab instead of space for indent #define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x)) (a) - 1) #define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) Best Regards, J.