add later thread-done invokation; add mi_is_redirected call
This commit is contained in:
parent
3c563816c0
commit
6c43ae2bde
Binary file not shown.
Binary file not shown.
@ -226,8 +226,10 @@ typedef bool (mi_cdecl mi_block_visit_fun)(const mi_heap_t* heap, const mi_heap_
|
|||||||
|
|
||||||
mi_decl_export bool mi_heap_visit_blocks(const mi_heap_t* heap, bool visit_all_blocks, mi_block_visit_fun* visitor, void* arg);
|
mi_decl_export bool mi_heap_visit_blocks(const mi_heap_t* heap, bool visit_all_blocks, mi_block_visit_fun* visitor, void* arg);
|
||||||
|
|
||||||
|
// Experimental
|
||||||
mi_decl_export bool mi_is_in_heap_region(const void* p) mi_attr_noexcept;
|
mi_decl_export bool mi_is_in_heap_region(const void* p) mi_attr_noexcept;
|
||||||
mi_decl_export int mi_reserve_huge_os_pages(size_t pages, double max_secs) mi_attr_noexcept;
|
mi_decl_export int mi_reserve_huge_os_pages(size_t pages, double max_secs) mi_attr_noexcept;
|
||||||
|
mi_decl_export bool mi_is_redirected() mi_attr_noexcept;
|
||||||
|
|
||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
// Convenience
|
// Convenience
|
||||||
|
20
src/init.c
20
src/init.c
@ -388,14 +388,26 @@ bool _mi_preloading() {
|
|||||||
return os_preloading;
|
return os_preloading;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool mi_is_redirected() mi_attr_noexcept {
|
||||||
|
return mi_redirected;
|
||||||
|
}
|
||||||
|
|
||||||
// Communicate with the redirection module on Windows
|
// Communicate with the redirection module on Windows
|
||||||
#if defined(_WIN32) && defined(MI_SHARED_LIB)
|
#if defined(_WIN32) && defined(MI_SHARED_LIB)
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
mi_decl_export void _mi_redirect_init() {
|
mi_decl_export void _mi_redirect_entry(DWORD reason) {
|
||||||
// called on redirection
|
// called on redirection; careful as this may be called before DllMain
|
||||||
mi_redirected = true;
|
if (reason == DLL_PROCESS_ATTACH) {
|
||||||
|
mi_redirected = true;
|
||||||
|
}
|
||||||
|
else if (reason == DLL_PROCESS_DETACH) {
|
||||||
|
mi_redirected = false;
|
||||||
|
}
|
||||||
|
else if (reason == DLL_THREAD_DETACH) {
|
||||||
|
mi_thread_done();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
__declspec(dllimport) bool mi_allocator_init(const char** message);
|
__declspec(dllimport) bool mi_allocator_init(const char** message);
|
||||||
__declspec(dllimport) void mi_allocator_done();
|
__declspec(dllimport) void mi_allocator_done();
|
||||||
@ -493,7 +505,7 @@ static void mi_process_done(void) {
|
|||||||
mi_process_load();
|
mi_process_load();
|
||||||
}
|
}
|
||||||
else if (reason==DLL_THREAD_DETACH) {
|
else if (reason==DLL_THREAD_DETACH) {
|
||||||
mi_thread_done();
|
if (!mi_is_redirected()) mi_thread_done();
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user