diff options
author | Andrew Morton <akpm@osdl.org> | 2006-03-25 03:08:01 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-25 08:22:58 -0800 |
commit | 962749af67b145c57917bfbff3c303ebd7d5988c (patch) | |
tree | ce454f8a1cb0beb89c875a11d31426a4b44ca0ba /include/linux/kernel.h | |
parent | 231bed205879236357171e50bd8965e70797ecdc (diff) | |
download | op-kernel-dev-962749af67b145c57917bfbff3c303ebd7d5988c.zip op-kernel-dev-962749af67b145c57917bfbff3c303ebd7d5988c.tar.gz |
[PATCH] roundup_pow_of_two() 64-bit fix
fls() takes an integer, so roundup_pow_of_two() is busted for ulongs larger
than 2^32-1.
Fix this by implementing and using fls_long().
(Why does roundup_pow_of_two() return a long?)
(Why is roundup_pow_of_two() __attribute_const__ whereas long_log2() is
__attribute_pure__?)
(Why does long_log2() suck so much? Because we were missing fls_long()?)
Cc: Roland Dreier <rdreier@cisco.com>
Cc: "Chen, Kenneth W" <kenneth.w.chen@intel.com>
Cc: John Hawkes <hawkes@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index bb6e7dd..03d6cfa 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -154,9 +154,10 @@ static inline int __attribute_pure__ long_log2(unsigned long x) return r; } -static inline unsigned long __attribute_const__ roundup_pow_of_two(unsigned long x) +static inline unsigned long +__attribute_const__ roundup_pow_of_two(unsigned long x) { - return (1UL << fls(x - 1)); + return 1UL << fls_long(x - 1); } extern int printk_ratelimit(void); |