use size_t for bitmask

This commit is contained in:
daan 2021-11-13 15:29:57 -08:00
parent 83ffd92b2b
commit f1ce9228a1
2 changed files with 12 additions and 12 deletions

View File

@ -307,9 +307,9 @@ typedef enum mi_segment_kind_e {
MI_SEGMENT_HUGE, // > MI_LARGE_SIZE_MAX segment with just one huge page inside.
} mi_segment_kind_t;
#define MI_COMMIT_SIZE (MI_SEGMENT_SIZE/MI_INTPTR_BITS)
#define MI_COMMIT_SIZE (MI_SEGMENT_SIZE/MI_SIZE_BITS)
#if (((1 << MI_SEGMENT_SHIFT)/MI_COMMIT_SIZE) > 8*MI_INTPTR_SIZE)
#if (((1 << MI_SEGMENT_SHIFT)/MI_COMMIT_SIZE) > MI_SIZE_BITS)
#error "not enough commit bits to cover the segment size"
#endif
@ -317,7 +317,7 @@ typedef mi_page_t mi_slice_t;
typedef int64_t mi_msecs_t;
typedef uintptr_t mi_commit_mask_t;
typedef size_t mi_commit_mask_t;
// Segments are large allocated memory blocks (8mb on 64 bit) from
// the OS. Inside segments we allocated fixed size _pages_ that

View File

@ -336,9 +336,9 @@ static mi_commit_mask_t mi_segment_commit_mask(mi_segment_t* segment, bool conse
if (size == 0 || size > MI_SEGMENT_SIZE) return 0;
if (p >= (uint8_t*)segment + mi_segment_size(segment)) return 0;
uintptr_t diff = (p - (uint8_t*)segment);
uintptr_t start;
uintptr_t end;
size_t diff = (p - (uint8_t*)segment);
size_t start;
size_t end;
if (conservative) {
start = _mi_align_up(diff, MI_COMMIT_SIZE);
end = _mi_align_down(diff + size, MI_COMMIT_SIZE);
@ -353,14 +353,14 @@ static mi_commit_mask_t mi_segment_commit_mask(mi_segment_t* segment, bool conse
*full_size = (end > start ? end - start : 0);
if (*full_size == 0) return 0;
uintptr_t bitidx = start / MI_COMMIT_SIZE;
mi_assert_internal(bitidx < (MI_INTPTR_SIZE*8));
size_t bitidx = start / MI_COMMIT_SIZE;
mi_assert_internal(bitidx < MI_COMMIT_MASK_BITS);
uintptr_t bitcount = *full_size / MI_COMMIT_SIZE; // can be 0
size_t bitcount = *full_size / MI_COMMIT_SIZE; // can be 0
if (bitidx + bitcount > MI_INTPTR_SIZE*8) {
_mi_warning_message("commit mask overflow: %zu %zu %zu %zu 0x%p %zu\n", bitidx, bitcount, start, end, p, size);
}
mi_assert_internal((bitidx + bitcount) <= (MI_INTPTR_SIZE*8));
mi_assert_internal((bitidx + bitcount) <= MI_COMMIT_MASK_BITS);
return mi_commit_mask_create(bitidx, bitcount);
}
@ -443,8 +443,8 @@ static void mi_segment_delayed_decommit(mi_segment_t* segment, bool force, mi_st
segment->decommit_expire = 0;
segment->decommit_mask = mi_commit_mask_empty();
uintptr_t idx;
uintptr_t count;
size_t idx;
size_t count;
mi_commit_mask_foreach(mask, idx, count) {
// if found, decommit that sequence
if (count > 0) {