mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-23 22:16:16 +01:00
gobject: Drop use of volatile from get_type() macros
http://isvolatileusefulwiththreads.in/c/ It’s possible that the variables here are only marked as volatile because they’re arguments to `g_once_*()`. Those arguments will be modified in a subsequent commit. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #600
This commit is contained in:
parent
066e68001e
commit
fab561f8d0
@ -480,9 +480,9 @@ A C source template file will typically look like this:
|
||||
GType
|
||||
@enum_name@_get_type (void)
|
||||
{
|
||||
static volatile gsize g_@type@_type_id__volatile;
|
||||
static gsize static_g_@type@_type_id;
|
||||
|
||||
if (g_once_init_enter (&g_define_type_id__volatile))
|
||||
if (g_once_init_enter (&static_g_@type@_type_id))
|
||||
{
|
||||
static const G@Type@Value values[] = {
|
||||
/*** END value-header ***/
|
||||
@ -498,9 +498,9 @@ GType
|
||||
GType g_@type@_type_id =
|
||||
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
|
||||
|
||||
g_once_init_leave (&g_@type@_type_id__volatile, g_@type@_type_id);
|
||||
g_once_init_leave (&static_g_@type@_type_id, g_@type@_type_id);
|
||||
}
|
||||
return g_@type@_type_id__volatile;
|
||||
return static_g_@type@_type_id;
|
||||
}
|
||||
|
||||
/*** END value-tail ***/
|
||||
|
@ -852,7 +852,7 @@ viewer_editable_default_init (ViewerEditableInterface *iface)
|
||||
GType
|
||||
viewer_editable_get_type (void)
|
||||
{
|
||||
static volatile gsize type_id = 0;
|
||||
static gsize type_id = 0;
|
||||
if (g_once_init_enter (&type_id)) {
|
||||
const GTypeInfo info = {
|
||||
sizeof (ViewerEditableInterface),
|
||||
|
@ -13,9 +13,9 @@
|
||||
GType
|
||||
@enum_name@_get_type (void)
|
||||
{
|
||||
static volatile gsize g_define_type_id__volatile = 0;
|
||||
static gsize static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&g_define_type_id__volatile))
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
{
|
||||
static const G@Type@Value values[] = {
|
||||
/*** END value-header ***/
|
||||
@ -29,10 +29,10 @@ GType
|
||||
};
|
||||
GType g_define_type_id =
|
||||
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
|
||||
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return g_define_type_id__volatile;
|
||||
return static_g_define_type_id;
|
||||
}
|
||||
|
||||
/*** END value-tail ***/
|
||||
|
@ -1060,7 +1060,7 @@ test_object_set_property (GObject *object,
|
||||
static GType
|
||||
test_enum_get_type (void)
|
||||
{
|
||||
static volatile gsize define_type_id = 0;
|
||||
static gsize define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&define_type_id))
|
||||
{
|
||||
@ -1082,7 +1082,7 @@ test_enum_get_type (void)
|
||||
static GType
|
||||
test_flags_get_type (void)
|
||||
{
|
||||
static volatile gsize define_type_id = 0;
|
||||
static gsize define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&define_type_id))
|
||||
{
|
||||
|
@ -120,9 +120,9 @@
|
||||
GType
|
||||
g_binding_flags_get_type (void)
|
||||
{
|
||||
static volatile gsize g_define_type_id__volatile = 0;
|
||||
static gsize static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&g_define_type_id__volatile))
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
{
|
||||
static const GFlagsValue values[] = {
|
||||
{ G_BINDING_DEFAULT, "G_BINDING_DEFAULT", "default" },
|
||||
@ -133,10 +133,10 @@ g_binding_flags_get_type (void)
|
||||
};
|
||||
GType g_define_type_id =
|
||||
g_flags_register_static (g_intern_static_string ("GBindingFlags"), values);
|
||||
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return g_define_type_id__volatile;
|
||||
return static_g_define_type_id;
|
||||
}
|
||||
|
||||
#define G_BINDING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_BINDING, GBindingClass))
|
||||
|
@ -180,19 +180,19 @@ G_DEFINE_BOXED_TYPE (GOptionGroup, g_option_group, g_option_group_ref, g_option_
|
||||
GType
|
||||
g_strv_get_type (void)
|
||||
{
|
||||
static volatile gsize g_define_type_id__volatile = 0;
|
||||
static gsize static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&g_define_type_id__volatile))
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
{
|
||||
GType g_define_type_id =
|
||||
g_boxed_type_register_static (g_intern_static_string ("GStrv"),
|
||||
(GBoxedCopyFunc) g_strdupv,
|
||||
(GBoxedFreeFunc) g_strfreev);
|
||||
|
||||
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return g_define_type_id__volatile;
|
||||
return static_g_define_type_id;
|
||||
}
|
||||
|
||||
GType
|
||||
|
@ -13,9 +13,9 @@
|
||||
GType
|
||||
@enum_name@_get_type (void)
|
||||
{
|
||||
static volatile gsize g_define_type_id__volatile = 0;
|
||||
static gsize static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&g_define_type_id__volatile))
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
{
|
||||
static const G@Type@Value values[] = {
|
||||
/*** END value-header ***/
|
||||
@ -29,10 +29,10 @@ GType
|
||||
};
|
||||
GType g_define_type_id =
|
||||
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
|
||||
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return g_define_type_id__volatile;
|
||||
return static_g_define_type_id;
|
||||
}
|
||||
|
||||
/*** END value-tail ***/
|
||||
|
@ -32,7 +32,7 @@ G_DEFINE_BOXED_TYPE (GIOChannel, g_io_channel, g_io_channel_ref, g_io_channel_un
|
||||
GType
|
||||
g_io_condition_get_type (void)
|
||||
{
|
||||
static volatile GType etype = 0;
|
||||
static GType etype = 0;
|
||||
|
||||
if (g_once_init_enter (&etype))
|
||||
{
|
||||
|
@ -1727,8 +1727,8 @@ guint g_type_get_type_registration_serial (void);
|
||||
* GType
|
||||
* gtk_gadget_get_type (void)
|
||||
* {
|
||||
* static volatile gsize g_define_type_id__volatile = 0;
|
||||
* if (g_once_init_enter (&g_define_type_id__volatile))
|
||||
* static gsize static_g_define_type_id = 0;
|
||||
* if (g_once_init_enter (&static_g_define_type_id))
|
||||
* {
|
||||
* GType g_define_type_id =
|
||||
* g_type_register_static_simple (GTK_TYPE_WIDGET,
|
||||
@ -1748,9 +1748,9 @@ guint g_type_get_type_registration_serial (void);
|
||||
* };
|
||||
* g_type_add_interface_static (g_define_type_id, TYPE_GIZMO, &g_implement_interface_info);
|
||||
* }
|
||||
* g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
|
||||
* g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
* }
|
||||
* return g_define_type_id__volatile;
|
||||
* return static_g_define_type_id;
|
||||
* }
|
||||
* ]|
|
||||
* The only pieces which have to be manually provided are the definitions of
|
||||
@ -1995,17 +1995,17 @@ type_name##_get_instance_private (TypeName *self) \
|
||||
GType \
|
||||
type_name##_get_type (void) \
|
||||
{ \
|
||||
static volatile gsize g_define_type_id__volatile = 0;
|
||||
static gsize static_g_define_type_id = 0;
|
||||
/* Prelude goes here */
|
||||
|
||||
/* Added for _G_DEFINE_TYPE_EXTENDED_WITH_PRELUDE */
|
||||
#define _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
|
||||
if (g_once_init_enter (&g_define_type_id__volatile)) \
|
||||
if (g_once_init_enter (&static_g_define_type_id)) \
|
||||
{ \
|
||||
GType g_define_type_id = type_name##_get_type_once (); \
|
||||
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
} \
|
||||
return g_define_type_id__volatile; \
|
||||
return static_g_define_type_id; \
|
||||
} /* closes type_name##_get_type() */ \
|
||||
\
|
||||
G_GNUC_NO_INLINE \
|
||||
@ -2041,8 +2041,8 @@ static void type_name##_default_init (TypeName##Interface *klass); \
|
||||
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)) \
|
||||
static gsize static_g_define_type_id = 0; \
|
||||
if (g_once_init_enter (&static_g_define_type_id)) \
|
||||
{ \
|
||||
GType g_define_type_id = \
|
||||
g_type_register_static_simple (G_TYPE_INTERFACE, \
|
||||
@ -2058,9 +2058,9 @@ type_name##_get_type (void) \
|
||||
#define _G_DEFINE_INTERFACE_EXTENDED_END() \
|
||||
/* following custom code */ \
|
||||
} \
|
||||
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
} \
|
||||
return g_define_type_id__volatile; \
|
||||
return static_g_define_type_id; \
|
||||
} /* closes type_name##_get_type() */
|
||||
|
||||
/**
|
||||
@ -2115,13 +2115,13 @@ static GType type_name##_get_type_once (void); \
|
||||
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)) \
|
||||
static gsize static_g_define_type_id = 0; \
|
||||
if (g_once_init_enter (&static_g_define_type_id)) \
|
||||
{ \
|
||||
GType g_define_type_id = type_name##_get_type_once (); \
|
||||
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
} \
|
||||
return g_define_type_id__volatile; \
|
||||
return static_g_define_type_id; \
|
||||
} \
|
||||
\
|
||||
G_GNUC_NO_INLINE \
|
||||
@ -2152,13 +2152,13 @@ static GType type_name##_get_type_once (void); \
|
||||
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)) \
|
||||
static gsize static_g_define_type_id = 0; \
|
||||
if (g_once_init_enter (&static_g_define_type_id)) \
|
||||
{ \
|
||||
GType g_define_type_id = type_name##_get_type_once (); \
|
||||
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
} \
|
||||
return g_define_type_id__volatile; \
|
||||
return static_g_define_type_id; \
|
||||
} \
|
||||
\
|
||||
G_GNUC_NO_INLINE \
|
||||
@ -2205,13 +2205,13 @@ static GType type_name##_get_type_once (void); \
|
||||
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)) \
|
||||
static gsize static_g_define_type_id = 0; \
|
||||
if (g_once_init_enter (&static_g_define_type_id)) \
|
||||
{ \
|
||||
GType g_define_type_id = type_name##_get_type_once (); \
|
||||
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
} \
|
||||
return g_define_type_id__volatile; \
|
||||
return static_g_define_type_id; \
|
||||
} \
|
||||
\
|
||||
G_GNUC_NO_INLINE \
|
||||
|
@ -66,9 +66,9 @@ custom_marshal_VOID__INVOCATIONHINT (GClosure *closure,
|
||||
static GType
|
||||
test_enum_get_type (void)
|
||||
{
|
||||
static volatile gsize g_define_type_id__volatile = 0;
|
||||
static gsize static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&g_define_type_id__volatile))
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
{
|
||||
static const GEnumValue values[] = {
|
||||
{ TEST_ENUM_NEGATIVE, "TEST_ENUM_NEGATIVE", "negative" },
|
||||
@ -79,18 +79,18 @@ test_enum_get_type (void)
|
||||
};
|
||||
GType g_define_type_id =
|
||||
g_enum_register_static (g_intern_static_string ("TestEnum"), values);
|
||||
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return g_define_type_id__volatile;
|
||||
return static_g_define_type_id;
|
||||
}
|
||||
|
||||
static GType
|
||||
test_unsigned_enum_get_type (void)
|
||||
{
|
||||
static volatile gsize g_define_type_id__volatile = 0;
|
||||
static gsize static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&g_define_type_id__volatile))
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
{
|
||||
static const GEnumValue values[] = {
|
||||
{ TEST_UNSIGNED_ENUM_FOO, "TEST_UNSIGNED_ENUM_FOO", "foo" },
|
||||
@ -99,10 +99,10 @@ test_unsigned_enum_get_type (void)
|
||||
};
|
||||
GType g_define_type_id =
|
||||
g_enum_register_static (g_intern_static_string ("TestUnsignedEnum"), values);
|
||||
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return g_define_type_id__volatile;
|
||||
return static_g_define_type_id;
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
|
Loading…
Reference in New Issue
Block a user