Lines Matching defs:bits
13 struct arena_bitmap __arena *bmp_alloc(size_t bits)
16 size_t size = BITS_TO_LONG_LONGS(bits) * sizeof(bmp->bits[0]);
19 if (bits % BITS_PER_LONG_LONG)
26 bmp_clear(bits, bmp);
45 old = bmp->bits[idx];
51 actual = cmpxchg(&bmp->bits[idx], old, new);
69 old = bmp->bits[idx];
75 actual = cmpxchg(&bmp->bits[idx], old, new);
93 old = bmp->bits[idx];
95 actual = cmpxchg(&bmp->bits[idx], old, new);
108 old = bmp->bits[idx];
110 actual = cmpxchg(&bmp->bits[idx], old, new);
116 void bmp_clear(size_t bits, struct arena_bitmap __arena *bmp)
118 size_t nwords = BITS_TO_LONG_LONGS(bits);
122 bmp->bits[i] = 0;
125 static __always_inline u64 bmp_last_word_mask(size_t bits)
127 u32 rem = bits % BITS_PER_LONG_LONG;
133 void bmp_and(size_t bits, struct arena_bitmap __arena *dst, struct arena_bitmap __arena *src1, struct arena_bitmap __arena *src2)
135 size_t nwords = BITS_TO_LONG_LONGS(bits);
139 dst->bits[i] = src1->bits[i] & src2->bits[i];
141 if (nwords && bits % BITS_PER_LONG_LONG)
142 dst->bits[nwords - 1] &= bmp_last_word_mask(bits);
146 void bmp_or(size_t bits, struct arena_bitmap __arena *dst, struct arena_bitmap __arena *src1, struct arena_bitmap __arena *src2)
148 size_t nwords = BITS_TO_LONG_LONGS(bits);
152 dst->bits[i] = src1->bits[i] | src2->bits[i];
154 if (nwords && bits % BITS_PER_LONG_LONG)
155 dst->bits[nwords - 1] &= bmp_last_word_mask(bits);
159 bool bmp_empty(size_t bits, struct arena_bitmap __arena *bmp)
161 size_t nwords = BITS_TO_LONG_LONGS(bits);
165 u64 mask = (i == nwords - 1) ? bmp_last_word_mask(bits) : ~0ULL;
167 if (bmp->bits[i] & mask)
175 void bmp_copy(size_t bits, struct arena_bitmap __arena *dst, struct arena_bitmap __arena *src)
177 size_t nwords = BITS_TO_LONG_LONGS(bits);
181 dst->bits[i] = src->bits[i];
183 if (nwords && bits % BITS_PER_LONG_LONG)
184 dst->bits[nwords - 1] &= bmp_last_word_mask(bits);
188 bool bmp_subset(size_t bits, struct arena_bitmap __arena *big, struct arena_bitmap __arena *small)
190 size_t nwords = BITS_TO_LONG_LONGS(bits);
194 u64 mask = (i == nwords - 1) ? bmp_last_word_mask(bits) : ~0ULL;
196 if (~big->bits[i] & small->bits[i] & mask)
204 bool bmp_intersects(size_t bits, struct arena_bitmap __arena *arg1, struct arena_bitmap __arena *arg2)
206 size_t nwords = BITS_TO_LONG_LONGS(bits);
210 u64 mask = (i == nwords - 1) ? bmp_last_word_mask(bits) : ~0ULL;
212 if (arg1->bits[i] & arg2->bits[i] & mask)
220 void bmp_print(size_t bits, struct arena_bitmap __arena *bmp)
222 size_t nwords = BITS_TO_LONG_LONGS(bits);
226 arena_stderr("%016llx ", bmp->bits[i]);