[cairo-commit] src/cairo-atomic-private.h

Jinghua Luo jinghua at kemper.freedesktop.org
Mon Oct 19 07:31:32 PDT 2009


 src/cairo-atomic-private.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit ea39f0302a936711043aa6834ba0ab487736572b
Author: Luo Jinghua <sunmoon1997 at gmail.com>
Date:   Mon Oct 19 22:21:00 2009 +0800

    atomic: correct libatomic_ops version of _cairo_atomic_int_cmpxchg
    
    AO_compare_and_swap_full() doesn't have the same semantic as
    _cairo_atomic_int_cmpxchg(). The former returns a TRUE on success
    FALSE otherwise while the later returns the atomic value.

diff --git a/src/cairo-atomic-private.h b/src/cairo-atomic-private.h
index d2583a1..8532f62 100644
--- a/src/cairo-atomic-private.h
+++ b/src/cairo-atomic-private.h
@@ -91,7 +91,7 @@ typedef  AO_t cairo_atomic_int_t;
 
 # define _cairo_atomic_int_inc(x) ((void) AO_fetch_and_add1_full(x))
 # define _cairo_atomic_int_dec_and_test(x) (AO_fetch_and_sub1_full(x) == 1)
-# define _cairo_atomic_int_cmpxchg(x, oldv, newv) ((cairo_atomic_int_t) AO_compare_and_swap_full(x, oldv, newv))
+# define _cairo_atomic_int_cmpxchg(x, oldv, newv) ((cairo_atomic_int_t) AO_compare_and_swap_full(x, oldv, newv) ? oldv : *x)
 
 #if SIZEOF_VOID_P==SIZEOF_INT
 typedef unsigned int cairo_atomic_intptr_t;


More information about the cairo-commit mailing list