This avoid overhead of atexit call which requires dynamic allocation and
for DLL builds also larger code which is statically linked into every DLL.
---
 mingw-w64-crt/gdtoa/misc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mingw-w64-crt/gdtoa/misc.c b/mingw-w64-crt/gdtoa/misc.c
index 6716392d33fe..322b56c68071 100644
--- a/mingw-w64-crt/gdtoa/misc.c
+++ b/mingw-w64-crt/gdtoa/misc.c
@@ -59,6 +59,8 @@ static long dtoa_CS_init = 0;
    2 = initialized
    3 = deleted
 */
+
+__attribute__((destructor))
 static void dtoa_lock_cleanup (void)
 {
        long last_CS_init = InterlockedExchange (&dtoa_CS_init,3);
@@ -81,7 +83,6 @@ static void dtoa_lock (unsigned int n)
                        int i;
                        for (i = 0; i < NLOCKS;  i++)
                                InitializeCriticalSection (&dtoa_CritSec[i]);
-                       atexit (dtoa_lock_cleanup);
                        (void)InterlockedExchange (&dtoa_CS_init, 2);
                }
                else if (2 == last_CS_init)
-- 
2.20.1



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

Reply via email to