mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-06 23:39:31 +03:00
Merge branch 'dev' into dev2
This commit is contained in:
commit
65a89854d1
2 changed files with 18 additions and 8 deletions
|
@ -425,7 +425,9 @@ endif()
|
||||||
|
|
||||||
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU|Intel" AND NOT CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU|Intel" AND NOT CMAKE_SYSTEM_NAME MATCHES "Haiku")
|
||||||
if(MI_OPT_ARCH)
|
if(MI_OPT_ARCH)
|
||||||
if(MI_ARCH STREQUAL "arm64")
|
if(APPLE AND CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND "arm64" IN_LIST CMAKE_OSX_ARCHITECTURES) # to support multi-arch binaries (#999)
|
||||||
|
set(MI_OPT_ARCH_FLAGS "-Xarch_arm64" "-march=armv8.1-a")
|
||||||
|
elseif(MI_ARCH STREQUAL "arm64")
|
||||||
set(MI_OPT_ARCH_FLAGS "-march=armv8.1-a") # fast atomics
|
set(MI_OPT_ARCH_FLAGS "-march=armv8.1-a") # fast atomics
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -62,6 +62,9 @@ static PGetNumaProcessorNodeEx pGetNumaProcessorNodeEx = NULL;
|
||||||
static PGetNumaNodeProcessorMaskEx pGetNumaNodeProcessorMaskEx = NULL;
|
static PGetNumaNodeProcessorMaskEx pGetNumaNodeProcessorMaskEx = NULL;
|
||||||
static PGetNumaProcessorNode pGetNumaProcessorNode = NULL;
|
static PGetNumaProcessorNode pGetNumaProcessorNode = NULL;
|
||||||
|
|
||||||
|
// Available after Windows XP
|
||||||
|
typedef BOOL (__stdcall *PGetPhysicallyInstalledSystemMemory)( PULONGLONG TotalMemoryInKilobytes );
|
||||||
|
|
||||||
//---------------------------------------------
|
//---------------------------------------------
|
||||||
// Enable large page support dynamically (if possible)
|
// Enable large page support dynamically (if possible)
|
||||||
//---------------------------------------------
|
//---------------------------------------------
|
||||||
|
@ -123,13 +126,7 @@ void _mi_prim_mem_init( mi_os_mem_config_t* config )
|
||||||
const size_t vbits = MI_INTPTR_BITS - mi_clz((uintptr_t)si.lpMaximumApplicationAddress);
|
const size_t vbits = MI_INTPTR_BITS - mi_clz((uintptr_t)si.lpMaximumApplicationAddress);
|
||||||
config->virtual_address_bits = vbits;
|
config->virtual_address_bits = vbits;
|
||||||
}
|
}
|
||||||
// get physical memory
|
|
||||||
ULONGLONG memInKiB = 0;
|
|
||||||
if (GetPhysicallyInstalledSystemMemory(&memInKiB)) {
|
|
||||||
if (memInKiB > 0 && memInKiB < (SIZE_MAX / MI_KiB)) {
|
|
||||||
config->physical_memory = (size_t)memInKiB * MI_KiB;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// get the VirtualAlloc2 function
|
// get the VirtualAlloc2 function
|
||||||
HINSTANCE hDll;
|
HINSTANCE hDll;
|
||||||
hDll = LoadLibrary(TEXT("kernelbase.dll"));
|
hDll = LoadLibrary(TEXT("kernelbase.dll"));
|
||||||
|
@ -152,8 +149,19 @@ void _mi_prim_mem_init( mi_os_mem_config_t* config )
|
||||||
pGetNumaProcessorNodeEx = (PGetNumaProcessorNodeEx)(void (*)(void))GetProcAddress(hDll, "GetNumaProcessorNodeEx");
|
pGetNumaProcessorNodeEx = (PGetNumaProcessorNodeEx)(void (*)(void))GetProcAddress(hDll, "GetNumaProcessorNodeEx");
|
||||||
pGetNumaNodeProcessorMaskEx = (PGetNumaNodeProcessorMaskEx)(void (*)(void))GetProcAddress(hDll, "GetNumaNodeProcessorMaskEx");
|
pGetNumaNodeProcessorMaskEx = (PGetNumaNodeProcessorMaskEx)(void (*)(void))GetProcAddress(hDll, "GetNumaNodeProcessorMaskEx");
|
||||||
pGetNumaProcessorNode = (PGetNumaProcessorNode)(void (*)(void))GetProcAddress(hDll, "GetNumaProcessorNode");
|
pGetNumaProcessorNode = (PGetNumaProcessorNode)(void (*)(void))GetProcAddress(hDll, "GetNumaProcessorNode");
|
||||||
|
// Get physical memory (not available on XP, so check dynamically)
|
||||||
|
PGetPhysicallyInstalledSystemMemory pGetPhysicallyInstalledSystemMemory = (PGetPhysicallyInstalledSystemMemory)(void (*)(void))GetProcAddress(hDll,"GetPhysicallyInstalledSystemMemory");
|
||||||
|
if (pGetPhysicallyInstalledSystemMemory != NULL) {
|
||||||
|
ULONGLONG memInKiB = 0;
|
||||||
|
if ((*pGetPhysicallyInstalledSystemMemory)(&memInKiB)) {
|
||||||
|
if (memInKiB > 0 && memInKiB < (SIZE_MAX / MI_KiB)) {
|
||||||
|
config->physical_memory = (size_t)memInKiB * MI_KiB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
FreeLibrary(hDll);
|
FreeLibrary(hDll);
|
||||||
}
|
}
|
||||||
|
// Enable large/huge OS page support?
|
||||||
if (mi_option_is_enabled(mi_option_allow_large_os_pages) || mi_option_is_enabled(mi_option_reserve_huge_os_pages)) {
|
if (mi_option_is_enabled(mi_option_allow_large_os_pages) || mi_option_is_enabled(mi_option_reserve_huge_os_pages)) {
|
||||||
win_enable_large_os_pages(&config->large_page_size);
|
win_enable_large_os_pages(&config->large_page_size);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue