Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/bitstring.h
Show First 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | |||||
static inline void | static inline void | ||||
bit_ffs_at(bitstr_t *_bitstr, int _start, int _nbits, int *_result) | bit_ffs_at(bitstr_t *_bitstr, int _start, int _nbits, int *_result) | ||||
{ | { | ||||
bitstr_t *_curbitstr; | bitstr_t *_curbitstr; | ||||
bitstr_t *_stopbitstr; | bitstr_t *_stopbitstr; | ||||
bitstr_t _test; | bitstr_t _test; | ||||
int _value, _offset; | int _value, _offset; | ||||
if (_start >= _nbits) { | |||||
_result = -1; | |||||
return; | |||||
} | |||||
if (_nbits > 0) { | if (_nbits > 0) { | ||||
_curbitstr = _bitstr + _bit_idx(_start); | _curbitstr = _bitstr + _bit_idx(_start); | ||||
_stopbitstr = _bitstr + _bit_idx(_nbits - 1); | _stopbitstr = _bitstr + _bit_idx(_nbits - 1); | ||||
_test = *_curbitstr; | _test = *_curbitstr; | ||||
if (_bit_offset(_start) != 0) | if (_bit_offset(_start) != 0) | ||||
_test &= _bit_make_mask(_start, _BITSTR_BITS - 1); | _test &= _bit_make_mask(_start, _BITSTR_BITS - 1); | ||||
while (_test == 0 && _curbitstr < _stopbitstr) | while (_test == 0 && _curbitstr < _stopbitstr) | ||||
Show All 12 Lines | |||||
/* Find the first bit clear in bit string at or after bit start. */ | /* Find the first bit clear in bit string at or after bit start. */ | ||||
static inline void | static inline void | ||||
bit_ffc_at(bitstr_t *_bitstr, int _start, int _nbits, int *_result) | bit_ffc_at(bitstr_t *_bitstr, int _start, int _nbits, int *_result) | ||||
{ | { | ||||
bitstr_t *_curbitstr; | bitstr_t *_curbitstr; | ||||
bitstr_t *_stopbitstr; | bitstr_t *_stopbitstr; | ||||
bitstr_t _test; | bitstr_t _test; | ||||
int _value, _offset; | int _value, _offset; | ||||
if (_start >= _nbits) { | |||||
_result = -1; | |||||
return; | |||||
} | |||||
if (_nbits > 0) { | if (_nbits > 0) { | ||||
_curbitstr = _bitstr + _bit_idx(_start); | _curbitstr = _bitstr + _bit_idx(_start); | ||||
_stopbitstr = _bitstr + _bit_idx(_nbits - 1); | _stopbitstr = _bitstr + _bit_idx(_nbits - 1); | ||||
_test = *_curbitstr; | _test = *_curbitstr; | ||||
if (_bit_offset(_start) != 0) | if (_bit_offset(_start) != 0) | ||||
_test |= _bit_make_mask(0, _start - 1); | _test |= _bit_make_mask(0, _start - 1); | ||||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |