mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 15:06:14 +01:00
gobject: use g_once_init_enter_pointer for GType initializers
GType is either an integer or a pointer, so we have to use the _pointer version here to support architectures such as Morello. Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842 See also: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3578
This commit is contained in:
parent
a1dfecf11f
commit
5ecd3cbe52
@ -38,9 +38,9 @@
|
||||
GType
|
||||
@enum_name@_get_type (void)
|
||||
{
|
||||
static gsize static_g_define_type_id = 0;
|
||||
static GType static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
if (g_once_init_enter_pointer (&static_g_define_type_id))
|
||||
{
|
||||
static const G@Type@Value values[] = {
|
||||
/*** END value-header ***/
|
||||
@ -54,7 +54,7 @@ GType
|
||||
};
|
||||
GType g_define_type_id =
|
||||
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return static_g_define_type_id;
|
||||
|
@ -1163,9 +1163,9 @@ test_object_set_property (GObject *object,
|
||||
static GType
|
||||
test_enum_get_type (void)
|
||||
{
|
||||
static gsize define_type_id = 0;
|
||||
static GType define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&define_type_id))
|
||||
if (g_once_init_enter_pointer (&define_type_id))
|
||||
{
|
||||
static const GEnumValue values[] = {
|
||||
{ TEST_ENUM_FOO, "TEST_ENUM_FOO", "foo" },
|
||||
@ -1176,7 +1176,7 @@ test_enum_get_type (void)
|
||||
};
|
||||
|
||||
GType type_id = g_enum_register_static ("TestEnum", values);
|
||||
g_once_init_leave (&define_type_id, type_id);
|
||||
g_once_init_leave_pointer (&define_type_id, type_id);
|
||||
}
|
||||
|
||||
return define_type_id;
|
||||
@ -1185,9 +1185,9 @@ test_enum_get_type (void)
|
||||
static GType
|
||||
test_flags_get_type (void)
|
||||
{
|
||||
static gsize define_type_id = 0;
|
||||
static GType define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&define_type_id))
|
||||
if (g_once_init_enter_pointer (&define_type_id))
|
||||
{
|
||||
static const GFlagsValue values[] = {
|
||||
{ TEST_FLAGS_NONE, "TEST_FLAGS_NONE", "none" },
|
||||
@ -1198,7 +1198,7 @@ test_flags_get_type (void)
|
||||
};
|
||||
|
||||
GType type_id = g_flags_register_static ("TestFlags", values);
|
||||
g_once_init_leave (&define_type_id, type_id);
|
||||
g_once_init_leave_pointer (&define_type_id, type_id);
|
||||
}
|
||||
|
||||
return define_type_id;
|
||||
|
@ -123,9 +123,9 @@
|
||||
GType
|
||||
g_binding_flags_get_type (void)
|
||||
{
|
||||
static gsize static_g_define_type_id = 0;
|
||||
static GType static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
if (g_once_init_enter_pointer (&static_g_define_type_id))
|
||||
{
|
||||
static const GFlagsValue values[] = {
|
||||
{ G_BINDING_DEFAULT, "G_BINDING_DEFAULT", "default" },
|
||||
@ -136,7 +136,7 @@ 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 (&static_g_define_type_id, g_define_type_id);
|
||||
g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return static_g_define_type_id;
|
||||
|
@ -185,16 +185,16 @@ G_DEFINE_BOXED_TYPE (GPatternSpec, g_pattern_spec, g_pattern_spec_copy, g_patter
|
||||
GType
|
||||
g_strv_get_type (void)
|
||||
{
|
||||
static gsize static_g_define_type_id = 0;
|
||||
static GType static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
if (g_once_init_enter_pointer (&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 (&static_g_define_type_id, g_define_type_id);
|
||||
g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return static_g_define_type_id;
|
||||
|
@ -22,9 +22,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
GType
|
||||
@enum_name@_get_type (void)
|
||||
{
|
||||
static gsize static_g_define_type_id = 0;
|
||||
static GType static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
if (g_once_init_enter_pointer (&static_g_define_type_id))
|
||||
{
|
||||
static const G@Type@Value values[] = {
|
||||
/*** END value-header ***/
|
||||
@ -38,7 +38,7 @@ GType
|
||||
};
|
||||
GType g_define_type_id =
|
||||
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return static_g_define_type_id;
|
||||
|
@ -1631,7 +1631,7 @@ g_param_spec_get_default_value (GParamSpec *pspec)
|
||||
* done before a g_once_init_enter() could take the fast path in
|
||||
* another thread.
|
||||
*/
|
||||
if (g_once_init_enter (&priv->default_value.g_type))
|
||||
if (g_once_init_enter_pointer (&priv->default_value.g_type))
|
||||
{
|
||||
GValue default_value = G_VALUE_INIT;
|
||||
|
||||
@ -1641,7 +1641,7 @@ g_param_spec_get_default_value (GParamSpec *pspec)
|
||||
/* store all but the type */
|
||||
memcpy (priv->default_value.data, default_value.data, sizeof (default_value.data));
|
||||
|
||||
g_once_init_leave (&priv->default_value.g_type, pspec->value_type);
|
||||
g_once_init_leave_pointer (&priv->default_value.g_type, pspec->value_type);
|
||||
}
|
||||
|
||||
return &priv->default_value;
|
||||
|
@ -36,7 +36,7 @@ g_io_condition_get_type (void)
|
||||
{
|
||||
static GType etype = 0;
|
||||
|
||||
if (g_once_init_enter (&etype))
|
||||
if (g_once_init_enter_pointer (&etype))
|
||||
{
|
||||
static const GFlagsValue values[] = {
|
||||
{ G_IO_IN, "G_IO_IN", "in" },
|
||||
@ -48,7 +48,7 @@ g_io_condition_get_type (void)
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
GType type_id = g_flags_register_static ("GIOCondition", values);
|
||||
g_once_init_leave (&etype, type_id);
|
||||
g_once_init_leave_pointer (&etype, type_id);
|
||||
}
|
||||
return etype;
|
||||
}
|
||||
|
@ -2009,8 +2009,8 @@ guint g_type_get_type_registration_serial (void);
|
||||
* GType
|
||||
* gtk_gadget_get_type (void)
|
||||
* {
|
||||
* static gsize static_g_define_type_id = 0;
|
||||
* if (g_once_init_enter (&static_g_define_type_id))
|
||||
* static GType static_g_define_type_id = 0;
|
||||
* if (g_once_init_enter_pointer (&static_g_define_type_id))
|
||||
* {
|
||||
* GType g_define_type_id =
|
||||
* g_type_register_static_simple (GTK_TYPE_WIDGET,
|
||||
@ -2030,7 +2030,7 @@ 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 (&static_g_define_type_id, g_define_type_id);
|
||||
* g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id);
|
||||
* }
|
||||
* return static_g_define_type_id;
|
||||
* }
|
||||
@ -2265,6 +2265,16 @@ static void type_name##_class_intern_init (gpointer klass) \
|
||||
}
|
||||
#endif /* GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 */
|
||||
|
||||
#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_80
|
||||
#define _g_type_once_init_type GType
|
||||
#define _g_type_once_init_enter g_once_init_enter_pointer
|
||||
#define _g_type_once_init_leave g_once_init_leave_pointer
|
||||
#else /* if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_80 */
|
||||
#define _g_type_once_init_type gsize
|
||||
#define _g_type_once_init_enter g_once_init_enter
|
||||
#define _g_type_once_init_leave g_once_init_leave
|
||||
#endif /* GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_80 */
|
||||
|
||||
/* Added for _G_DEFINE_TYPE_EXTENDED_WITH_PRELUDE */
|
||||
#define _G_DEFINE_TYPE_EXTENDED_BEGIN_PRE(TypeName, type_name, TYPE_PARENT) \
|
||||
\
|
||||
@ -2286,15 +2296,15 @@ type_name##_get_instance_private (TypeName *self) \
|
||||
GType \
|
||||
type_name##_get_type (void) \
|
||||
{ \
|
||||
static gsize static_g_define_type_id = 0;
|
||||
static _g_type_once_init_type 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 (&static_g_define_type_id)) \
|
||||
if (_g_type_once_init_enter (&static_g_define_type_id)) \
|
||||
{ \
|
||||
GType g_define_type_id = type_name##_get_type_once (); \
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
_g_type_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
} \
|
||||
return static_g_define_type_id; \
|
||||
} /* closes type_name##_get_type() */ \
|
||||
@ -2334,8 +2344,8 @@ static void type_name##_default_init (TypeName##Interface *klass); \
|
||||
GType \
|
||||
type_name##_get_type (void) \
|
||||
{ \
|
||||
static gsize static_g_define_type_id = 0; \
|
||||
if (g_once_init_enter (&static_g_define_type_id)) \
|
||||
static _g_type_once_init_type static_g_define_type_id = 0; \
|
||||
if (_g_type_once_init_enter (&static_g_define_type_id)) \
|
||||
{ \
|
||||
GType g_define_type_id = \
|
||||
g_type_register_static_simple (G_TYPE_INTERFACE, \
|
||||
@ -2351,7 +2361,7 @@ type_name##_get_type (void) \
|
||||
#define _G_DEFINE_INTERFACE_EXTENDED_END() \
|
||||
/* following custom code */ \
|
||||
} \
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
_g_type_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
} \
|
||||
return static_g_define_type_id; \
|
||||
} /* closes type_name##_get_type() */
|
||||
@ -2460,11 +2470,11 @@ static GType type_name##_get_type_once (void); \
|
||||
GType \
|
||||
type_name##_get_type (void) \
|
||||
{ \
|
||||
static gsize static_g_define_type_id = 0; \
|
||||
if (g_once_init_enter (&static_g_define_type_id)) \
|
||||
static _g_type_once_init_type static_g_define_type_id = 0; \
|
||||
if (_g_type_once_init_enter (&static_g_define_type_id)) \
|
||||
{ \
|
||||
GType g_define_type_id = type_name##_get_type_once (); \
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
_g_type_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
} \
|
||||
return static_g_define_type_id; \
|
||||
} \
|
||||
@ -2497,11 +2507,11 @@ static GType type_name##_get_type_once (void); \
|
||||
GType \
|
||||
type_name##_get_type (void) \
|
||||
{ \
|
||||
static gsize static_g_define_type_id = 0; \
|
||||
if (g_once_init_enter (&static_g_define_type_id)) \
|
||||
static _g_type_once_init_type static_g_define_type_id = 0; \
|
||||
if (_g_type_once_init_enter (&static_g_define_type_id)) \
|
||||
{ \
|
||||
GType g_define_type_id = type_name##_get_type_once (); \
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
_g_type_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
} \
|
||||
return static_g_define_type_id; \
|
||||
} \
|
||||
@ -2550,11 +2560,11 @@ static GType type_name##_get_type_once (void); \
|
||||
GType \
|
||||
type_name##_get_type (void) \
|
||||
{ \
|
||||
static gsize static_g_define_type_id = 0; \
|
||||
if (g_once_init_enter (&static_g_define_type_id)) \
|
||||
static _g_type_once_init_type static_g_define_type_id = 0; \
|
||||
if (_g_type_once_init_enter (&static_g_define_type_id)) \
|
||||
{ \
|
||||
GType g_define_type_id = type_name##_get_type_once (); \
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
_g_type_once_init_leave (&static_g_define_type_id, g_define_type_id); \
|
||||
} \
|
||||
return static_g_define_type_id; \
|
||||
} \
|
||||
|
@ -66,9 +66,9 @@ custom_marshal_VOID__INVOCATIONHINT (GClosure *closure,
|
||||
static GType
|
||||
test_enum_get_type (void)
|
||||
{
|
||||
static gsize static_g_define_type_id = 0;
|
||||
static GType static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
if (g_once_init_enter_pointer (&static_g_define_type_id))
|
||||
{
|
||||
static const GEnumValue values[] = {
|
||||
{ TEST_ENUM_NEGATIVE, "TEST_ENUM_NEGATIVE", "negative" },
|
||||
@ -79,7 +79,7 @@ test_enum_get_type (void)
|
||||
};
|
||||
GType g_define_type_id =
|
||||
g_enum_register_static (g_intern_static_string ("TestEnum"), values);
|
||||
g_once_init_leave (&static_g_define_type_id, g_define_type_id);
|
||||
g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return static_g_define_type_id;
|
||||
@ -88,9 +88,9 @@ test_enum_get_type (void)
|
||||
static GType
|
||||
test_unsigned_enum_get_type (void)
|
||||
{
|
||||
static gsize static_g_define_type_id = 0;
|
||||
static GType static_g_define_type_id = 0;
|
||||
|
||||
if (g_once_init_enter (&static_g_define_type_id))
|
||||
if (g_once_init_enter_pointer (&static_g_define_type_id))
|
||||
{
|
||||
static const GEnumValue values[] = {
|
||||
{ TEST_UNSIGNED_ENUM_FOO, "TEST_UNSIGNED_ENUM_FOO", "foo" },
|
||||
@ -99,7 +99,7 @@ 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 (&static_g_define_type_id, g_define_type_id);
|
||||
g_once_init_leave_pointer (&static_g_define_type_id, g_define_type_id);
|
||||
}
|
||||
|
||||
return static_g_define_type_id;
|
||||
|
@ -121,7 +121,7 @@ test_type_flags_final (void)
|
||||
* block within the test_final2_get_type() function
|
||||
*/
|
||||
g_test_expect_message ("GLib", G_LOG_LEVEL_CRITICAL,
|
||||
"*g_once_init_leave: assertion*");
|
||||
"*g_once_init_leave_pointer: assertion*");
|
||||
|
||||
final2_type = TEST_TYPE_FINAL2;
|
||||
g_assert_true (final2_type == G_TYPE_INVALID);
|
||||
|
Loading…
Reference in New Issue
Block a user