MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / include / linux / bitops.h
blob5d1eabcde5d5f273e6b3e9450c23e0861f69c84c
1 #ifndef _LINUX_BITOPS_H
2 #define _LINUX_BITOPS_H
3 #include <asm/types.h>
5 /*
6 * Include this here because some architectures need generic_ffs/fls in
7 * scope
8 */
9 #include <asm/bitops.h>
11 static __inline__ int get_bitmask_order(unsigned int count)
13 int order;
15 order = fls(count);
16 return order; /* We could be slightly more clever with -1 here... */
19 static __inline__ int get_count_order(unsigned int count)
21 int order;
23 order = fls(count) - 1;
24 if (count & (count - 1))
25 order++;
26 return order;
29 static inline unsigned long hweight_long(unsigned long w)
31 return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
35 * rol32 - rotate a 32-bit value left
37 * @word: value to rotate
38 * @shift: bits to roll
40 static inline __u32 rol32(__u32 word, unsigned int shift)
42 return (word << shift) | (word >> (32 - shift));
46 * ror32 - rotate a 32-bit value right
48 * @word: value to rotate
49 * @shift: bits to roll
51 static inline __u32 ror32(__u32 word, unsigned int shift)
53 return (word >> shift) | (word << (32 - shift));
56 static inline unsigned fls_long(unsigned long l)
58 if (sizeof(l) == 4)
59 return fls(l);
60 return fls64(l);
63 #endif