summarylogtreecommitdiffstats
path: root/glib-prefer-constructors-over-DllMain.patch
diff options
context:
space:
mode:
Diffstat (limited to 'glib-prefer-constructors-over-DllMain.patch')
-rw-r--r--glib-prefer-constructors-over-DllMain.patch76
1 files changed, 76 insertions, 0 deletions
diff --git a/glib-prefer-constructors-over-DllMain.patch b/glib-prefer-constructors-over-DllMain.patch
new file mode 100644
index 000000000000..2edec2b1ff5c
--- /dev/null
+++ b/glib-prefer-constructors-over-DllMain.patch
@@ -0,0 +1,76 @@
+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 2.7 and later)
+and the MSVC build (MSVC 2008 and later using _Pragma, earlier
+versions using #pragma)
+---
+ glib/glib-init.c | 22 ++++++++++++++--------
+ 1 file changed, 14 insertions(+), 8 deletions(-)
+
+diff --git a/glib/glib-init.c b/glib/glib-init.c
+--- a/glib/glib-init.c 2018-08-02 16:09:46.277047195 +0200
++++ b/glib/glib-init.c 2018-08-02 16:10:23.617387056 +0200
+@@ -272,12 +272,14 @@
+
+ #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,
+@@ -287,13 +289,6 @@
+ {
+ case DLL_PROCESS_ATTACH:
+ glib_dll = hinstDLL;
+- g_clock_win32_init ();
+-#ifdef THREADS_WIN32
+- g_thread_win32_init ();
+-#endif
+- glib_init ();
+- /* must go after glib_init */
+- g_console_win32_init ();
+ break;
+
+ case DLL_THREAD_DETACH:
+@@ -317,7 +312,10 @@
+ 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)
+@@ -327,7 +325,15 @@
+ 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 ();
++ /* must go after glib_init */
++ g_console_win32_init ();
+ }
+
+ #else