/* Should not be necessary but for some reason,
* DllMain is called twice at attachment and
* at detachment.*/
-static int xbt_dll_process_is_dattached = 0;
static int xbt_dll_process_is_attached = 0;
/* see also http://msdn.microsoft.com/en-us/library/ms682583%28VS.85%29.aspx */
&& xbt_dll_process_is_attached == 0) {
xbt_preinit();
} else if (fdwReason == DLL_PROCESS_DETACH
- && xbt_dll_process_is_dattached == 0) {
+ && xbt_dll_process_is_attached == 1) {
xbt_postexit();
}
return 1;
static void xbt_preinit(void)
{
+#ifdef _XBT_WIN32
xbt_dll_process_is_attached = 1;
+#endif
#ifdef MMALLOC_WANT_OVERIDE_LEGACY
mmalloc_preinit();
#endif
static void xbt_postexit(void)
{
- xbt_dll_process_is_dattached = 1;
+#ifdef _XBT_WIN32
+ xbt_dll_process_is_attached = 0;
+#endif
xbt_trp_postexit();
xbt_datadesc_postexit();