diff options
| author | Jeff Garzik <jgarzik@pobox.com> | 2005-11-18 19:42:40 +0300 |
|---|---|---|
| committer | Jeff Garzik <jgarzik@pobox.com> | 2005-11-18 19:42:40 +0300 |
| commit | 85a07029aaba8f5b27241bcff56cc009c9f4993b (patch) | |
| tree | c579554c2ea9c942ccbea60e223bc62d8262f652 /include/linux/bitops.h | |
| parent | 0da36b3467040908d3df6bc1f5b4d592a8b23b63 (diff) | |
| parent | 79bfb0a98fdc73ed6a18469cef245cbf50a1d8bb (diff) | |
| download | linux-85a07029aaba8f5b27241bcff56cc009c9f4993b.tar.xz | |
Merge branch 'upstream'
Diffstat (limited to 'include/linux/bitops.h')
| -rw-r--r-- | include/linux/bitops.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index cb3c3ef50f50..38c2fb7ebe09 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -84,6 +84,16 @@ static __inline__ int get_bitmask_order(unsigned int count) return order; /* We could be slightly more clever with -1 here... */ } +static __inline__ int get_count_order(unsigned int count) +{ + int order; + + order = fls(count) - 1; + if (count & (count - 1)) + order++; + return order; +} + /* * hweightN: returns the hamming weight (i.e. the number * of bits set) of a N-bit word |
