[glib: 4/7] Refactor glib/glib-init.c to isolate init/deinit steps in isolated functions
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 4/7] Refactor glib/glib-init.c to isolate init/deinit steps in isolated functions
- Date: Wed, 26 Jan 2022 11:38:45 +0000 (UTC)
commit 2ff2c9eb5bf4d5be2665ffcf922332de91cab308
Author: Loic Le Page <llepage fluendo com>
Date: Thu Jan 20 16:24:44 2022 +0100
Refactor glib/glib-init.c to isolate init/deinit steps in isolated functions
glib/glib-init.c | 49 +++++++++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 18 deletions(-)
---
diff --git a/glib/glib-init.c b/glib/glib-init.c
index 2e9428253..22be89108 100644
--- a/glib/glib-init.c
+++ b/glib/glib-init.c
@@ -342,12 +342,36 @@ glib_init (void)
#ifdef G_PLATFORM_WIN32
+HMODULE glib_dll = NULL;
+
+static void
+glib_win32_init (void)
+{
+ g_crash_handler_win32_init ();
+#ifdef THREADS_WIN32
+ g_thread_win32_init ();
+#endif
+
+ g_clock_win32_init ();
+ glib_init ();
+ /* must go after glib_init */
+ g_console_win32_init ();
+}
+
+static void
+glib_win32_deinit (gboolean detach_thread)
+{
+#ifdef THREADS_WIN32
+ if (detach_thread)
+ g_thread_win32_process_detach ();
+#endif
+ g_crash_handler_win32_deinit ();
+}
+
BOOL WINAPI DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved);
-HMODULE glib_dll;
-
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
@@ -357,14 +381,7 @@ DllMain (HINSTANCE hinstDLL,
{
case DLL_PROCESS_ATTACH:
glib_dll = hinstDLL;
- g_crash_handler_win32_init ();
- g_clock_win32_init ();
-#ifdef THREADS_WIN32
- g_thread_win32_init ();
-#endif
- glib_init ();
- /* must go after glib_init */
- g_console_win32_init ();
+ glib_win32_init ();
break;
case DLL_THREAD_DETACH:
@@ -374,11 +391,7 @@ DllMain (HINSTANCE hinstDLL,
break;
case DLL_PROCESS_DETACH:
-#ifdef THREADS_WIN32
- if (lpvReserved == NULL)
- g_thread_win32_process_detach ();
-#endif
- g_crash_handler_win32_deinit ();
+ glib_win32_deinit (lpvReserved == NULL);
break;
default:
@@ -389,7 +402,7 @@ DllMain (HINSTANCE hinstDLL,
return TRUE;
}
-#elif defined (G_HAS_CONSTRUCTORS)
+#elif defined(G_HAS_CONSTRUCTORS) /* && !G_PLATFORM_WIN32 */
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(glib_init_ctor)
@@ -402,6 +415,6 @@ glib_init_ctor (void)
glib_init ();
}
-#else
+#else /* !G_PLATFORM_WIN32 && !G_HAS_CONSTRUCTORS */
# error Your platform/compiler is missing constructor support
-#endif
+#endif /* G_PLATFORM_WIN32 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]