lkml.org 
[lkml]   [2010]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 24/38] move round_up/down to kernel.h
On 01/22/2010 11:28 AM, Joe Perches wrote:
> On Fri, 2010-01-22 at 08:52 -0600, Christoph Lameter wrote:
>> On Fri, 22 Jan 2010, Yinghai Lu wrote:
>>> +#define __round_mask(x,y) ((__typeof__(x))((y)-1))
>>> +#define round_up(x,y) ((((x)-1) | __round_mask(x,y))+1)
>>> +#define round_down(x,y) ((x) & ~__round_mask(x,y))
>> s/round/round_power2/
>
> s/round/round_power_of_2/
> BUILD_BUG_ON_NOT_POWER_OF_2
>

Uh... the whole reason why the classical rounding functions don't work
is that we're using it with non-constants, and therefore the compiler
doesn't know that we're restricted to powers of two (and therefore it
will generate divides.)

-hpa


\
 
 \ /
  Last update: 2010-01-22 21:11    [W:3.358 / U:0.436 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site