… | |
… | |
145 | ecb_function_ int |
145 | ecb_function_ int |
146 | ecb_ctz32 (uint32_t x) |
146 | ecb_ctz32 (uint32_t x) |
147 | { |
147 | { |
148 | int r = 0; |
148 | int r = 0; |
149 | |
149 | |
150 | x &= (uint32_t)-(int32_t)x; /* this isolates the lowest bit */ |
150 | x &= ~x + 1; /* this isolates the lowest bit */ |
151 | |
151 | |
152 | if (x & 0xaaaaaaaa) r += 1; |
152 | if (x & 0xaaaaaaaa) r += 1; |
153 | if (x & 0xcccccccc) r += 2; |
153 | if (x & 0xcccccccc) r += 2; |
154 | if (x & 0xf0f0f0f0) r += 4; |
154 | if (x & 0xf0f0f0f0) r += 4; |
155 | if (x & 0xff00ff00) r += 8; |
155 | if (x & 0xff00ff00) r += 8; |