Skip to content

Commit

Permalink
Remove volatile qualifier for g_once_init handles.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtwebster committed Nov 27, 2024
1 parent c34b09d commit 02fce99
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 47 deletions.
13 changes: 6 additions & 7 deletions clutter/clutter/clutter-enum-types.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
GType
@enum_name@_get_type (void)
{
static volatile gsize g_enum_type_id__volatile = 0;
static gsize g_enum_type_id = 0;

if (g_once_init_enter (&g_enum_type_id__volatile))
if (g_once_init_enter (&g_enum_type_id))
{
static const G@Type@Value values[] = {
/*** END value-header ***/
Expand All @@ -28,14 +28,13 @@ GType
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
GType g_enum_type_id;
GType id;

g_enum_type_id =
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
id = g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);

g_once_init_leave (&g_enum_type_id__volatile, g_enum_type_id);
g_once_init_leave (&g_enum_type_id, id);
}

return g_enum_type_id__volatile;
return g_enum_type_id;
}
/*** END value-tail ***/
10 changes: 5 additions & 5 deletions clutter/clutter/clutter-paint-node.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ clutter_paint_node_init (ClutterPaintNode *self)
GType
clutter_paint_node_get_type (void)
{
static volatile gsize paint_node_type_id__volatile = 0;
static gsize paint_node_type_id = 0;

if (g_once_init_enter (&paint_node_type_id__volatile))
if (g_once_init_enter (&paint_node_type_id))
{
static const GTypeFundamentalInfo finfo = {
(G_TYPE_FLAG_CLASSED |
Expand Down Expand Up @@ -274,16 +274,16 @@ clutter_paint_node_get_type (void)
&value_table,
};

GType paint_node_type_id =
GType id =
g_type_register_fundamental (g_type_fundamental_next (),
I_("ClutterPaintNode"),
&node_info, &finfo,
G_TYPE_FLAG_ABSTRACT);

g_once_init_leave (&paint_node_type_id__volatile, paint_node_type_id);
g_once_init_leave (&paint_node_type_id, id);
}

return paint_node_type_id__volatile;
return paint_node_type_id;
}

/**
Expand Down
10 changes: 5 additions & 5 deletions clutter/clutter/x11/clutter-backend-x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ G_DEFINE_TYPE (ClutterBackendX11, clutter_backend_x11, CLUTTER_TYPE_BACKEND)
GType
clutter_x11_filter_return_get_type (void)
{
static volatile gsize g_define_type__volatile;
static gsize g_define_type;

if (g_once_init_enter (&g_define_type__volatile))
if (g_once_init_enter (&g_define_type))
{
static const GEnumValue values[] = {
{ CLUTTER_X11_FILTER_CONTINUE, "CLUTTER_X11_FILTER_CONTINUE", "continue" },
Expand All @@ -68,13 +68,13 @@ clutter_x11_filter_return_get_type (void)
{ 0, NULL, NULL },
};

GType g_define_type =
GType id =
g_enum_register_static (g_intern_static_string ("ClutterX11FilterReturn"), values);

g_once_init_leave (&g_define_type__volatile, g_define_type);
g_once_init_leave (&g_define_type, id);
}

return g_define_type__volatile;
return g_define_type;
}

/* atoms; remember to add the code that assigns the atom value to
Expand Down
13 changes: 6 additions & 7 deletions cogl/cogl-path/cogl-path-enum-types.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
GType
@enum_name@_get_type (void)
{
static volatile gsize g_enum_type_id__volatile = 0;
static gsize g_enum_type_id = 0;

if (g_once_init_enter (&g_enum_type_id__volatile))
if (g_once_init_enter (&g_enum_type_id))
{
static const G@Type@Value values[] = {
/*** END value-header ***/
Expand All @@ -35,14 +35,13 @@ GType
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
GType g_enum_type_id;
GType id;

g_enum_type_id =
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
id = g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);

g_once_init_leave (&g_enum_type_id__volatile, g_enum_type_id);
g_once_init_leave (&g_enum_type_id, id);
}

