From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nikita Danilov Date: Wed, 30 Aug 2006 16:11:44 +0000 Subject: Re: [RFC][PATCH 01/10] put alignment macros in align.h Message-Id: <17653.47296.222332.231821@gargle.gargle.HOWL> List-Id: References: <20060829201934.A5363374@localhost.localdomain> In-Reply-To: <20060829201934.A5363374@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-ia64@vger.kernel.org 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. Nikita.