Use TLS callback also for shared library builds

This way things just work even if the compiled object
files are used in tests.
This commit is contained in:
Luca Bacci
2025-05-26 15:34:41 +02:00
parent c108dc09b9
commit f2b98de002

View File

@@ -458,48 +458,6 @@ glib_win32_deinit (gboolean detach_thread)
g_crash_handler_win32_deinit ();
}
#ifndef GLIB_STATIC_COMPILATION
BOOL WINAPI DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved);
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
glib_dll = hinstDLL;
glib_win32_init ();
break;
case DLL_THREAD_DETACH:
#ifdef THREADS_WIN32
g_thread_win32_thread_detach ();
#endif
break;
case DLL_PROCESS_DETACH:
glib_win32_deinit (lpvReserved == NULL);
break;
default:
/* do nothing */
;
}
return TRUE;
}
#else
#ifndef G_HAS_CONSTRUCTORS
#error static compilation on Windows requires constructor support
#endif
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(glib_priv_constructor)
#endif
@@ -518,7 +476,7 @@ glib_priv_constructor (void)
}
#ifndef G_HAS_TLS_CALLBACKS
#error static compilation on Windows requires TLS callbacks support
#error Compilation on Windows requires TLS callbacks support
#endif
G_DEFINE_TLS_CALLBACK (glib_priv_tls_callback)
@@ -548,8 +506,6 @@ glib_priv_tls_callback (LPVOID hinstance,
}
}
#endif /* GLIB_STATIC_COMPILATION */
#elif defined(G_HAS_CONSTRUCTORS) /* && !G_PLATFORM_WIN32 */
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA