aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/bitops.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/bitops.h')
-rw-r--r--include/linux/bitops.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index c05a29cb9bb2..fc68053378ce 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -10,22 +10,26 @@
10#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) 10#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
11#endif 11#endif
12 12
13extern unsigned int __sw_hweight8(unsigned int w);
14extern unsigned int __sw_hweight16(unsigned int w);
15extern unsigned int __sw_hweight32(unsigned int w);
16extern unsigned long __sw_hweight64(__u64 w);
17
13/* 18/*
14 * Include this here because some architectures need generic_ffs/fls in 19 * Include this here because some architectures need generic_ffs/fls in
15 * scope 20 * scope
16 */ 21 */
17#include <asm/bitops.h> 22#include <asm/bitops.h>
18 23
19#define for_each_bit(bit, addr, size) \ 24#define for_each_set_bit(bit, addr, size) \
20 for ((bit) = find_first_bit((addr), (size)); \ 25 for ((bit) = find_first_bit((addr), (size)); \
21 (bit) < (size); \ 26 (bit) < (size); \
22 (bit) = find_next_bit((addr), (size), (bit) + 1)) 27 (bit) = find_next_bit((addr), (size), (bit) + 1))
23 28
24
25static __inline__ int get_bitmask_order(unsigned int count) 29static __inline__ int get_bitmask_order(unsigned int count)
26{ 30{
27 int order; 31 int order;
28 32
29 order = fls(count); 33 order = fls(count);
30 return order; /* We could be slightly more clever with -1 here... */ 34 return order; /* We could be slightly more clever with -1 here... */
31} 35}
@@ -33,7 +37,7 @@ static __inline__ int get_bitmask_order(unsigned int count)
33static __inline__ int get_count_order(unsigned int count) 37static __inline__ int get_count_order(unsigned int count)
34{ 38{
35 int order; 39 int order;
36 40
37 order = fls(count) - 1; 41 order = fls(count) - 1;
38 if (count & (count - 1)) 42 if (count & (count - 1))
39 order++; 43 order++;