diff --git a/gio/gresource.c b/gio/gresource.c index 4ccd33364..a67df11ef 100644 --- a/gio/gresource.c +++ b/gio/gresource.c @@ -1364,11 +1364,10 @@ g_resources_get_info (const gchar *path, static void register_lazy_static_resources_unlocked (void) { - GStaticResource *list; + GStaticResource *list = g_atomic_pointer_get (&lazy_register_resources); - do - list = lazy_register_resources; - while (!g_atomic_pointer_compare_and_exchange (&lazy_register_resources, list, NULL)); + while (!g_atomic_pointer_compare_and_exchange_full (&lazy_register_resources, list, NULL, &list)) + ; while (list != NULL) { @@ -1416,7 +1415,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)); diff --git a/glib/gdataset.c b/glib/gdataset.c index 500022630..c8461d943 100644 --- a/glib/gdataset.c +++ b/glib/gdataset.c @@ -144,12 +144,13 @@ #define G_DATALIST_GET_POINTER(datalist) \ ((GData*) ((gsize) g_atomic_pointer_get (datalist) & ~(gsize) G_DATALIST_FLAGS_MASK_INTERNAL)) -#define G_DATALIST_SET_POINTER(datalist, pointer) G_STMT_START { \ - gpointer _oldv, _newv; \ - do { \ - _oldv = g_atomic_pointer_get (datalist); \ +#define G_DATALIST_SET_POINTER(datalist, pointer) G_STMT_START { \ + gpointer _oldv = g_atomic_pointer_get (datalist); \ + gpointer _newv; \ + do { \ _newv = (gpointer) (((gsize) _oldv & G_DATALIST_FLAGS_MASK_INTERNAL) | (gsize) pointer); \ - } while (!g_atomic_pointer_compare_and_exchange ((void**) datalist, _oldv, _newv)); \ + } while (!g_atomic_pointer_compare_and_exchange_full ((void**) datalist, _oldv, \ + _newv, &_oldv)); \ } G_STMT_END /* --- structures --- */ diff --git a/gobject/gobject.c b/gobject/gobject.c index b4186c561..c6fef8282 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -3435,16 +3435,20 @@ object_floating_flag_handler (GObject *object, { gpointer oldvalue; case +1: /* force floating if possible */ - do - oldvalue = g_atomic_pointer_get (&object->qdata); - while (!g_atomic_pointer_compare_and_exchange ((void**) &object->qdata, oldvalue, - (gpointer) ((gsize) oldvalue | OBJECT_FLOATING_FLAG))); + oldvalue = g_atomic_pointer_get (&object->qdata); + while (!g_atomic_pointer_compare_and_exchange_full ( + (void**) &object->qdata, oldvalue, + (void *) ((gsize) oldvalue | OBJECT_FLOATING_FLAG), + &oldvalue)) + ; return (gsize) oldvalue & OBJECT_FLOATING_FLAG; case -1: /* sink if possible */ - do - oldvalue = g_atomic_pointer_get (&object->qdata); - while (!g_atomic_pointer_compare_and_exchange ((void**) &object->qdata, oldvalue, - (gpointer) ((gsize) oldvalue & ~(gsize) OBJECT_FLOATING_FLAG))); + oldvalue = g_atomic_pointer_get (&object->qdata); + while (!g_atomic_pointer_compare_and_exchange_full ( + (void**) &object->qdata, oldvalue, + (void *) ((gsize) oldvalue & ~(gsize) OBJECT_FLOATING_FLAG), + &oldvalue)) + ; return (gsize) oldvalue & OBJECT_FLOATING_FLAG; default: /* check floating */ return 0 != ((gsize) g_atomic_pointer_get (&object->qdata) & OBJECT_FLOATING_FLAG);