From 5c16431446b4a1a709ea7ef86837c1c592913273 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Mon, 11 Sep 2006 13:11:15 +0000 Subject: [PATCH] applied patch from Christian Persch to support G_DEBUG flags Mon Sep 11 14:58:56 2006 Tim Janik * gmodule.c: applied patch from Christian Persch to support G_DEBUG flags resident-modules and bind-now-modules, bug #345099. --- gmodule/ChangeLog | 5 +++++ gmodule/gmodule.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/gmodule/ChangeLog b/gmodule/ChangeLog index 4d8ded6f7..9090e2f53 100644 --- a/gmodule/ChangeLog +++ b/gmodule/ChangeLog @@ -1,3 +1,8 @@ +Mon Sep 11 14:58:56 2006 Tim Janik + + * gmodule.c: applied patch from Christian Persch to support + G_DEBUG flags resident-modules and bind-now-modules, bug #345099. + 2006-08-29 Tor Lillqvist Remove support for Windows 9x/ME. GTK+ hasn't worked on Win9x diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c index fbf24cc86..0ff4eaa41 100644 --- a/gmodule/gmodule.c +++ b/gmodule/gmodule.c @@ -90,6 +90,8 @@ static inline GModule* g_module_find_by_name (const gchar *name); static GModule *modules = NULL; static GModule *main_module = NULL; static GStaticPrivate module_error_private = G_STATIC_PRIVATE_INIT; +static gboolean module_debug_initialized = FALSE; +static guint module_debug_flags = 0; /* --- inline functions --- */ @@ -299,6 +301,29 @@ str_check_suffix (const gchar* string, strcmp (string + string_len - suffix_len, suffix) == 0; } +enum +{ + G_MODULE_DEBUG_RESIDENT_MODULES = 1 << 0, + G_MODULE_DEBUG_BIND_NOW_MODULES = 1 << 1 +}; + +static void +_g_module_debug_init (void) +{ + const GDebugKey keys[] = { + { "resident-modules", G_MODULE_DEBUG_RESIDENT_MODULES }, + { "bind-now-modules", G_MODULE_DEBUG_BIND_NOW_MODULES } + }; + const gchar *env; + + env = g_getenv ("G_DEBUG"); + + module_debug_flags = + !env ? 0 : g_parse_debug_string (env, keys, G_N_ELEMENTS (keys)); + + module_debug_initialized = TRUE; +} + static GStaticRecMutex g_module_global_lock = G_STATIC_REC_MUTEX_INIT; GModule* @@ -312,6 +337,13 @@ g_module_open (const gchar *file_name, SUPPORT_OR_RETURN (NULL); g_static_rec_mutex_lock (&g_module_global_lock); + + if (G_UNLIKELY (!module_debug_initialized)) + _g_module_debug_init (); + + if (module_debug_flags & G_MODULE_DEBUG_BIND_NOW_MODULES) + flags &= ~G_MODULE_BIND_LAZY; + if (!file_name) { if (!main_module) @@ -468,6 +500,10 @@ g_module_open (const gchar *file_name, g_free (saved_error); } + if (module != NULL && + (module_debug_flags & G_MODULE_DEBUG_RESIDENT_MODULES)) + g_module_make_resident (module); + g_static_rec_mutex_unlock (&g_module_global_lock); return module; }