--- gobject/gboxed.c.orig	Mon Dec 20 15:11:08 2004
+++ gobject/gboxed.c	Mon Dec 20 15:30:40 2004
@@ -23,6 +23,7 @@
 #include	"gvaluearray.h"
 #include	"gclosure.h"
 #include	"gvaluecollector.h"
+#include	"gthread.h"
 
 #include <string.h>
 
@@ -134,63 +135,98 @@
   g_assert (type == G_TYPE_BOXED);
 }
 
+static void
+closure_register_type (GType *type_id)
+{
+  *type_id = g_boxed_type_register_static ("GClosure",
+					   (GBoxedCopyFunc) g_closure_ref,
+					   (GBoxedFreeFunc) g_closure_unref);
+}
+
 GType
 g_closure_get_type (void)
 {
-  static GType type_id = 0;
+  static GType type_id;
+  static GOnce once = G_ONCE_INIT;
+
+  g_once (&once, (GThreadFunc) closure_register_type, &type_id);
 
-  if (!type_id)
-    type_id = g_boxed_type_register_static ("GClosure",
-					    (GBoxedCopyFunc) g_closure_ref,
-					    (GBoxedFreeFunc) g_closure_unref);
   return type_id;
 }
 
+static void
+value_register_type (GType *type_id)
+{
+  *type_id = g_boxed_type_register_static ("GValue",
+					   value_copy,
+					   value_free);
+}
+
 GType
 g_value_get_type (void)
 {
-  static GType type_id = 0;
+  static GType type_id;
+  static GOnce once = G_ONCE_INIT;
+
+  g_once (&once, (GThreadFunc) value_register_type, &type_id);
 
-  if (!type_id)
-    type_id = g_boxed_type_register_static ("GValue",
-					    value_copy,
-					    value_free);
   return type_id;
 }
 
+static void
+value_array_register_type (GType *type_id)
+{
+  *type_id = g_boxed_type_register_static ("GValueArray",
+					   (GBoxedCopyFunc) g_value_array_copy,
+					   (GBoxedFreeFunc) g_value_array_free);
+}
+
 GType
 g_value_array_get_type (void)
 {
-  static GType type_id = 0;
+  static GType type_id;
+  static GOnce once = G_ONCE_INIT;
+
+  g_once (&once, (GThreadFunc) value_array_register_type, &type_id);
 
-  if (!type_id)
-    type_id = g_boxed_type_register_static ("GValueArray",
-					    (GBoxedCopyFunc) g_value_array_copy,
-					    (GBoxedFreeFunc) g_value_array_free);
   return type_id;
 }
 
+static void
+strv_register_type (GType *type_id)
+{
+  *type_id = g_boxed_type_register_static ("GStrv",
+					   (GBoxedCopyFunc) g_strdupv,
+					   (GBoxedFreeFunc) g_strfreev);
+}
+
 GType
 g_strv_get_type (void)
 {
-  static GType type_id = 0;
+  static GType type_id;
+  static GOnce once = G_ONCE_INIT;
+
+  g_once (&once, (GThreadFunc) strv_register_type, &type_id);
 
-  if (!type_id)
-    type_id = g_boxed_type_register_static ("GStrv",
-					    (GBoxedCopyFunc) g_strdupv,
-					    (GBoxedFreeFunc) g_strfreev);
   return type_id;
 }
 
+static void
+gstring_register_type (GType *type_id)
+{
+  *type_id = g_boxed_type_register_static ("GString",	/* the naming is a bit odd, but GString is obviously not G_TYPE_STRING */
+					   gstring_copy,
+					   gstring_free);
+}
+
 GType
 g_gstring_get_type (void)
 {
-  static GType type_id = 0;
+  static GType type_id;
+  static GOnce once = G_ONCE_INIT;
+
+  g_once (&once, (GThreadFunc) gstring_register_type, &type_id);
 
-  if (!type_id)
-    type_id = g_boxed_type_register_static ("GString",	/* the naming is a bit odd, but GString is obviously not G_TYPE_STRING */
-					    gstring_copy,
-					    gstring_free);
   return type_id;
 }
 
--- gobject/gsourceclosure.c.orig	Mon Dec 20 15:20:19 2004
+++ gobject/gsourceclosure.c	Mon Dec 20 15:30:37 2004
@@ -23,6 +23,7 @@
 #include "gmarshal.h"
 #include "gvalue.h"
 #include "gvaluetypes.h"
