diff options
author | Richard Henderson <rth@twiddle.net> | 2007-05-29 19:01:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-30 13:07:54 -0400 |
commit | 74fd1b687fbeba566ceb59cc1fdbc7a64c5e0c0b (patch) | |
tree | efc6ffd2080ec94bef934758f40c220d710adf28 /include/asm-alpha/bitops.h | |
parent | f54496f55a729078e9eef90bf9e0783857a27db1 (diff) |
alpha: cleanup in bitops.h
Remove 2 functions private to the alpha implemetation,
in favor of similar functions in <linux/log2.h>.
Provide a more efficient version of the fls64 function
for pre-ev67 alphas.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-alpha/bitops.h')
-rw-r--r-- | include/asm-alpha/bitops.h | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/include/asm-alpha/bitops.h b/include/asm-alpha/bitops.h index 4b6ef7f21b93..3a0cbeb03fa1 100644 --- a/include/asm-alpha/bitops.h +++ b/include/asm-alpha/bitops.h | |||
@@ -313,32 +313,29 @@ static inline int ffs(int word) | |||
313 | * fls: find last bit set. | 313 | * fls: find last bit set. |
314 | */ | 314 | */ |
315 | #if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67) | 315 | #if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67) |
316 | static inline int fls(int word) | 316 | static inline int fls64(unsigned long word) |
317 | { | 317 | { |
318 | return 64 - __kernel_ctlz(word & 0xffffffff); | 318 | return 64 - __kernel_ctlz(word); |
319 | } | 319 | } |
320 | #else | 320 | #else |
321 | #include <asm-generic/bitops/fls.h> | 321 | extern const unsigned char __flsm1_tab[256]; |
322 | #endif | ||
323 | #include <asm-generic/bitops/fls64.h> | ||
324 | 322 | ||
325 | /* Compute powers of two for the given integer. */ | 323 | static inline int fls64(unsigned long x) |
326 | static inline long floor_log2(unsigned long word) | ||
327 | { | 324 | { |
328 | #if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67) | 325 | unsigned long t, a, r; |
329 | return 63 - __kernel_ctlz(word); | 326 | |
330 | #else | 327 | t = __kernel_cmpbge (x, 0x0101010101010101); |
331 | long bit; | 328 | a = __flsm1_tab[t]; |
332 | for (bit = -1; word ; bit++) | 329 | t = __kernel_extbl (x, a); |
333 | word >>= 1; | 330 | r = a*8 + __flsm1_tab[t] + (x != 0); |
334 | return bit; | 331 | |
335 | #endif | 332 | return r; |
336 | } | 333 | } |
334 | #endif | ||
337 | 335 | ||
338 | static inline long ceil_log2(unsigned long word) | 336 | static inline int fls(int x) |
339 | { | 337 | { |
340 | long bit = floor_log2(word); | 338 | return fls64((unsigned int) x); |
341 | return bit + (word > (1UL << bit)); | ||
342 | } | 339 | } |
343 | 340 | ||
344 | /* | 341 | /* |
@@ -353,9 +350,20 @@ static inline unsigned long hweight64(unsigned long w) | |||
353 | return __kernel_ctpop(w); | 350 | return __kernel_ctpop(w); |
354 | } | 351 | } |
355 | 352 | ||
356 | #define hweight32(x) (unsigned int) hweight64((x) & 0xfffffffful) | 353 | static inline unsigned int hweight32(unsigned int w) |
357 | #define hweight16(x) (unsigned int) hweight64((x) & 0xfffful) | 354 | { |
358 | #define hweight8(x) (unsigned int) hweight64((x) & 0xfful) | 355 | return hweight64(w); |
356 | } | ||
357 | |||
358 | static inline unsigned int hweight16(unsigned int w) | ||
359 | { | ||
360 | return hweight64(w & 0xffff); | ||
361 | } | ||
362 | |||
363 | static inline unsigned int hweight8(unsigned int w) | ||
364 | { | ||
365 | return hweight64(w & 0xff); | ||
366 | } | ||
359 | #else | 367 | #else |
360 | #include <asm-generic/bitops/hweight.h> | 368 | #include <asm-generic/bitops/hweight.h> |
361 | #endif | 369 | #endif |