commit | f3241115e7195925a30e41e363536b24111c0cc8 | [log] [tgz] |
---|---|---|
author | Willy Tarreau <w@1wt.eu> | Tue Feb 26 09:56:22 2019 +0100 |
committer | Willy Tarreau <w@1wt.eu> | Wed Feb 27 14:27:07 2019 +0100 |
tree | dc84df13774225c621f7cd5fc5696d093ce8642b | |
parent | 9e85318417773a9ad01b8405415b8086096f20eb [diff] |
MINOR: tools: implement functions to look up the nth bit set in a mask Function mask_find_rank_bit() returns the bit position in mask <m> of the nth bit set of rank <r>, between 0 and LONGBITS-1 included, starting from the left. For example ranks 0,1,2,3 for mask 0x55 will be 6, 4, 2 and 0 respectively. This algorithm is based on a popcount variant and is described here : https://graphics.stanford.edu/~seander/bithacks.html.