+#include "gthread.h"
 
 /* This is needed for a proper GBoxedCopyFunc, until the g_io_channel_ref API
  * returns it's GIOChannel itself #131076.
@@ -34,36 +35,48 @@
   return channel;
 }
 
+static void
+io_channel_register_type (GType *our_type)
+{
+  *our_type = g_boxed_type_register_static ("GIOChannel",
+					    (GBoxedCopyFunc) wrap_g_io_channel_ref,
+					    (GBoxedFreeFunc) g_io_channel_unref);
+}
+
 GType
 g_io_channel_get_type (void)
 {
-  static GType our_type = 0;
-  
-  if (our_type == 0)
-    our_type = g_boxed_type_register_static ("GIOChannel",
-					     (GBoxedCopyFunc) wrap_g_io_channel_ref,
-					     (GBoxedFreeFunc) g_io_channel_unref);
+  static GType our_type;
+  static GOnce once = G_ONCE_INIT;
+
+  g_once (&once, (GThreadFunc) io_channel_register_type, &our_type);
 
   return our_type;
 }
 
+static void
+io_condition_register_type (GType *etype)
+{
+  static const GFlagsValue values[] = {
+    { G_IO_IN,   "G_IO_IN",   "in" },
+    { G_IO_OUT,  "G_IO_OUT",  "out" },
+    { G_IO_PRI,  "G_IO_PRI",  "pri" },
+    { G_IO_ERR,  "G_IO_ERR",  "err" },
+    { G_IO_HUP,  "G_IO_HUP",  "hup" },
+    { G_IO_NVAL, "G_IO_NVAL", "nval" },
+    { 0, NULL, NULL }
+  };
+  *etype = g_flags_register_static ("GIOCondition", values);
+}
+
 GType
 g_io_condition_get_type (void)
 {
-  static GType etype = 0;
-  if (etype == 0)
-    {
-      static const GFlagsValue values[] = {
-	{ G_IO_IN,   "G_IO_IN",   "in" },
-	{ G_IO_OUT,  "G_IO_OUT",  "out" },
-	{ G_IO_PRI,  "G_IO_PRI",  "pri" },
-	{ G_IO_ERR,  "G_IO_ERR",  "err" },
-	{ G_IO_HUP,  "G_IO_HUP",  "hup" },
-	{ G_IO_NVAL, "G_IO_NVAL", "nval" },
-	{ 0, NULL, NULL }
-      };
-      etype = g_flags_register_static ("GIOCondition", values);
-    }
+  static GType etype;
+  static GOnce once = G_ONCE_INIT;
+
+  g_once (&once, (GThreadFunc) io_condition_register_type, &etype);
+
   return etype;
 }
 
--- gobject/gtypemodule.c.orig	Mon Dec 20 15:26:35 2004
+++ gobject/gtypemodule.c	Mon Dec 20 15:30:57 2004
@@ -21,6 +21,7 @@
 
 #include "gtypeplugin.h"
 #include "gtypemodule.h"
+#include "gthread.h"
 
 typedef struct _ModuleTypeInfo ModuleTypeInfo;
 typedef struct _ModuleInterfaceInfo ModuleInterfaceInfo;
@@ -98,34 +99,38 @@
   iface->complete_interface_info = g_type_module_complete_interface_info;
 }
 
-GType
-g_type_module_get_type (void)
+static void
+type_module_register_type (GType *type_module_type)
 {
-  static GType type_module_type = 0;
+  static const GTypeInfo type_module_info = {
+    sizeof (GTypeModuleClass),
+    NULL,           /* base_init */
+    NULL,           /* base_finalize */
+    (GClassInitFunc) g_type_module_class_init,
+    NULL,           /* class_finalize */
+    NULL,           /* class_data */
+    sizeof (GTypeModule),
+    0,              /* n_preallocs */
+    NULL,           /* instance_init */
+  };
+  static const GInterfaceInfo iface_info = {
+    (GInterfaceInitFunc) g_type_module_iface_init,
+    NULL,               /* interface_finalize */
+    NULL,               /* interface_data */
+  };
 
-  if (!type_module_type)
-    {
-      static const GTypeInfo type_module_info = {
-        sizeof (GTypeModuleClass),
-        NULL,           /* base_init */
-        NULL,           /* base_finalize */
-        (GClassInitFunc) g_type_module_class_init,
-        NULL,           /* class_finalize */
-        NULL,           /* class_data */
-        sizeof (GTypeModule),
-        0,              /* n_preallocs */
-        NULL,           /* instance_init */
-      };
-      static const GInterfaceInfo iface_info = {
-        (GInterfaceInitFunc) g_type_module_iface_init,
-        NULL,               /* interface_finalize */
-        NULL,               /* interface_data */
-      };
+  *type_module_type = g_type_register_static (G_TYPE_OBJECT, "GTypeModule", &type_module_info, G_TYPE_FLAG_ABSTRACT);
+
+  g_type_add_interface_static (*type_module_type, G_TYPE_TYPE_PLUGIN, &iface_info);
+}
 
-      type_module_type = g_type_register_static (G_TYPE_OBJECT, "GTypeModule", &type_module_info, G_TYPE_FLAG_ABSTRACT);
+GType
+g_type_module_get_type (void)
+{
+  static GType type_module_type;
+  static GOnce once = G_ONCE_INIT;
 
-      g_type_add_interface_static (type_module_type, G_TYPE_TYPE_PLUGIN, &iface_info);
-    }
+  g_once (&once, (GThreadFunc) type_module_register_type, &type_module_type);
   
   return type_module_type;
 }
--- gobject/gtypeplugin.c.orig	Mon Dec 20 15:28:14 2004
+++ gobject/gtypeplugin.c	Mon Dec 20 15:31:13 2004
@@ -17,25 +17,30 @@
  * Boston, MA 02111-1307, USA.
  */
 #include	"gtypeplugin.h"
+#include	"gthread.h"
 
 
 
 /* --- functions --- */
+static void
+type_plugin_register_type (GType *type_plugin_type)
+{
+  static const GTypeInfo type_plugin_info = {
+    sizeof (GTypePluginClass),
+    NULL,           /* base_init */
+    NULL,           /* base_finalize */
+  };
+      
+  *type_plugin_type = g_type_register_static (G_TYPE_INTERFACE, "GTypePlugin", &type_plugin_info, 0);
+}
+
 GType
 g_type_plugin_get_type (void)
 {
-  static GType type_plugin_type = 0;
-  
-  if (!type_plugin_type)
-    {
-      static const GTypeInfo type_plugin_info = {
-	sizeof (GTypePluginClass),
-	NULL,           /* base_init */
-	NULL,           /* base_finalize */
-      };
-      
-      type_plugin_type = g_type_register_static (G_TYPE_INTERFACE, "GTypePlugin", &type_plugin_info, 0);
-    }
+  static GType type_plugin_type;
+  static GOnce once = G_ONCE_INIT;
+
+  g_once (&once, (GThreadFunc) type_plugin_register_type, &type_plugin_type);
   
   return type_plugin_type;
 }
