mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-06 15:29:31 +03:00
merge from dev
This commit is contained in:
parent
78e2e580f8
commit
72a33c37ef
3 changed files with 4 additions and 4 deletions
|
@ -172,13 +172,13 @@ typedef int32_t mi_ssize_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Maximum slice offset (15)
|
// Maximum slice offset (15)
|
||||||
#define MI_MAX_SLICE_OFFSET ((MI_ALIGNED_MAX / MI_SEGMENT_SLICE_SIZE) - 1)
|
#define MI_MAX_SLICE_OFFSET ((MI_ALIGNMENT_MAX / MI_SEGMENT_SLICE_SIZE) - 1)
|
||||||
|
|
||||||
// Used as a special value to encode block sizes in 32 bits.
|
// Used as a special value to encode block sizes in 32 bits.
|
||||||
#define MI_HUGE_BLOCK_SIZE ((uint32_t)MI_HUGE_OBJ_SIZE_MAX)
|
#define MI_HUGE_BLOCK_SIZE ((uint32_t)MI_HUGE_OBJ_SIZE_MAX)
|
||||||
|
|
||||||
// blocks up to this size are always allocated aligned
|
// blocks up to this size are always allocated aligned
|
||||||
#define MI_MAX_ALIGN_GUARANTEE (8*MI_MAX_ALIGN_SIZE)
|
#define MI_MAX_ALIGN_GUARANTEE (8*MI_MAX_ALIGN_SIZE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -317,7 +317,7 @@ static uint8_t* _mi_segment_page_start_from_slice(const mi_segment_t* segment, c
|
||||||
size_t psize = (size_t)slice->slice_count * MI_SEGMENT_SLICE_SIZE;
|
size_t psize = (size_t)slice->slice_count * MI_SEGMENT_SLICE_SIZE;
|
||||||
// make the start not OS page aligned for smaller blocks to avoid page/cache effects
|
// make the start not OS page aligned for smaller blocks to avoid page/cache effects
|
||||||
size_t start_offset = (xblock_size >= MI_INTPTR_SIZE && xblock_size <= 1024 ? MI_MAX_ALIGN_GUARANTEE : 0);
|
size_t start_offset = (xblock_size >= MI_INTPTR_SIZE && xblock_size <= 1024 ? MI_MAX_ALIGN_GUARANTEE : 0);
|
||||||
if (page_size != NULL) *page_size = psize - start_offset;
|
if (page_size != NULL) { *page_size = psize - start_offset; }
|
||||||
return (uint8_t*)segment + ((idx*MI_SEGMENT_SLICE_SIZE) + start_offset);
|
return (uint8_t*)segment + ((idx*MI_SEGMENT_SLICE_SIZE) + start_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ int main(void) {
|
||||||
for (size_t align = 1; align <= MI_ALIGNMENT_MAX && ok; align *= 2) {
|
for (size_t align = 1; align <= MI_ALIGNMENT_MAX && ok; align *= 2) {
|
||||||
void* ps[8];
|
void* ps[8];
|
||||||
for (int i = 0; i < 8 && ok; i++) {
|
for (int i = 0; i < 8 && ok; i++) {
|
||||||
ps[i] = mi_malloc_aligned(align/2 /*size*/, align);
|
ps[i] = mi_malloc_aligned(align*13 /*size*/, align);
|
||||||
if (ps[i] == NULL || (uintptr_t)(ps[i]) % align != 0) {
|
if (ps[i] == NULL || (uintptr_t)(ps[i]) % align != 0) {
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue