Home | History | Annotate | Download | only in utils

Lines Matching defs:bf

23 	struct bitfield *bf;
25 bf = os_zalloc(sizeof(*bf) + (max_bits + 7) / 8);
26 if (bf == NULL)
28 bf->bits = (u8 *) (bf + 1);
29 bf->max_bits = max_bits;
30 return bf;
34 void bitfield_free(struct bitfield *bf)
36 os_free(bf);
40 void bitfield_set(struct bitfield *bf, size_t bit)
42 if (bit >= bf->max_bits)
44 bf->bits[bit / 8] |= BIT(bit % 8);
48 void bitfield_clear(struct bitfield *bf, size_t bit)
50 if (bit >= bf->max_bits)
52 bf->bits[bit / 8] &= ~BIT(bit % 8);
56 int bitfield_is_set(struct bitfield *bf, size_t bit)
58 if (bit >= bf->max_bits)
60 return !!(bf->bits[bit / 8] & BIT(bit % 8));
76 int bitfield_get_first_zero(struct bitfield *bf)
79 for (i = 0; i <= (bf->max_bits + 7) / 8; i++) {
80 if (bf->bits[i] != 0xff)
83 if (i > (bf->max_bits + 7) / 8)
85 i = i * 8 + first_zero(bf->bits[i]);
86 if (i >= bf->max_bits)