MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / _mi_bitmap_claim

Function _mi_bitmap_claim

3rd/mimalloc-2.0.9/src/bitmap.c:153–162  ·  view source on GitHub ↗

Set `count` bits at `bitmap_idx` to 1 atomically Returns `true` if all `count` bits were 0 previously. `any_zero` is `true` if there was at least one zero bit.

Source from the content-addressed store, hash-verified

151// Set `count` bits at `bitmap_idx` to 1 atomically
152// Returns `true` if all `count` bits were 0 previously. `any_zero` is `true` if there was at least one zero bit.
153bool _mi_bitmap_claim(mi_bitmap_t bitmap, size_t bitmap_fields, size_t count, mi_bitmap_index_t bitmap_idx, bool* any_zero) {
154 const size_t idx = mi_bitmap_index_field(bitmap_idx);
155 const size_t bitidx = mi_bitmap_index_bit_in_field(bitmap_idx);
156 const size_t mask = mi_bitmap_mask_(count, bitidx);
157 mi_assert_internal(bitmap_fields > idx); MI_UNUSED(bitmap_fields);
158 //mi_assert_internal(any_zero != NULL || (bitmap[idx] & mask) == 0);
159 size_t prev = mi_atomic_or_acq_rel(&bitmap[idx], mask);
160 if (any_zero != NULL) *any_zero = ((prev & mask) != mask);
161 return ((prev & mask) == 0);
162}
163
164// Returns `true` if all `count` bits were 1. `any_ones` is `true` if there was at least one bit set to one.
165static bool mi_bitmap_is_claimedx(mi_bitmap_t bitmap, size_t bitmap_fields, size_t count, mi_bitmap_index_t bitmap_idx, bool* any_ones) {

Callers 5

mi_segment_cache_purgeFunction · 0.85
mi_region_try_alloc_osFunction · 0.85
mi_region_try_allocFunction · 0.85
_mi_mem_freeFunction · 0.85
mi_manage_os_memory_exFunction · 0.85

Calls 3

mi_bitmap_index_fieldFunction · 0.85
mi_bitmap_mask_Function · 0.85

Tested by

no test coverage detected