mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-11-04 01:58:54 +01:00 
			
		
		
		
	gtype: Add some missing atomic accesses to init_state
Half of the references to `init_state` in `gtype.c` already correctly accessed it atomically, but a couple didn’t. Drop the `volatile` qualifier from its declaration, as that’s not necessary for atomic access. Note that this is the `init_state` in `TypeData`, *not* the `init_state` in `IFaceEntry`. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #600
This commit is contained in:
		@@ -322,7 +322,7 @@ struct _ClassData
 | 
			
		||||
  CommonData         common;
 | 
			
		||||
  guint16            class_size;
 | 
			
		||||
  guint16            class_private_size;
 | 
			
		||||
  int volatile       init_state; /* atomic - g_type_class_ref reads it unlocked */
 | 
			
		||||
  int                init_state;  /* (atomic) - g_type_class_ref reads it unlocked */
 | 
			
		||||
  GBaseInitFunc      class_init_base;
 | 
			
		||||
  GBaseFinalizeFunc  class_finalize_base;
 | 
			
		||||
  GClassInitFunc     class_init;
 | 
			
		||||
@@ -336,7 +336,7 @@ struct _InstanceData
 | 
			
		||||
  CommonData         common;
 | 
			
		||||
  guint16            class_size;
 | 
			
		||||
  guint16            class_private_size;
 | 
			
		||||
  int volatile       init_state; /* atomic - g_type_class_ref reads it unlocked */
 | 
			
		||||
  int                init_state;  /* (atomic) - g_type_class_ref reads it unlocked */
 | 
			
		||||
  GBaseInitFunc      class_init_base;
 | 
			
		||||
  GBaseFinalizeFunc  class_finalize_base;
 | 
			
		||||
  GClassInitFunc     class_init;
 | 
			
		||||
@@ -1415,7 +1415,7 @@ type_node_add_iface_entry_W (TypeNode   *node,
 | 
			
		||||
 | 
			
		||||
  if (parent_entry)
 | 
			
		||||
    {
 | 
			
		||||
      if (node->data && node->data->class.init_state >= BASE_IFACE_INIT)
 | 
			
		||||
      if (node->data && g_atomic_int_get (&node->data->class.init_state) >= BASE_IFACE_INIT)
 | 
			
		||||
        {
 | 
			
		||||
          entries->entry[i].init_state = INITIALIZED;
 | 
			
		||||
          entries->entry[i].vtable = parent_entry->vtable;
 | 
			
		||||
@@ -1481,7 +1481,7 @@ type_add_interface_Wm (TypeNode             *node,
 | 
			
		||||
   */
 | 
			
		||||
  if (node->data)
 | 
			
		||||
    {
 | 
			
		||||
      InitState class_state = node->data->class.init_state;
 | 
			
		||||
      InitState class_state = g_atomic_int_get (&node->data->class.init_state);
 | 
			
		||||
      
 | 
			
		||||
      if (class_state >= BASE_IFACE_INIT)
 | 
			
		||||
        type_iface_vtable_base_init_Wm (iface, node);
 | 
			
		||||
@@ -2175,7 +2175,7 @@ type_class_init_Wm (TypeNode   *node,
 | 
			
		||||
  g_assert (node->is_classed && node->data &&
 | 
			
		||||
	    node->data->class.class_size &&
 | 
			
		||||
	    !node->data->class.class &&
 | 
			
		||||
	    node->data->class.init_state == UNINITIALIZED);
 | 
			
		||||
	    g_atomic_int_get (&node->data->class.init_state) == UNINITIALIZED);
 | 
			
		||||
  if (node->data->class.class_private_size)
 | 
			
		||||
    class = g_malloc0 (ALIGN_STRUCT (node->data->class.class_size) + node->data->class.class_private_size);
 | 
			
		||||
  else
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user