mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-05 23:19:31 +03:00
Merge branch 'dev' into dev-win
This commit is contained in:
commit
d3224d0bba
2 changed files with 13 additions and 1 deletions
|
@ -53,8 +53,8 @@ terms of the MIT license. A copy of the license can be found in the file
|
||||||
#else
|
#else
|
||||||
#define mi_attr_alloc_size(s) __attribute__((alloc_size(s)))
|
#define mi_attr_alloc_size(s) __attribute__((alloc_size(s)))
|
||||||
#define mi_attr_alloc_size2(s1,s2) __attribute__((alloc_size(s1,s2)))
|
#define mi_attr_alloc_size2(s1,s2) __attribute__((alloc_size(s1,s2)))
|
||||||
#define mi_cdecl // leads to warnings... __attribute__((cdecl))
|
|
||||||
#endif
|
#endif
|
||||||
|
#define mi_cdecl // leads to warnings... __attribute__((cdecl))
|
||||||
#else
|
#else
|
||||||
#define mi_decl_thread __thread
|
#define mi_decl_thread __thread
|
||||||
#define mi_decl_export
|
#define mi_decl_export
|
||||||
|
|
12
src/os.c
12
src/os.c
|
@ -196,6 +196,18 @@ static bool mi_os_mem_free(void* addr, size_t size, mi_stats_t* stats)
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static void* mi_win_virtual_allocx(void* addr, size_t size, size_t try_alignment, DWORD flags) {
|
static void* mi_win_virtual_allocx(void* addr, size_t size, size_t try_alignment, DWORD flags) {
|
||||||
|
#if (MI_INTPTR_SIZE >= 8)
|
||||||
|
// on 64-bit systems, use the virtual address area after 4TiB for 4MiB aligned allocations
|
||||||
|
static volatile intptr_t aligned_base = ((intptr_t)4 << 40); // starting at 4TiB
|
||||||
|
if (addr == NULL && try_alignment > 0 &&
|
||||||
|
try_alignment <= MI_SEGMENT_SIZE && (size%MI_SEGMENT_SIZE) == 0)
|
||||||
|
{
|
||||||
|
intptr_t hint = mi_atomic_add(&aligned_base, size) - size;
|
||||||
|
if (hint%try_alignment == 0) {
|
||||||
|
return VirtualAlloc((void*)hint, size, flags, PAGE_READWRITE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#if defined(MEM_EXTENDED_PARAMETER_TYPE_BITS)
|
#if defined(MEM_EXTENDED_PARAMETER_TYPE_BITS)
|
||||||
// on modern Windows try use NtAllocateVirtualMemoryEx for 1GiB huge pages
|
// on modern Windows try use NtAllocateVirtualMemoryEx for 1GiB huge pages
|
||||||
if ((size % (uintptr_t)1 << 30) == 0 /* 1GiB multiple */
|
if ((size % (uintptr_t)1 << 30) == 0 /* 1GiB multiple */
|
||||||
|
|
Loading…
Add table
Reference in a new issue