diff options
Diffstat (limited to 'include/my_bit.h')
-rw-r--r-- | include/my_bit.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/my_bit.h b/include/my_bit.h index 174e0f70083..a50403c312d 100644 --- a/include/my_bit.h +++ b/include/my_bit.h @@ -121,6 +121,15 @@ static inline uint32 my_reverse_bits(uint32 key) _my_bits_reverse_table[(key>>24) ]; } +/* + a number with the n lowest bits set + an overflow-safe version of (1 << n) - 1 +*/ +static inline uint32 my_set_bits(int n) +{ + return (((1UL << (n - 1)) - 1) << 1) | 1; +} + C_MODE_END #endif /* MY_BIT_INCLUDED */ |