diff options
Diffstat (limited to 'common/util.c')
| -rw-r--r-- | common/util.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/common/util.c b/common/util.c index 644301fe8..9d8fb9321 100644 --- a/common/util.c +++ b/common/util.c | |||
| @@ -22,7 +22,7 @@ uint8_t bitpop(uint8_t bits) | |||
| 22 | { | 22 | { |
| 23 | uint8_t c; | 23 | uint8_t c; |
| 24 | for (c = 0; bits; c++) | 24 | for (c = 0; bits; c++) |
| 25 | bits &= bits -1; | 25 | bits &= bits - 1; |
| 26 | return c; | 26 | return c; |
| 27 | /* | 27 | /* |
| 28 | const uint8_t bit_count[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; | 28 | const uint8_t bit_count[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; |
| @@ -30,6 +30,14 @@ uint8_t bitpop(uint8_t bits) | |||
| 30 | */ | 30 | */ |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | uint8_t bitpop16(uint16_t bits) | ||
| 34 | { | ||
| 35 | uint8_t c; | ||
| 36 | for (c = 0; bits; c++) | ||
| 37 | bits &= bits - 1; | ||
| 38 | return c; | ||
| 39 | } | ||
| 40 | |||
| 33 | // most significant on-bit - return highest location of on-bit | 41 | // most significant on-bit - return highest location of on-bit |
| 34 | uint8_t biton(uint8_t bits) | 42 | uint8_t biton(uint8_t bits) |
| 35 | { | 43 | { |
