Created
November 18, 2016 00:36
-
-
Save carlosdelfino/8bc9b03dc7956dbe3cbfd14a6234113e to your computer and use it in GitHub Desktop.
From bc90511c1eb333e26e0bc0eaee62375d0e788db6 Mon Sep 17 00:00:00 2001 From: Erik van Pienbroek <epienbro@fedoraproject.org> Date: Tue, 16 Apr 2013 11:42:11 +0200 Subject: [PATCH] win32: Prefer the use of constructors over DllMain This prevents having to depend on DllMain in static libraries Constructors are available in both the GCC build (GCC …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
glib/glib-init.c | 22 ++++++++++++++-------- | |
1 file changed, 14 insertions(+), 8 deletions(-) | |
diff --git a/glib/glib-init.c b/glib/glib-init.c | |
index 0032ee8..dd6ccbf 100644 | |
--- a/glib/glib-init.c | |
+++ b/glib/glib-init.c | |
@@ -223,12 +223,14 @@ glib_init (void) | |
#if defined (G_OS_WIN32) | |
+HMODULE glib_dll = NULL; | |
+ | |
+#if defined (DLL_EXPORT) | |
+ | |
BOOL WINAPI DllMain (HINSTANCE hinstDLL, | |
DWORD fdwReason, | |
LPVOID lpvReserved); | |
-HMODULE glib_dll; | |
- | |
BOOL WINAPI | |
DllMain (HINSTANCE hinstDLL, | |
DWORD fdwReason, | |
@@ -238,11 +240,6 @@ DllMain (HINSTANCE hinstDLL, | |
{ | |
case DLL_PROCESS_ATTACH: | |
glib_dll = hinstDLL; | |
- g_clock_win32_init (); | |
-#ifdef THREADS_WIN32 | |
- g_thread_win32_init (); | |
-#endif | |
- glib_init (); | |
break; | |
case DLL_THREAD_DETACH: | |
@@ -259,7 +256,10 @@ DllMain (HINSTANCE hinstDLL, | |
return TRUE; | |
} | |
-#elif defined (G_HAS_CONSTRUCTORS) | |
+#endif /* defined (DLL_EXPORT) */ | |
+#endif /* defined (G_OS_WIN32) */ | |
+ | |
+#if defined (G_HAS_CONSTRUCTORS) | |
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA | |
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(glib_init_ctor) | |
@@ -269,6 +269,12 @@ G_DEFINE_CONSTRUCTOR(glib_init_ctor) | |
static void | |
glib_init_ctor (void) | |
{ | |
+#if defined (G_OS_WIN32) | |
+ g_clock_win32_init (); | |
+#ifdef THREADS_WIN32 | |
+ g_thread_win32_init (); | |
+#endif /* defined (THREADS_WIN32) */ | |
+#endif /* defined (G_OS_WIN32) */ | |
glib_init (); | |
} | |
-- | |
1.8.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment