在 2020/10/30 下午5:37, Martin Storsjö 写道:
> 
> If you're using UCRT, the callback (tls_atexit_callback in tls_atexit.c) 
> registered by
> _register_thread_local_exe_atexit_callback gets executed. This is a callback 
> that gets executed
> _before_ running any atexit functions, and allows UCRT builds to get TLS 
> destructors executed at the
> right spot. Unfortunately, the emulation of 
> _register_thread_local_exe_atexit_callback for
> msvcrt.dll isn't perfect - maybe it's possible to make it better somehow?
> 
> One way would be to change the atexit() function in crt/crtexe.c to create a 
> local list of funtions
> registered by atexit, just adding one single function to the CRT's atexit() 
> list, and in that
> function, first execute the callback defined by 
> _register_thread_local_exe_atexit_callback if set,
> then all functions registered by atexit().
> 

Yes this looks feasible.

The 'one single function' can be registered just before the call to `__main()` 
which invokes static
constructors. The C standard requires that `atexit()` shall allow registration 
of at least 32
functions, which requires a static array of at least 32 pointers; dynamic 
storage may be used if it
is exhausted.





-- 
Best regards,
LH_Mouse

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to