]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Avoid divide in IS_ALIGN
authorHerbert Xu <herbert@gondor.apana.org.au>
Wed, 6 Feb 2008 09:37:05 +0000 (01:37 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Wed, 6 Feb 2008 18:41:04 +0000 (10:41 -0800)
I was happy to discover the brand new IS_ALIGN macro and quickly used it in
my code.  To my dismay I found that the generated code used division to
perform the test.

This patch fixes it by changing the % test to an &.  This avoids the
division.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/kernel.h

index ff356b2ee478d3dd006e67a76427a467525df7ae..18222f267bc4043f0a0ff0be1201d58938f1063a 100644 (file)
@@ -35,7 +35,7 @@ extern const char linux_proc_banner[];
 #define ALIGN(x,a)             __ALIGN_MASK(x,(typeof(x))(a)-1)
 #define __ALIGN_MASK(x,mask)   (((x)+(mask))&~(mask))
 #define PTR_ALIGN(p, a)                ((typeof(p))ALIGN((unsigned long)(p), (a)))
-#define IS_ALIGNED(x,a)                (((x) % ((typeof(x))(a))) == 0)
+#define IS_ALIGNED(x, a)               (((x) & ((typeof(x))(a) - 1)) == 0)
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))