lkml.org 
[lkml]   [2005]   [Apr]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 0/6] add generic round_up_pow2() macro
Andrew Morton wrote:
> Nick Wilson <njw@osdl.org> wrote:
>
>>The first patch adds a generic round_up_pow2() macro to kernel.h. The
>> remaining patches modify a few files to make use of the new macro.
>
>
> We already have ALIGN() and roundup_pow_of_two().

cool. It doesn't handle x={0,1} though.
Maybe we should have:

static inline unsigned long __attribute_const__
__roundup_pow_of_two(unsigned long x)
{
return (1UL << fls(x - 1));
}

static inline unsigned long __attribute_const__
roundup_pow_of_two(unsigned long x)
{
return (unlikely(x<2)?2:__roundup_pow_of_two(x));
}

--
Pádraig Brady - http://www.pixelbeat.org
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-04-08 12:02    [W:0.078 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site