diff options
author | Ryan Lortie <desrt@desrt.ca> | 2011-05-28 15:59:18 -0400 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2011-05-28 16:10:44 -0400 |
commit | 83821352657a9481dbff6ab04e8ae60566c17d5e (patch) | |
tree | 7303ad39e185c8354df294e62d716e0effee2ba9 /gobject | |
parent | 2fb57ff46f32316e991ab9f99daa5fce4885f097 (diff) |
glib: Rewrite gatomic.[ch]
- remove all inline assembly versions
- implement the atomic operations using either GCC intrinsics, the
Windows interlocked API or a mutex-based fallback
- drop gatomic-gcc.c since these are now defined in the header file.
Adjust Makefile.am accordingly.
- expand the set of operations: support 'get', 'set', 'compare and
exchange', 'add', 'or', and 'xor' for both integers and pointers
- deprecate g_atomic_int_exchange_and_add since g_atomic_int_add (as
with all the new arithmetic operations) now returns the prior value
- unify the use of macros: all functions are now wrapped in macros that
perform the proper casts and checks
- remove G_GNUC_MAY_ALIAS use; it was never required for the integer
operations (since casting between pointers that only vary in
signedness of the target is explicitly permitted) and we avoid the
need for the pointer operations by using simple 'void *' instead of
'gpointer *' (which caused the 'type-punned pointer' warning)
- provide function implementations of g_atomic_int_inc and
g_atomic_int_dec_and_test: these were strictly macros before
- improve the documentation to make it very clear exactly which types
of pointers these operations may be used with
- remove a few uses of the now-deprecated g_atomic_int_exchange_and_add
- drop initialisation of gatomic from gthread (by using a GStaticMutex
instead of a GMutex)
- update glib.symbols and documentation sections files
Closes #650823 and #650935
Diffstat (limited to 'gobject')
-rw-r--r-- | gobject/gobject.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gobject/gobject.c b/gobject/gobject.c index ead907195..33c978592 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -2654,7 +2654,7 @@ g_object_ref (gpointer _object) #endif /* G_ENABLE_DEBUG */ - old_val = g_atomic_int_exchange_and_add ((int *)&object->ref_count, 1); + old_val = g_atomic_int_add (&object->ref_count, 1); if (old_val == 1 && OBJECT_HAS_TOGGLE_REF (object)) toggle_refs_notify (object, FALSE); @@ -2735,7 +2735,7 @@ g_object_unref (gpointer _object) g_datalist_id_set_data (&object->qdata, quark_weak_refs, NULL); /* decrement the last reference */ - old_ref = g_atomic_int_exchange_and_add ((int *)&object->ref_count, -1); + old_ref = g_atomic_int_add (&object->ref_count, -1); TRACE (GOBJECT_OBJECT_UNREF(object,G_TYPE_FROM_INSTANCE(object),old_ref)); |