use g_once_init_enter/g_once_init_leave to guard critical initialization

Tue Jul 10 12:31:50 2007  Tim Janik  <timj@imendio.com>

        * gtype.h: use g_once_init_enter/g_once_init_leave to guard critical
        initialization section of *_get_type implementations in G_DEFINE_TYPE,
        bug #65041.



svn path=/trunk/; revision=5618
This commit is contained in:
Tim Janik 2007-07-10 10:33:03 +00:00 committed by Tim Janik
parent 1132766280
commit 3bdefad44a
2 changed files with 13 additions and 6 deletions

View File

@ -1,3 +1,9 @@
Tue Jul 10 12:31:50 2007 Tim Janik <timj@imendio.com>
* gtype.h: use g_once_init_enter/g_once_init_leave to guard critical
initialization section of *_get_type implementations in G_DEFINE_TYPE,
bug #65041.
Fri Jun 29 2007 Matthias Clasen <mclasen@redhat.com>
* === Released 2.13.6 ===

View File

@ -368,23 +368,24 @@ static void type_name##_class_intern_init (gpointer klass) \
GType \
type_name##_get_type (void) \
{ \
static GType g_define_type_id = 0; \
if (G_UNLIKELY (g_define_type_id == 0)) \
static volatile gsize g_define_type_id__volatile = 0; \
if (g_once_init_enter (&g_define_type_id__volatile)) \
{ \
g_define_type_id = \
GType g_define_type_id = \
g_type_register_static_simple (TYPE_PARENT, \
g_intern_static_string (#TypeName), \
sizeof (TypeName##Class), \
(GClassInitFunc)type_name##_class_intern_init, \
(GClassInitFunc) type_name##_class_intern_init, \
sizeof (TypeName), \
(GInstanceInitFunc)type_name##_init, \
(GInstanceInitFunc) type_name##_init, \
(GTypeFlags) flags); \
{ /* custom code follows */
#define _G_DEFINE_TYPE_EXTENDED_END() \
/* following custom code */ \
} \
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
} \
return g_define_type_id; \
return g_define_type_id__volatile; \
} /* closes type_name##_get_type() */