Lines Matching defs:b
37 bitset_init(bitset_t *b)
39 bzero(b, sizeof (bitset_t));
47 bitset_init_fanout(bitset_t *b, uint_t fanout)
49 bzero(b, sizeof (bitset_t));
50 b->bs_fanout = fanout;
58 bitset_fini(bitset_t *b)
60 if (b->bs_words > 0)
61 kmem_free(b->bs_set, b->bs_words * sizeof (ulong_t));
71 bitset_resize(bitset_t *b, uint_t els)
76 nwords = BT_BITOUL(els << b->bs_fanout);
77 if (b->bs_words == nwords)
86 if (b->bs_words > 0)
87 bcopy(b->bs_set, bset_new,
88 MIN(b->bs_words, nwords) * sizeof (ulong_t));
94 bset_tmp = b->bs_set;
95 b->bs_set = bset_new;
98 if (b->bs_words > 0)
99 kmem_free(bset_tmp, b->bs_words * sizeof (ulong_t));
101 b->bs_words = nwords;
108 bitset_capacity(bitset_t *b)
110 return (b->bs_words * BT_NBIPUL);
123 bitset_add(bitset_t *b, uint_t elt)
125 uint_t pos = (elt << b->bs_fanout);
127 ASSERT(b->bs_words * BT_NBIPUL > pos);
128 BT_SET(b->bs_set, pos);
135 bitset_atomic_add(bitset_t *b, uint_t elt)
137 uint_t pos = (elt << b->bs_fanout);
139 ASSERT(b->bs_words * BT_NBIPUL > pos);
140 BT_ATOMIC_SET(b->bs_set, pos);
148 bitset_atomic_test_and_add(bitset_t *b, uint_t elt)
150 uint_t pos = (elt << b->bs_fanout);
153 ASSERT(b->bs_words * BT_NBIPUL > pos);
154 BT_ATOMIC_SET_EXCL(b->bs_set, pos, ret);
163 bitset_del(bitset_t *b, uint_t elt)
165 uint_t pos = (elt << b->bs_fanout);
167 ASSERT(b->bs_words * BT_NBIPUL > pos);
168 BT_CLEAR(b->bs_set, pos);
175 bitset_atomic_del(bitset_t *b, uint_t elt)
177 uint_t pos = (elt << b->bs_fanout);
179 ASSERT(b->bs_words * BT_NBIPUL > pos);
180 BT_ATOMIC_CLEAR(b->bs_set, pos);
188 bitset_atomic_test_and_del(bitset_t *b, uint_t elt)
190 uint_t pos = (elt << b->bs_fanout);
193 ASSERT(b->bs_words * BT_NBIPUL > pos);
194 BT_ATOMIC_CLEAR_EXCL(b->bs_set, pos, ret);
203 bitset_in_set(bitset_t *b, uint_t elt)
205 uint_t pos = (elt << b->bs_fanout);
207 if (pos >= b->bs_words * BT_NBIPUL)
210 return (BT_TEST(b->bs_set, pos));
217 bitset_is_null(bitset_t *b)
221 for (i = 0; i < b->bs_words; i++)
222 if (b->bs_set[i] != 0)
256 bitset_find(bitset_t *b)
264 ASSERT(b->bs_words > 0);
265 start = seed % b->bs_words;
269 elt = bitset_find_in_word(b->bs_set[i], seed);
272 return (elt >> b->bs_fanout);
274 if (++i == b->bs_words)
351 bitset_zero(bitset_t *b)
353 bzero(b->bs_set, sizeof (ulong_t) * b->bs_words);