return g_enum_type_id__volatile;
return g_enum_type_id;
}
/*** END value-tail ***/
32 changes: 16 additions & 16 deletions cogl/cogl/cogl-gtype-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ struct _CoglGtypeClass
GType \
cogl_##underscore_name##_get_gtype (void) \
{ \
static volatile size_t type_volatile = 0; \
if (g_once_init_enter (&type_volatile)) \
static gsize g_type_id = 0; \
if (g_once_init_enter (&g_type_id)) \
{ \
GType type = \
g_boxed_type_register_static (g_intern_static_string (I_("Cogl" # Name)), \
(GBoxedCopyFunc)copy_func, \
(GBoxedFreeFunc)free_func); \
g_once_init_leave (&type_volatile, type); \
g_once_init_leave (&g_type_id, type); \
} \
return type_volatile; \
return g_type_id; \
}

#define COGL_GTYPE_IMPLEMENT_INTERFACE(name) { \
Expand All @@ -89,8 +89,8 @@ cogl_##underscore_name##_get_gtype (void) \
GType \
cogl_##name##_get_gtype (void) \
{ \
static volatile gsize type_id__volatile = 0; \
if (g_once_init_enter (&type_id__volatile)) \
static gsize g_type_id = 0; \
if (g_once_init_enter (&g_type_id)) \
{ \
static const GTypeFundamentalInfo finfo = { \
(G_TYPE_FLAG_CLASSED | \
Expand Down Expand Up @@ -125,12 +125,12 @@ cogl_##name##_get_gtype (void) \
I_("Cogl" # Name), \
&node_info, &finfo, \
G_TYPE_FLAG_ABSTRACT); \
g_once_init_leave (&type_id__volatile, \
g_once_init_leave (&g_type_id, \
fundamental_type_id);

#define _COGL_GTYPE_DEFINE_BASE_CLASS_END() \
} \
return type_id__volatile; \
return g_type_id; \
}

#define COGL_GTYPE_DEFINE_BASE_CLASS(Name,name,...) \
Expand All @@ -144,8 +144,8 @@ cogl_##name##_get_gtype (void) \
GType \
name##_get_gtype (void) \
{ \
static volatile gsize type_id__volatile = 0; \
if (g_once_init_enter (&type_id__volatile)) \
static gsize g_type_id = 0; \
if (g_once_init_enter (&g_type_id)) \
{ \
GType fundamental_type_id = \
g_type_register_static_simple (G_TYPE_INTERFACE, \
Expand All @@ -162,10 +162,10 @@ cogl_##name##_get_gtype (void) \
#define _COGL_GTYPE_DEFINE_INTERFACE_EXTENDED_END() \
/* following custom code */ \
} \
g_once_init_leave (&type_id__volatile, \
g_once_init_leave (&g_type_id, \
fundamental_type_id); \
} \
return type_id__volatile; \
return g_type_id; \
} /* closes name##_get_type() */


Expand Down Expand Up @@ -207,8 +207,8 @@ cogl_##name##_get_gtype (void) \
GType \
name##_get_gtype (void) \
{ \
static volatile gsize type_id__volatile = 0; \
if (g_once_init_enter (&type_id__volatile)) \
static gsize g_type_id = 0; \
if (g_once_init_enter (&g_type_id)) \
{ \
GType fundamental_type_id = \
g_type_register_static_simple (parent, \
Expand All @@ -223,10 +223,10 @@ cogl_##name##_get_gtype (void) \
#define _COGL_GTYPE_DEFINE_TYPE_EXTENDED_END() \
/* following custom code */ \
} \
g_once_init_leave (&type_id__volatile, \
g_once_init_leave (&g_type_id, \
fundamental_type_id); \
} \
return type_id__volatile; \
return g_type_id; \
} /* closes name##_get_type() */


Expand Down
13 changes: 6 additions & 7 deletions src/meta/meta-enum-types.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
GType
@enum_name@_get_type (void)
{
static volatile gsize g_enum_type_id__volatile = 0;
static gsize g_enum_type_id = 0;

if (g_once_init_enter (&g_enum_type_id__volatile))
if (g_once_init_enter (&g_enum_type_id))
{
static const G@Type@Value values[] = {
/*** END value-header ***/
Expand All @@ -27,14 +27,13 @@ GType
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
GType g_enum_type_id;
GType id;

g_enum_type_id =
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
id = g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);

g_once_init_leave (&g_enum_type_id__volatile, g_enum_type_id);
g_once_init_leave (&g_enum_type_id, id);
}

return g_enum_type_id__volatile;
return g_enum_type_id;
}
/*** END value-tail ***/

0 comments on commit 02fce99

Please sign in to comment.