mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-06 23:39:31 +03:00
fix build on windows
This commit is contained in:
parent
4377abe017
commit
f971bd6d74
2 changed files with 5 additions and 4 deletions
|
@ -45,6 +45,7 @@ terms of the MIT license. A copy of the license can be found in the file
|
||||||
}
|
}
|
||||||
#elif defined(__cplusplus)
|
#elif defined(__cplusplus)
|
||||||
// C++: use static initialization to detect process start
|
// C++: use static initialization to detect process start
|
||||||
|
extern mi_heap_t _mi_heap_main;
|
||||||
static bool mi_process_attach(void) {
|
static bool mi_process_attach(void) {
|
||||||
_mi_process_load();
|
_mi_process_load();
|
||||||
atexit(&_mi_process_done);
|
atexit(&_mi_process_done);
|
||||||
|
|
|
@ -623,11 +623,11 @@ static void NTAPI mi_win_main(PVOID module, DWORD reason, LPVOID reserved) {
|
||||||
|
|
||||||
|
|
||||||
#if defined(MI_SHARED_LIB)
|
#if defined(MI_SHARED_LIB)
|
||||||
#define MI_PRIM_HAS_PROCESS_INIT 1
|
#define MI_PRIM_HAS_PROCESS_ATTACH 1
|
||||||
|
|
||||||
// Windows DLL: easy to hook into process_init and thread_done
|
// Windows DLL: easy to hook into process_init and thread_done
|
||||||
__declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) {
|
__declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) {
|
||||||
win_main((PVOID)inst,reason,reserved);
|
mi_win_main((PVOID)inst,reason,reserved);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,7 +639,7 @@ static void NTAPI mi_win_main(PVOID module, DWORD reason, LPVOID reserved) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif !defined(MI_WIN_USE_FLS)
|
#elif !defined(MI_WIN_USE_FLS)
|
||||||
#define MI_PRIM_HAS_PROCESS_INIT 1
|
#define MI_PRIM_HAS_PROCESS_ATTACH 1
|
||||||
|
|
||||||
// Set up TLS callbacks in a statically linked library by using special data sections.
|
// Set up TLS callbacks in a statically linked library by using special data sections.
|
||||||
// See <https://stackoverflow.com/questions/14538159/tls-callback-in-windows>
|
// See <https://stackoverflow.com/questions/14538159/tls-callback-in-windows>
|
||||||
|
@ -679,7 +679,7 @@ static void NTAPI mi_win_main(PVOID module, DWORD reason, LPVOID reserved) {
|
||||||
#if defined(_MSC_VER) // on clang/gcc use the constructor attribute (in `src/prim/prim.c`)
|
#if defined(_MSC_VER) // on clang/gcc use the constructor attribute (in `src/prim/prim.c`)
|
||||||
// MSVC: use data section magic for static libraries
|
// MSVC: use data section magic for static libraries
|
||||||
// See <https://www.codeguru.com/cpp/misc/misc/applicationcontrol/article.php/c6945/Running-Code-Before-and-After-Main.htm>
|
// See <https://www.codeguru.com/cpp/misc/misc/applicationcontrol/article.php/c6945/Running-Code-Before-and-After-Main.htm>
|
||||||
#define MI_PRIM_HAS_PROCESS_INIT 1
|
#define MI_PRIM_HAS_PROCESS_ATTACH 1
|
||||||
|
|
||||||
static int mi_process_attach(void) {
|
static int mi_process_attach(void) {
|
||||||
mi_win_main(NULL,DLL_PROCESS_ATTACH,NULL);
|
mi_win_main(NULL,DLL_PROCESS_ATTACH,NULL);
|
||||||
|
|
Loading…
Add table
Reference in a new issue