On Fri, Mar 09, 2007 at 03:15:10PM -0800, Linus Torvalds wrote:
>
>
> On Sat, 10 Mar 2007, Oleg Verych wrote:
> >
> > OTOH, if i would write it this way
> >
> > #define BALIGN(x,bits) x) >> (bits)) + 1) << (bits))
>
> But that's *wrong*. It aligns something that is *already* aligned t
On Sat, 10 Mar 2007, Oleg Verych wrote:
>
> OTOH, if i would write it this way
>
> #define BALIGN(x,bits) x) >> (bits)) + 1) << (bits))
But that's *wrong*. It aligns something that is *already* aligned to
something else.
So you'd have to do it as something like
#define ALIG
On Wed, Mar 07, 2007 at 08:38:27AM -0800, Linus Torvalds wrote:
>
>
> On Wed, 7 Mar 2007, Oleg Verych wrote:
> >
> > Probably it can be used to get rid of gccisms and "type fluff" due to
> > bitwise arithmetics in ALIGN?
>
> Hell no.
>
> The typeof is there to make sure we have the right type,
On Wed, 7 Mar 2007, Oleg Verych wrote:
>
> GCC's assembler version of this macro is optimized as needed.
Not fora non-constant mask, I bet.
> But i wanted to address Al's statement about using typeof():
Well, that doesn't affect ALIGN(), since you can only use ALIGN() on an
arithmetic type a
On Wed, Mar 07, 2007 at 08:38:27AM -0800, Linus Torvalds wrote:
>
>
> On Wed, 7 Mar 2007, Oleg Verych wrote:
> >
> > Probably it can be used to get rid of gccisms and "type fluff" due to
> > bitwise arithmetics in ALIGN?
>
> Hell no.
>
> The typeof is there to make sure we have the right type,
On Wed, 7 Mar 2007, Oleg Verych wrote:
>
> Probably it can be used to get rid of gccisms and "type fluff" due to
> bitwise arithmetics in ALIGN?
Hell no.
The typeof is there to make sure we have the right type, and it's simple.
The current ALIGN() macro is efficient as hell (generating just a
> From: David Howells
> Newsgroups: gmane.linux.kernel
> Subject: Re: [PATCH] Fix get_order()
> Date: Wed, 07 Mar 2007 11:43:06 +
>
[]
> Various archs (including i386, x86_64, powerpc and frv) have instructions that
> can be used to calculate integer log2(N).
>
Probab
Linus Torvalds <[EMAIL PROTECTED]> wrote:
> > +#define ilog2_up(n) ((n) == 1 ? 0 : ilog2((n) - 1) + 1)
>
> This is wrong. It uses "n" twice, which makes it unsafe as a macro.
Damn. I missed that.
> Or it could use a "__builtin_constant_p()" (which gcc defines to not have
> side effects) to al
On Tue, 6 Mar 2007, David Howells wrote:
> /**
> + * ilog2_up - rounded up log of base 2 of 32-bit or a 64-bit unsigned value
> + * @n - parameter
> + *
> + * constant-capable log of base 2 calculation
> + * - this can be used to initialise global variables from constant data,
> hence
> + * t
Alexey Dobriyan <[EMAIL PROTECTED]> wrote:
> > #if BITS_PER_LONG == 32 && defined(ARCH_HAS_ILOG2_U32)
>
> There is no such thing except on FRV, where it's redundant.
Redundant in what way?
> CONFIG_ARCH_HAS_ILOG2_U32
> ^^^
On Tue, Mar 06, 2007 at 06:34:26PM +, David Howells wrote:
> Provide an ilog2_up() that rounds its result up (ilog2() rounds down).
>
> Fix get_order() to use ilog2_up() not ilog2() to get the correct rounding.
>
> Adjust the documentation surrounding ilog2() and co. to indicate what rounding
>
David Howells wrote:
H. Peter Anvin <[EMAIL PROTECTED]> wrote:
Why not just make it ((n) < 1 ? 0 : ...) and make it well-defined for
n == 0?
Because log2(0) is -INF or mathematically undefined or something isn't it?
Yes, but it's a *rounding up* function. In this case, it makes sense to
r
H. Peter Anvin <[EMAIL PROTECTED]> wrote:
> Why not just make it ((n) < 1 ? 0 : ...) and make it well-defined for
> n == 0?
Because log2(0) is -INF or mathematically undefined or something isn't it?
David
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a
Linus Torvalds <[EMAIL PROTECTED]> wrote:
> That seems bogus. "n == 1" should give "0", no?
Sigh. No. The comment header says it all:
/**
* roundup_pow_of_two - round the given value up to nearest power of two
* @n - parameter
*
* round the given val
H. Peter Anvin <[EMAIL PROTECTED]> wrote:
> Eh? roundup_pow_of_two(1) should be 0; 2^0 = 1.
Nonono.
roundup_pow_of_two(0) => ?
roundup_pow_of_two(1) => 1
roundup_pow_of_two(2) => 2
roundup_pow_of_two(3) => 4
roundup_pow_of_two(4) => 4
roundup_
David Howells wrote:
/**
+ * ilog2_up - rounded up log of base 2 of 32-bit or a 64-bit unsigned value
+ * @n - parameter
+ *
+ * constant-capable log of base 2 calculation
+ * - this can be used to initialise global variables from constant data, hence
+ * the massive ternary operator constru
On Tue, 6 Mar 2007, David Howells wrote:
> @@ -159,8 +175,8 @@ unsigned long __roundup_pow_of_two(unsigned long n)
> #define roundup_pow_of_two(n)\
> (\
> __builtin_constant_p(n) ? ( \
> - (n == 1)
David Howells wrote:
From: David Howells <[EMAIL PROTECTED]>
Provide an ilog2_up() that rounds its result up (ilog2() rounds down).
Fix get_order() to use ilog2_up() not ilog2() to get the correct rounding.
Adjust the documentation surrounding ilog2() and co. to indicate what rounding
they per
From: David Howells <[EMAIL PROTECTED]>
Provide an ilog2_up() that rounds its result up (ilog2() rounds down).
Fix get_order() to use ilog2_up() not ilog2() to get the correct rounding.
Adjust the documentation surrounding ilog2() and co. to indicate what rounding
they perform.
Fix roundup_pow_
H. Peter Anvin <[EMAIL PROTECTED]> wrote:
> if (size <= (1UL << page_shift))
> return 0;
> else
> return __ilog2_u32(size-1)+1-page_shift;
I think you're right. That'll also defend against the result of __ilog2_u32()
being less than page_shift-1.
I think
David Howells wrote:
From: David Howells <[EMAIL PROTECTED]>
Fix get_order() to use ilog2() properly.
Signed-Off-By: David Howells <[EMAIL PROTECTED]>
---
include/asm-generic/page.h | 14 +++---
include/linux/log2.h | 20 ++--
2 files changed, 29 insertions(+
From: David Howells <[EMAIL PROTECTED]>
Fix get_order() to use ilog2() properly.
Signed-Off-By: David Howells <[EMAIL PROTECTED]>
---
include/asm-generic/page.h | 14 +++---
include/linux/log2.h | 20 ++--
2 files changed, 29 insertions(+), 5 deletions(-)
diff
22 matches
Mail list logo