From 8e37c495b8cb4afc6f9833eb654238b8593367f4 Mon Sep 17 00:00:00 2001
From: Jonathan Yong <10walls@gmail.com>
Date: Fri, 31 Oct 2014 06:46:02 +0800
Subject: [PATCH 10/18] Cygwin: prevent modules from being unloaded before
 their dtors are called

---
 libstdc++-v3/config/os/mingw32-w64/os_defines.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libstdc++-v3/config/os/mingw32-w64/os_defines.h b/libstdc++-v3/config/os/mingw32-w64/os_defines.h
index e535f6c2b85..e0284216b12 100644
--- a/libstdc++-v3/config/os/mingw32-w64/os_defines.h
+++ b/libstdc++-v3/config/os/mingw32-w64/os_defines.h
@@ -90,4 +90,9 @@
 
 #define _GLIBCXX_USE_CRT_RAND_S 1
 
+// Enable use of GetModuleHandleEx (requires Windows XP/2003) in
+// __cxa_thread_atexit to prevent modules from being unloaded before
+// their dtors are called
+#define _GLIBCXX_THREAD_ATEXIT_WIN32 1
+
 #endif
-- 
2.28.0

