Find the first bit set in bit string at or after bit start. */
| 195 | |
| 196 | /* Find the first bit set in bit string at or after bit start. */ |
| 197 | static inline void |
| 198 | bit_ffs_at(bitstr_t *_bitstr, int _start, int _nbits, int *_result) |
| 199 | { |
| 200 | bitstr_t *_curbitstr; |
| 201 | bitstr_t *_stopbitstr; |
| 202 | bitstr_t _test; |
| 203 | int _value, _offset; |
| 204 | |
| 205 | if (_start >= _nbits) { |
| 206 | *_result = -1; |
| 207 | return; |
| 208 | } |
| 209 | |
| 210 | if (_nbits > 0) { |
| 211 | _curbitstr = _bitstr + _bit_idx(_start); |
| 212 | _stopbitstr = _bitstr + _bit_idx(_nbits - 1); |
| 213 | |
| 214 | _test = *_curbitstr; |
| 215 | if (_bit_offset(_start) != 0) |
| 216 | _test &= _bit_make_mask(_start, _BITSTR_BITS - 1); |
| 217 | while (_test == 0 && _curbitstr < _stopbitstr) |
| 218 | _test = *(++_curbitstr); |
| 219 | |
| 220 | _offset = ffsl(_test); |
| 221 | _value = ((_curbitstr - _bitstr) * _BITSTR_BITS) + _offset - 1; |
| 222 | if (_offset == 0 || _value >= _nbits) |
| 223 | _value = -1; |
| 224 | } else { |
| 225 | _value = -1; |
| 226 | } |
| 227 | *_result = _value; |
| 228 | } |
| 229 | |
| 230 | /* Find the first bit clear in bit string at or after bit start. */ |
| 231 | static inline void |
no test coverage detected