Messages in this thread | | | Date | Fri, 25 Jul 2008 16:54:45 -0400 | From | "H. Peter Anvin" <> | Subject | Re: [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
| |