[glib] Use g_atomic_pointer_or/and to set datalist flags
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Use g_atomic_pointer_or/and to set datalist flags
- Date: Sat, 4 Jun 2011 01:14:52 +0000 (UTC)
commit fca330dafa9a77edc58a30b6128eaf466d4a2ba7
Author: Alexander Larsson <alexl redhat com>
Date: Wed May 25 11:56:51 2011 +0200
Use g_atomic_pointer_or/and to set datalist flags
https://bugzilla.gnome.org/show_bug.cgi?id=650458
glib/gdataset.c | 20 ++++----------------
1 files changed, 4 insertions(+), 16 deletions(-)
---
diff --git a/glib/gdataset.c b/glib/gdataset.c
index c2582b9..3408558 100644
--- a/glib/gdataset.c
+++ b/glib/gdataset.c
@@ -992,16 +992,10 @@ void
g_datalist_set_flags (GData **datalist,
guint flags)
{
- gpointer oldvalue;
g_return_if_fail (datalist != NULL);
g_return_if_fail ((flags & ~G_DATALIST_FLAGS_MASK) == 0);
-
- do
- {
- oldvalue = g_atomic_pointer_get (datalist);
- }
- while (!g_atomic_pointer_compare_and_exchange ((void**) datalist, oldvalue,
- (gpointer) ((gsize) oldvalue | flags)));
+
+ g_atomic_pointer_or (datalist, (gsize)flags);
}
/**
@@ -1021,16 +1015,10 @@ void
g_datalist_unset_flags (GData **datalist,
guint flags)
{
- gpointer oldvalue;
g_return_if_fail (datalist != NULL);
g_return_if_fail ((flags & ~G_DATALIST_FLAGS_MASK) == 0);
-
- do
- {
- oldvalue = g_atomic_pointer_get (datalist);
- }
- while (!g_atomic_pointer_compare_and_exchange ((void**) datalist, oldvalue,
- (gpointer) ((gsize) oldvalue & ~(gsize) flags)));
+
+ g_atomic_pointer_and (datalist, ~(gsize)flags);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]