Re: [RFC PATCH 1/6] kenrel.h: add ALIGN_OF_LAST_BIT()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 20, 2012 at 2:32 PM, Michal Nazarewicz <mina86@xxxxxxxxxx> wrote:
> On Tue, 20 Mar 2012 11:21:19 +0100, Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
> wrote:
>
>> Get the biggest 2**y that x % (2**y) == 0 for the align value.

>> --- a/include/linux/kernel.h
>> +++ b/include/linux/kernel.h
>> @@ -44,6 +44,8 @@
>>  #define PTR_ALIGN(p, a)                ((typeof(p))ALIGN((unsigned
>> long)(p), (a)))
>>  #define IS_ALIGNED(x, a)               (((x) & ((typeof(x))(a) - 1)) ==
>> 0)
>> +#define ALIGN_OF_LAST_BIT(x)   ((((x)^((x) - 1))>>1) + 1)
>
>
> Wouldn't ALIGNMENT() be less confusing? After all, that's what this macro is
> calculating, right? Alignment of given address.

Bits do not have alignment because they aren't directly addressable.
Can you hardcode this sequence with comment, because it looks too
special for macro.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]