crt: tls: Deduplicate code for running mingw cxa dtors Code for this functionality inside the tls_atexit.c file is already in the local tls_atexit_callback() function. Signed-off-by: LIU Hao <lh_mouse@126.com>
diff --git a/mingw-w64-crt/crt/tls_atexit.c b/mingw-w64-crt/crt/tls_atexit.c index 337a1a8..0e4d57c 100644 --- a/mingw-w64-crt/crt/tls_atexit.c +++ b/mingw-w64-crt/crt/tls_atexit.c
@@ -149,18 +149,13 @@ * but none get called for the main executable. This matches what the * standard says, but differs from what MSVC does with a dynamically * linked CRT (which still runs TLS destructors for the main thread). + * + * For DLLs, run dtors when detached. For EXEs, run dtors via the + * thread local atexit callback, to make sure they don't run when + * exiting the process with _exit or ExitProcess. */ - if (__mingw_module_is_dll) { - run_thread_dtor_list(); - /* For DLLs, run dtors when detached. For EXEs, run dtors via the - * thread local atexit callback, to make sure they don't run when - * exiting the process with _exit or ExitProcess. */ - run_dtor_list(&global_dtors); - if (tls_dtors_slot != TLS_OUT_OF_INDEXES) { - TlsFree(tls_dtors_slot); - tls_dtors_slot = TLS_OUT_OF_INDEXES; - } - } + if (__mingw_module_is_dll) + tls_atexit_callback(NULL, DLL_PROCESS_DETACH, NULL); if (inited == 1) { inited = 0; DeleteCriticalSection(&lock);