X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=include%2Fasm-alpha%2Fbitops.h;h=9e71201000d58eb8943650bc14c938aca1850513;hb=347c53dca73fca317d57781f510f5ff4f6c0d0d7;hp=3f88715e811eaa10e5f9c4395131fa22f6f6545f;hpb=ca9ba4471c1203bb6e759b76e83167fec54fe590;p=powerpc.git diff --git a/include/asm-alpha/bitops.h b/include/asm-alpha/bitops.h index 3f88715e81..9e71201000 100644 --- a/include/asm-alpha/bitops.h +++ b/include/asm-alpha/bitops.h @@ -1,7 +1,6 @@ #ifndef _ALPHA_BITOPS_H #define _ALPHA_BITOPS_H -#include #include /* @@ -314,32 +313,29 @@ static inline int ffs(int word) * fls: find last bit set. */ #if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67) -static inline int fls(int word) +static inline int fls64(unsigned long word) { - return 64 - __kernel_ctlz(word & 0xffffffff); + return 64 - __kernel_ctlz(word); } #else -#include -#endif -#include +extern const unsigned char __flsm1_tab[256]; -/* Compute powers of two for the given integer. */ -static inline long floor_log2(unsigned long word) +static inline int fls64(unsigned long x) { -#if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67) - return 63 - __kernel_ctlz(word); -#else - long bit; - for (bit = -1; word ; bit++) - word >>= 1; - return bit; -#endif + unsigned long t, a, r; + + t = __kernel_cmpbge (x, 0x0101010101010101UL); + a = __flsm1_tab[t]; + t = __kernel_extbl (x, a); + r = a*8 + __flsm1_tab[t] + (x != 0); + + return r; } +#endif -static inline long ceil_log2(unsigned long word) +static inline int fls(int x) { - long bit = floor_log2(word); - return bit + (word > (1UL << bit)); + return fls64((unsigned int) x); } /* @@ -354,9 +350,20 @@ static inline unsigned long hweight64(unsigned long w) return __kernel_ctpop(w); } -#define hweight32(x) (unsigned int) hweight64((x) & 0xfffffffful) -#define hweight16(x) (unsigned int) hweight64((x) & 0xfffful) -#define hweight8(x) (unsigned int) hweight64((x) & 0xfful) +static inline unsigned int hweight32(unsigned int w) +{ + return hweight64(w); +} + +static inline unsigned int hweight16(unsigned int w) +{ + return hweight64(w & 0xffff); +} + +static inline unsigned int hweight8(unsigned int w) +{ + return hweight64(w & 0xff); +} #else #include #endif