mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-09 19:06:15 +01:00
gresource: Ensure lazy_register_resources is always accessed atomically
On some platforms, pointer-sized reads are not necessarily atomic, so we always need to use the correct atomic access primitives. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
f792b2ce64
commit
28f83c9cf7
@ -1367,7 +1367,7 @@ register_lazy_static_resources_unlocked (void)
|
||||
GStaticResource *list;
|
||||
|
||||
do
|
||||
list = lazy_register_resources;
|
||||
list = g_atomic_pointer_get (&lazy_register_resources);
|
||||
while (!g_atomic_pointer_compare_and_exchange (&lazy_register_resources, list, NULL));
|
||||
|
||||
while (list != NULL)
|
||||
@ -1416,7 +1416,7 @@ g_static_resource_init (GStaticResource *static_resource)
|
||||
|
||||
do
|
||||
{
|
||||
next = lazy_register_resources;
|
||||
next = g_atomic_pointer_get (&lazy_register_resources);
|
||||
static_resource->next = next;
|
||||
}
|
||||
while (!g_atomic_pointer_compare_and_exchange (&lazy_register_resources, next, static_resource));
|
||||
|
Loading…
Reference in New Issue
Block a user