lkml.org 
[lkml]   [2008]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] introduce lower_32_bits() macro
Andrew Morton wrote:
>>> */
>>> #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
>>>
>>> +/**
>>> + * lower_32_bits - return bits 0-31 of a number
>>> + * @n: the number we're accessing
>>> + */
>>> +#define lower_32_bits(n) ((n) & 0xffffffffULL)
>>> +
>> NAK. These are assymmetric with regards to type, which is the *last*
>> thing we want.
>
> Yes, it will convert a 32-bit expression into a 64-bit one.
>

Sort of. upper_32_bits() takes a 32- or 64-bit expression, and delivers
the upper 32 bits *as a 32-bit number*. An equivalent expression would be:

((u32)((u64)(n) >> 32))

... which might actually produce better code, for all I know.

Logically speaking, if we have a lower_32_bits() macro, it should also
produce a 32-bit type as result.

-hpa



\
 
 \ /
  Last update: 2008-07-25 22:59    [W:0.066 / U:0.344 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site