summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2011-09-09 19:48:14 -0400
committerRyan Lortie <desrt@desrt.ca>2011-09-09 19:50:55 -0400
commitf1494c156dcbbe125807ef2a1b5ab0ca4b2acc66 (patch)
treebd701bb7f1e17b900e796ef1e69e372714996666
parentbceaf3a7194ecd5303b6cbc9797586ba4849b1bc (diff)
downloadglib-f1494c156dcbbe125807ef2a1b5ab0ca4b2acc66.tar.gz
Clean up l10n threading stuff
Remove the explicit thread initialisation functions for g_get_charset(), g_get_filename_charsets() and g_get_language_names(). Add a lock around one remaining case of access to libcharset (the other 2 cases already have the lock). Do a proper g_once_init_enter() style initialisation for the GLib gettext functions. https://bugzilla.gnome.org/show_bug.cgi?id=658683
-rw-r--r--glib/gconvert.c10
-rw-r--r--glib/gthread.c4
-rw-r--r--glib/gthreadprivate.h2
-rw-r--r--glib/gutf8.c2
-rw-r--r--glib/gutils.c19
5 files changed, 8 insertions, 29 deletions
diff --git a/glib/gconvert.c b/glib/gconvert.c
index c5845ca02..86a2c0ee8 100644
--- a/glib/gconvert.c
+++ b/glib/gconvert.c
@@ -1425,16 +1425,6 @@ get_filename_charset (const gchar **filename_charset)
return is_utf8;
}
-/* This is called from g_thread_init(). It's used to
- * initialize some static data in a threadsafe way.
- */
-void
-_g_convert_thread_init (void)
-{
- const gchar **dummy;
- (void) g_get_filename_charsets (&dummy);
-}
-
/**
* g_filename_to_utf8:
* @opsysstring: a string in the encoding for filenames
diff --git a/glib/gthread.c b/glib/gthread.c
index 26ff38622..cc8e71764 100644
--- a/glib/gthread.c
+++ b/glib/gthread.c
@@ -957,10 +957,6 @@ g_thread_init_glib (void)
/* accomplish log system initialization to enable messaging */
_g_messages_thread_init_nomessage ();
-
- /* we may run full-fledged initializers from here */
- _g_convert_thread_init ();
- _g_utils_thread_init ();
}
/* The following sections implement: GOnce, GStaticMutex, GStaticRecMutex,
diff --git a/glib/gthreadprivate.h b/glib/gthreadprivate.h
index d0c8b33a9..3887519fc 100644
--- a/glib/gthreadprivate.h
+++ b/glib/gthreadprivate.h
@@ -53,8 +53,6 @@ G_GNUC_INTERNAL void _g_slice_thread_init_nomessage (void);
G_GNUC_INTERNAL void _g_messages_thread_init_nomessage (void);
/* full fledged initializers */
-G_GNUC_INTERNAL void _g_convert_thread_init (void);
-G_GNUC_INTERNAL void _g_utils_thread_init (void);
G_GNUC_INTERNAL void _g_thread_impl_init (void);
G_END_DECLS
diff --git a/glib/gutf8.c b/glib/gutf8.c
index 7344e3994..f6d721baf 100644
--- a/glib/gutf8.c
+++ b/glib/gutf8.c
@@ -597,7 +597,9 @@ g_get_charset (const char **charset)
g_static_private_set (&cache_private, cache, charset_cache_free);
}
+ G_LOCK (aliases);
raw = _g_locale_charset_raw ();
+ G_UNLOCK (aliases);
if (!(cache->raw && strcmp (cache->raw, raw) == 0))
{
diff --git a/glib/gutils.c b/glib/gutils.c
index 679bab7d8..162c2cf61 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -3648,15 +3648,6 @@ g_get_codeset (void)
return g_strdup (charset);
}
-/* This is called from g_thread_init(). It's used to
- * initialize some static data in a threadsafe way.
- */
-void
-_g_utils_thread_init (void)
-{
- g_get_language_names ();
-}
-
#ifdef G_OS_WIN32
/**
@@ -3707,11 +3698,13 @@ _glib_get_locale_dir (void)
#endif /* G_OS_WIN32 */
static void
-ensure_gettext_initialized(void)
+ensure_gettext_initialized (void)
{
- static gboolean _glib_gettext_initialized = FALSE;
+ static gsize initialised;
- if (!_glib_gettext_initialized)
+ g_thread_init_glib ();
+
+ if (g_once_init_enter (&initialised))
{
#ifdef G_OS_WIN32
gchar *tmp = _glib_get_locale_dir ();
@@ -3723,7 +3716,7 @@ ensure_gettext_initialized(void)
# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
# endif
- _glib_gettext_initialized = TRUE;
+ g_once_init_leave (&initialised, TRUE);
}
}