diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-11-15 20:56:07 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-11-15 20:56:07 -0500 |
commit | 77ed78e5cf32be1c3fae5c477cc1d78e2e3f17db (patch) | |
tree | 805db8c5c180ee7ee85b3c484461100c91f6c781 /include/linux/bitops.h | |
parent | 68bdbdf0b32566e1ebd41415bde9a7c43b47bf48 (diff) | |
parent | f6ff56cd56b83d8edf4b3cffc5c53c56b37a5081 (diff) | |
download | blackbird-op-linux-77ed78e5cf32be1c3fae5c477cc1d78e2e3f17db.tar.gz blackbird-op-linux-77ed78e5cf32be1c3fae5c477cc1d78e2e3f17db.zip |
Merge branch 'master'
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 |