crt: Improve mingw-w64 _register_thread_local_exe_atexit_callback implementation which is used for msvcrt builds

Check that the _register_thread_local_exe_atexit_callback function is not
called multiple times. UCRT also disallow to call it multiple times.

Improve guard in run_callback to ensure that the callback is not executed
more times even if the run_callback is called more times.

Add mingw-w64 wrapper around the CRT exit() function which will register
the callback via atexit before calling the CRT exit function. This ensures
that the CRT exit function would call the callback as the first atexit
callback.

Signed-off-by: LIU Hao <lh_mouse@126.com>
39 files changed