120 |
/* Return bitset type name. */ |
/* Return bitset type name. */ |
121 |
extern const char *bitset_type_name_get PARAMS ((bitset)); |
extern const char *bitset_type_name_get PARAMS ((bitset)); |
122 |
|
|
|
#if BITSET_INLINE |
|
123 |
|
|
124 |
/* Set bit BITNO in bitset BSET. */ |
/* Set bit BITNO in bitset BSET. */ |
125 |
static inline void |
static inline void |
126 |
bitset_set (bitset bset, bitset_bindex bitno) |
bitset_set (bitset bset, bitset_bindex bitno) |
127 |
{ |
{ |
128 |
bitset_windex index = bitno / BITSET_WORD_BITS; |
bitset_windex windex = bitno / BITSET_WORD_BITS; |
129 |
bitset_windex offset = index - bset->b.cindex; |
bitset_windex offset = windex - bset->b.cindex; |
130 |
|
|
131 |
if (offset < bset->b.csize) |
if (offset < bset->b.csize) |
132 |
bset->b.cdata[offset] |= ((bitset_word) 1 << (bitno % BITSET_WORD_BITS)); |
bset->b.cdata[offset] |= ((bitset_word) 1 << (bitno % BITSET_WORD_BITS)); |
139 |
static inline void |
static inline void |
140 |
bitset_reset (bitset bset, bitset_bindex bitno) |
bitset_reset (bitset bset, bitset_bindex bitno) |
141 |
{ |
{ |
142 |
bitset_windex index = bitno / BITSET_WORD_BITS; |
bitset_windex windex = bitno / BITSET_WORD_BITS; |
143 |
bitset_windex offset = index - bset->b.cindex; |
bitset_windex offset = windex - bset->b.cindex; |
144 |
|
|
145 |
if (offset < bset->b.csize) |
if (offset < bset->b.csize) |
146 |
bset->b.cdata[offset] &= ~((bitset_word) 1 << (bitno % BITSET_WORD_BITS)); |
bset->b.cdata[offset] &= ~((bitset_word) 1 << (bitno % BITSET_WORD_BITS)); |
153 |
static inline int |
static inline int |
154 |
bitset_test (bitset bset, bitset_bindex bitno) |
bitset_test (bitset bset, bitset_bindex bitno) |
155 |
{ |
{ |
156 |
bitset_windex index = bitno / BITSET_WORD_BITS; |
bitset_windex windex = bitno / BITSET_WORD_BITS; |
157 |
bitset_windex offset = index - bset->b.cindex; |
bitset_windex offset = windex - bset->b.cindex; |
158 |
|
|
159 |
if (offset < bset->b.csize) |
if (offset < bset->b.csize) |
160 |
return (bset->b.cdata[offset] >> (bitno % BITSET_WORD_BITS)) & 1; |
return (bset->b.cdata[offset] >> (bitno % BITSET_WORD_BITS)) & 1; |
161 |
else |
else |
162 |
return BITSET_TEST_ (bset, bitno); |
return BITSET_TEST_ (bset, bitno); |
163 |
} |
} |
|
#endif |
|
|
|
|
|
#if ! BITSET_INLINE |
|
|
|
|
|
/* Set bit BITNO in bitset BSET. */ |
|
|
#define bitset_set(bset, bitno) \ |
|
|
do \ |
|
|
{ \ |
|
|
bitset_bindex _bitno = (bitno); \ |
|
|
bitset_windex _index = _bitno / BITSET_WORD_BITS; \ |
|
|
bitset_windex _offset = _index - (bset)->b.cindex; \ |
|
|
\ |
|
|
if (_offset < (bset)->b.csize) \ |
|
|
(bset)->b.cdata[_offset] |= \ |
|
|
((bitset_word) 1 << (_bitno % BITSET_WORD_BITS)); \ |
|
|
else \ |
|
|
BITSET_SET_ ((bset), _bitno); \ |
|
|
} while (0) |
|
|
|
|
|
|
|
|
/* Reset bit BITNO in bitset BSET. */ |
|
|
#define bitset_reset(bset, bitno) \ |
|
|
do \ |
|
|
{ \ |
|
|
bitset_bindex _bitno = (bitno); \ |
|
|
bitset_windex _index = _bitno / BITSET_WORD_BITS; \ |
|
|
bitset_windex _offset = _index - (bset)->b.cindex; \ |
|
|
\ |
|
|
if (_offset < (bset)->b.csize) \ |
|
|
(bset)->b.cdata[_offset] &= \ |
|
|
~((bitset_word) 1 << (_bitno % BITSET_WORD_BITS)); \ |
|
|
else \ |
|
|
BITSET_RESET_ ((bset), _bitno); \ |
|
|
} while (0) |
|
|
|
|
|
|
|
|
/* Test bit BITNO in bitset BSET. */ |
|
|
#define bitset_test(bset, bitno) \ |
|
|
(((((bitno) / BITSET_WORD_BITS) - (bset)->b.cindex) < (bset)->b.csize) \ |
|
|
? ((bset)->b.cdata[(((bitno) / BITSET_WORD_BITS) - (bset)->b.cindex)] \ |
|
|
>> ((bitno) % BITSET_WORD_BITS)) & 1 \ |
|
|
: (unsigned int) BITSET_TEST_ ((bset), (bitno))) |
|
|
#endif |
|
164 |
|
|
165 |
|
|
166 |
/* Toggle bit BITNO in bitset BSET and return non-zero if now set. */ |
/* Toggle bit BITNO in bitset BSET and return non-zero if now set. */ |