[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <E1HOybN-00031m-6M@flower>
Date: Wed, 7 Mar 2007 17:02:53 +0100
From: Oleg Verych <olecom@...wer.upol.cz>
To: David Howells <dhowells@...hat.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Al Viro <viro@....linux.org.uk>, akpm@...ux-foundation.org,
benh@...nel.crashing.org, linux-kernel@...r.kernel.org,
hpa@...or.com, johannes@...solutions.net
Subject: ALIGN via ilog2 without gccisms (Re: [PATCH] Fix get_order())
> From: David Howells
> Newsgroups: gmane.linux.kernel
> Subject: Re: [PATCH] Fix get_order()
> Date: Wed, 07 Mar 2007 11:43:06 +0000
>
[]
> Various archs (including i386, x86_64, powerpc and frv) have instructions that
> can be used to calculate integer log2(N).
>
Probably it can be used to get rid of gccisms and "type fluff" due to
bitwise arithmetics in ALIGN?
Here:
#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
like that:
#define ALIGN(x,y) __ALIGN_MASK(x,ilog2(y))
#define __ALIGN_MASK(x,bits) (((((x) >> (bits)) << 1) + 2) << (bits - 1))
Note side effect, that this one always yields even result. Maybe this is
good, due to avoidance of misaligned access.
____
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists