Index: gobject/gtype.h
===================================================================
--- gobject/gtype.h	(révision 6202)
+++ gobject/gtype.h	(copie de travail)
@@ -388,6 +388,43 @@ type_name##_get_type (void) \
   return g_define_type_id__volatile;	\
 } /* closes type_name##_get_type() */
 
+/* convenience macros for boxed type registration:
+ * macro arguments: TypeName, copy_func, free_func
+ * example: G_DEFINE_BOXED_TYPE (GtkFoo, gtk_foo, gtk_foo_copy, gtk_foo_free)
+ */
+#define G_DEFINE_BOXED_TYPE(TypeName, type_name, copy_func, free_func) \
+GType \
+type_name##_get_type (void) \
+{ \
+  static volatile gsize g_define_type_id__volatile = 0; \
+  if (g_once_init_enter (&g_define_type_id__volatile))  \
+    { \
+      GType g_define_type_id = \
+        g_boxed_type_register_static (g_intern_static_string (#TypeName), \
+                                      (GBoxedCopyFunc) copy_func, \
+                                      (GBoxedFreeFunc) free_func); \
+      g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
+    }					\
+  return g_define_type_id__volatile;	\
+} /* closes type_name##_get_type() */
+
+/* convenience macros for pointer type registration:
+ * macro arguments: TypeName, type_name
+ * example: G_DEFINE_POINTER_TYPE (GtkFooPointer, gtk_foo_pointer)
+ */
+#define G_POINTER_BOXED_TYPE(TypeName, type_name) \
+GType \
+type_name##_get_type (void) \
+{ \
+  static volatile gsize g_define_type_id__volatile = 0; \
+  if (g_once_init_enter (&g_define_type_id__volatile))  \
+    { \
+      GType g_define_type_id = \
+        g_pointer_type_register_static (g_intern_static_string (#TypeName)); \
+      g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
+    }					\
+  return g_define_type_id__volatile;	\
+} /* closes type_name##_get_type() */
 
 /* --- protected (for fundamental type implementations) --- */
 GTypePlugin*	 g_type_get_plugin		(GType		     type);
Index: gobject/gsourceclosure.c
===================================================================
--- gobject/gsourceclosure.c	(révision 6202)
+++ gobject/gsourceclosure.c	(copie de travail)
@@ -25,24 +25,14 @@
 #include "gvaluetypes.h"
 #include "gobjectalias.h"
 
-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) g_io_channel_ref,
-					     (GBoxedFreeFunc) g_io_channel_unref);
-
-  return our_type;
-}
+G_DEFINE_BOXED_TYPE (GIOChannel, g_io_channel, g_io_channel_ref, g_io_channel_unref)
 
 GType
 g_io_condition_get_type (void)
 {
-  static GType etype = 0;
-  if (etype == 0)
+  static volatile gsize g_define_type_id__volatile = 0;
+
+  if (g_once_init_enter (&g_define_type_id__volatile))
     {
       static const GFlagsValue values[] = {
 	{ G_IO_IN,   "G_IO_IN",   "in" },
@@ -53,9 +43,13 @@ g_io_condition_get_type (void)
 	{ G_IO_NVAL, "G_IO_NVAL", "nval" },
 	{ 0, NULL, NULL }
       };
-      etype = g_flags_register_static ("GIOCondition", values);
+      GType g_define_type_id =
+        g_flags_register_static (g_intern_static_string ("GIOCondition"), values);
+
+      g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
     }
-  return etype;
+
+  return g_define_type_id__volatile;
 }
 
 /* We need to hand-write this marshaler, since it doesn't have an
Index: gobject/gboxed.c
===================================================================
--- gobject/gboxed.c	(révision 6202)
+++ gobject/gboxed.c	(copie de travail)
@@ -120,42 +120,6 @@ g_boxed_type_init (void) 
   g_assert (type == G_TYPE_BOXED);
 }
 
-GType
-g_closure_get_type (void)
-{
-  static GType type_id = 0;
-
-  if (!type_id)
-    type_id = g_boxed_type_register_static (g_intern_static_string ("GClosure"),
-					    (GBoxedCopyFunc) g_closure_ref,
-					    (GBoxedFreeFunc) g_closure_unref);
-  return type_id;
-}
-
-GType
-g_value_get_type (void)
-{
-  static GType type_id = 0;
-
-  if (!type_id)
-    type_id = g_boxed_type_register_static (g_intern_static_string ("GValue"),
-					    value_copy,
-					    value_free);
-  return type_id;
-}
-
-GType
-g_value_array_get_type (void)
-{
-  static GType type_id = 0;
-
-  if (!type_id)
-    type_id = g_boxed_type_register_static (g_intern_static_string ("GValueArray"),
-					    (GBoxedCopyFunc) g_value_array_copy,
-					    (GBoxedFreeFunc) g_value_array_free);
-  return type_id;
-}
-
 static gpointer
 gdate_copy (gpointer boxed)
 {
@@ -164,30 +128,6 @@ gdate_copy (gpointer boxed)
   return g_date_new_julian (g_date_get_julian (date));
 }
 
-GType
-g_date_get_type (void)
-{
-  static GType type_id = 0;
-
-  if (!type_id)
-    type_id = g_boxed_type_register_static (g_intern_static_string ("GDate"),
-					    (GBoxedCopyFunc) gdate_copy,
-					    (GBoxedFreeFunc) g_date_free);
-  return type_id;
-}
-
-GType
-g_strv_get_type (void)
-{
-  static GType type_id = 0;
-
-  if (!type_id)
-    type_id = g_boxed_type_register_static (g_intern_static_string ("GStrv"),
-					    (GBoxedCopyFunc) g_strdupv,
-					    (GBoxedFreeFunc) g_strfreev);
-  return type_id;
-}
-
 static gpointer
 gstring_copy (gpointer boxed)
 {
@@ -204,19 +144,6 @@ gstring_free (gpointer boxed)
   g_string_free (gstring, TRUE);
 }
 
-GType
-g_gstring_get_type (void)
-{
-  static GType type_id = 0;
-
-  if (!type_id)
-    type_id = g_boxed_type_register_static (g_intern_static_string ("GString"),
-                                            /* the naming is a bit odd, but GString is obviously not G_TYPE_STRING */
-					    gstring_copy,
-					    gstring_free);
-  return type_id;
-}
-
 static gpointer
 hash_table_copy (gpointer boxed)
 {
@@ -231,26 +158,15 @@ hash_table_free (gpointer boxed)
   g_hash_table_unref (hash_table);
 }
 
-GType
-g_hash_table_get_type (void)
-{
-  static GType type_id = 0;
-  if (!type_id)
-    type_id = g_boxed_type_register_static (g_intern_static_string ("GHashTable"),
-					    hash_table_copy, hash_table_free);
-  return type_id;
-}
-
-GType
-g_regex_get_type (void)
-{
-  static GType type_id = 0;
-  if (!type_id)
-    type_id = g_boxed_type_register_static (g_intern_static_string ("GRegex"),
-					    (GBoxedCopyFunc) g_regex_ref,
-					    (GBoxedFreeFunc) g_regex_unref);
-  return type_id;
-}
+G_DEFINE_BOXED_TYPE (GClosure, g_closure, g_closure_ref, g_closure_unref)
+G_DEFINE_BOXED_TYPE (GValue, g_value, value_copy, value_free)
+G_DEFINE_BOXED_TYPE (GValueArray, g_value_array, g_value_array_copy, g_value_array_free)
+G_DEFINE_BOXED_TYPE (GDate, g_date, gdate_copy, g_date_free)
+G_DEFINE_BOXED_TYPE (GStrv, g_strv, g_strdupv, g_strfreev)
+/* the naming is a bit odd, but GString is obviously not G_TYPE_STRING */
+G_DEFINE_BOXED_TYPE (GString, g_gstring, gstring_copy, gstring_free)
+G_DEFINE_BOXED_TYPE (GHashTable, g_hash_table, hash_table_copy, hash_table_free)
+G_DEFINE_BOXED_TYPE (GRegex, g_regex, g_regex_ref, g_regex_unref)
 
 static void
 boxed_proxy_value_init (GValue *value)
