diff options
author | Emmanuele Bassi <ebassi@linux.intel.com> | 2009-05-16 13:53:58 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@linux.intel.com> | 2009-05-16 13:53:58 +0100 |
commit | 5778210462b8b7a1a5d98466508276f712ea8c47 (patch) | |
tree | 4c712b34ddbd3605e2e7820046f26b3bd936cf8d /json-glib | |
parent | 43d4bd151cd6979ecc6fdad5fab3e7988117c7be (diff) | |
download | json-glib-5778210462b8b7a1a5d98466508276f712ea8c47.tar.gz |
Update the enum types templates
The autogenerated enumeration types registration code should
be using the same pattern used by the G_DEFINE_TYPE() macros,
with GOnce to enable atomic (and thread-safe) type registration.
Diffstat (limited to 'json-glib')
-rw-r--r-- | json-glib/json-enum-types.c.in | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/json-glib/json-enum-types.c.in b/json-glib/json-enum-types.c.in index 3578c6e..eba4222 100644 --- a/json-glib/json-enum-types.c.in +++ b/json-glib/json-enum-types.c.in @@ -3,15 +3,18 @@ /*** END file-header ***/ /*** BEGIN file-production ***/ + /* enumerations from "@filename@" */ #include "@filename@" + /*** END file-production ***/ /*** BEGIN value-header ***/ GType @enum_name@_get_type(void) { - static GType etype = 0; - if (G_UNLIKELY (!etype)) + static volatile gsize g_enum_type_id__volatile = 0; + + if (g_once_init_enter (&g_enum_type_id__volatile)) { const G@Type@Value values[] = { /*** END value-header ***/ @@ -23,9 +26,14 @@ GType /*** BEGIN value-tail ***/ { 0, NULL, NULL } }; - etype = g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); + GType g_enum_type_id; + + g_enum_type_id = + g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); + + g_once_init_leave (&g_enum_type_id__volatile, g_enum_type_id); } - return etype; -} + return g_enum_type_id__volatile; +} /*** END value-tail ***/ |