Re: [RFC][PATCH 01/10] put alignment macros in align.h

From: Dave Hansen <haveblue_at_us.ibm.com>
Date: 2006-08-31 02:48:49
On Wed, 2006-08-30 at 20:11 +0400, Nikita Danilov wrote:
> Dave Hansen writes:
>  > + */
>  > +#ifndef __ASSEMBLY__
>  > +#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))
> 
> This evaluates (a) twice. While in all existing call-sites (a) is
> probably a constant, it's still safer to do
> 
> #define ALIGN(x,a) ({ typeof(a) __a = (a); (((x) + __a - 1) & ~(__a - 1)); })
> 
> in a generic macro and rely on compiler to optimize temporary variable
> out.

Looks great to me.  I'll incorporate it for the next version. 

-- Dave

-
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Thu Aug 31 02:49:36 2006

This archive was generated by hypermail 2.1.8 : 2006-08-31 02:49:46 EST