From 02fce996c86d6eb473aee83f4b6eb054a51a36da Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Wed, 27 Nov 2024 14:01:13 -0500 Subject: [PATCH] Remove volatile qualifier for g_once_init handles. Should not have it per documentation: https://docs.gtk.org/glib/type_func.Once.init_enter.html ref: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1785 ref: #687 --- clutter/clutter/clutter-enum-types.c.in | 13 +++++---- clutter/clutter/clutter-paint-node.c | 10 +++---- clutter/clutter/x11/clutter-backend-x11.c | 10 +++---- cogl/cogl-path/cogl-path-enum-types.c.in | 13 +++++---- cogl/cogl/cogl-gtype-private.h | 32 +++++++++++------------ src/meta/meta-enum-types.c.in | 13 +++++---- 6 files changed, 44 insertions(+), 47 deletions(-) diff --git a/clutter/clutter/clutter-enum-types.c.in b/clutter/clutter/clutter-enum-types.c.in index de2cb26d0..50f9bbf4b 100644 --- a/clutter/clutter/clutter-enum-types.c.in +++ b/clutter/clutter/clutter-enum-types.c.in @@ -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 ***/ @@ -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 ***/ diff --git a/clutter/clutter/clutter-paint-node.c b/clutter/clutter/clutter-paint-node.c index 138a64652..03589ce7c 100644 --- a/clutter/clutter/clutter-paint-node.c +++ b/clutter/clutter/clutter-paint-node.c @@ -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 | @@ -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; } /** diff --git a/clutter/clutter/x11/clutter-backend-x11.c b/clutter/clutter/x11/clutter-backend-x11.c index c8cb880c8..4944599a3 100644 --- a/clutter/clutter/x11/clutter-backend-x11.c +++ b/clutter/clutter/x11/clutter-backend-x11.c @@ -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" }, @@ -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 diff --git a/cogl/cogl-path/cogl-path-enum-types.c.in b/cogl/cogl-path/cogl-path-enum-types.c.in index 7209da80a..df8bec984 100644 --- a/cogl/cogl-path/cogl-path-enum-types.c.in +++ b/cogl/cogl-path/cogl-path-enum-types.c.in @@ -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 ***/ @@ -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 ***/ diff --git a/cogl/cogl/cogl-gtype-private.h b/cogl/cogl/cogl-gtype-private.h index 7ba270651..5b2461d7b 100644 --- a/cogl/cogl/cogl-gtype-private.h +++ b/cogl/cogl/cogl-gtype-private.h @@ -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) { \ @@ -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 | \ @@ -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,...) \ @@ -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, \ @@ -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() */ @@ -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, \ @@ -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() */ diff --git a/src/meta/meta-enum-types.c.in b/src/meta/meta-enum-types.c.in index 0480ffdca..6b5eec39c 100644 --- a/src/meta/meta-enum-types.c.in +++ b/src/meta/meta-enum-types.c.in @@ -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 ***/ @@ -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 ***/