mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 19:38:41 +03:00
Merge branch 'dev3' into dev3-bin
This commit is contained in:
commit
2aad74e0c3
16 changed files with 73 additions and 261 deletions
|
@ -97,7 +97,12 @@ const mi_page_t _mi_page_empty = {
|
|||
// may lead to allocation itself on some platforms)
|
||||
// --------------------------------------------------------
|
||||
|
||||
static mi_decl_cache_align mi_subproc_t subproc_main = { 0 }; // note: empty initializer to prevent running the constructor (in C++ compilation)
|
||||
static mi_decl_cache_align mi_subproc_t subproc_main
|
||||
#if __cplusplus
|
||||
= { }; // empty initializer to prevent running the constructor (with msvc)
|
||||
#else
|
||||
= { 0 }; // C zero initialize
|
||||
#endif
|
||||
|
||||
static mi_decl_cache_align mi_tld_t tld_empty = {
|
||||
0, // thread_id
|
||||
|
|
|
@ -639,6 +639,11 @@ bool _mi_prim_random_buf(void* buf, size_t buf_len) {
|
|||
static void NTAPI mi_win_main(PVOID module, DWORD reason, LPVOID reserved) {
|
||||
MI_UNUSED(reserved);
|
||||
MI_UNUSED(module);
|
||||
#if MI_TLS_SLOT >= 2
|
||||
if ((reason==DLL_PROCESS_ATTACH || reason==DLL_THREAD_ATTACH) && mi_prim_get_default_heap() == NULL) {
|
||||
_mi_heap_set_default_direct((mi_heap_t*)&_mi_heap_empty);
|
||||
}
|
||||
#endif
|
||||
if (reason==DLL_PROCESS_ATTACH) {
|
||||
_mi_process_load();
|
||||
}
|
||||
|
@ -647,7 +652,7 @@ static void NTAPI mi_win_main(PVOID module, DWORD reason, LPVOID reserved) {
|
|||
}
|
||||
else if (reason==DLL_THREAD_DETACH && !_mi_is_redirected()) {
|
||||
_mi_thread_done(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -800,6 +805,11 @@ static void NTAPI mi_win_main(PVOID module, DWORD reason, LPVOID reserved) {
|
|||
#endif
|
||||
mi_decl_export void _mi_redirect_entry(DWORD reason) {
|
||||
// called on redirection; careful as this may be called before DllMain
|
||||
#if MI_TLS_SLOT >= 2
|
||||
if ((reason==DLL_PROCESS_ATTACH || reason==DLL_THREAD_ATTACH) && mi_prim_get_default_heap() == NULL) {
|
||||
_mi_heap_set_default_direct((mi_heap_t*)&_mi_heap_empty);
|
||||
}
|
||||
#endif
|
||||
if (reason == DLL_PROCESS_ATTACH) {
|
||||
mi_redirected = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue