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

Chris Wilson ickle at kemper.freedesktop.org
Thu Apr 29 02:05:27 PDT 2010


 src/cairo-atomic-private.h |   27 ++++++++++++++++++++-------
 src/cairo-atomic.c         |   16 ++++++++--------
 2 files changed, 28 insertions(+), 15 deletions(-)

New commits:
commit aa495eac5a2db9b396eb1953eb112c733d0ababc
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Apr 29 10:04:18 2010 +0100

    atomic: Tweak for compilation x86.
    
    Missing definition of _cairo_atomic_ptr_get() used in the fallbacks.

diff --git a/src/cairo-atomic-private.h b/src/cairo-atomic-private.h
index 4fcb188..f97cead 100644
--- a/src/cairo-atomic-private.h
+++ b/src/cairo-atomic-private.h
@@ -58,6 +58,7 @@ CAIRO_BEGIN_DECLS
 typedef int cairo_atomic_int_t;
 
 # define _cairo_atomic_int_get(x) (*x)
+# define _cairo_atomic_ptr_get(x) (*x)
 
 # define _cairo_atomic_int_inc(x) ((void) __sync_fetch_and_add(x, 1))
 # define _cairo_atomic_int_dec_and_test(x) (__sync_fetch_and_add(x, -1) == 1)
@@ -144,16 +145,26 @@ typedef int64_t cairo_atomic_intptr_t;
 
 #ifndef HAS_ATOMIC_OPS
 
-typedef int cairo_atomic_int_t;
+#if SIZEOF_VOID_P==SIZEOF_INT
+typedef unsigned int cairo_atomic_intptr_t;
+#elif SIZEOF_VOID_P==SIZEOF_LONG
+typedef unsigned long cairo_atomic_intptr_t;
+#elif SIZEOF_VOID_P==SIZEOF_LONG_LONG
+typedef unsigned long long cairo_atomic_intptr_t;
+#else
+#error No matching integer pointer type
+#endif
+
+typedef cairo_atomic_intptr_t cairo_atomic_int_t;
 
 cairo_private void
-_cairo_atomic_int_inc (int *x);
+_cairo_atomic_int_inc (cairo_atomic_int_t *x);
 
 cairo_private cairo_bool_t
-_cairo_atomic_int_dec_and_test (int *x);
+_cairo_atomic_int_dec_and_test (cairo_atomic_int_t *x);
 
-cairo_private int
-_cairo_atomic_int_cmpxchg_return_old_impl (int *x, int oldv, int newv);
+cairo_private cairo_atomic_int_t
+_cairo_atomic_int_cmpxchg_return_old_impl (cairo_atomic_int_t *x, cairo_atomic_int_t oldv, cairo_atomic_int_t newv);
 
 cairo_private void *
 _cairo_atomic_ptr_cmpxchg_return_old_impl (void **x, void *oldv, void *newv);
@@ -162,10 +173,12 @@ _cairo_atomic_ptr_cmpxchg_return_old_impl (void **x, void *oldv, void *newv);
 #define _cairo_atomic_ptr_cmpxchg_return_old(x, oldv, newv) _cairo_atomic_ptr_cmpxchg_return_old_impl (x, oldv, newv)
 
 #ifdef ATOMIC_OP_NEEDS_MEMORY_BARRIER
-cairo_private int
-_cairo_atomic_int_get (int *x);
+cairo_private cairo_atomic_int_t
+_cairo_atomic_int_get (cairo_atomic_int_t *x);
+# define _cairo_atomic_ptr_get(x) (void *) _cairo_atomic_int_get((cairo_atomic_int_t *) x)
 #else
 # define _cairo_atomic_int_get(x) (*x)
+# define _cairo_atomic_ptr_get(x) (*x)
 #endif
 
 #else
diff --git a/src/cairo-atomic.c b/src/cairo-atomic.c
index 4347be1..909cfea 100644
--- a/src/cairo-atomic.c
+++ b/src/cairo-atomic.c
@@ -42,7 +42,7 @@ COMPILE_TIME_ASSERT(sizeof(void*) == sizeof(int) ||
 		    sizeof(void*) == sizeof(long long));
 #else
 void
-_cairo_atomic_int_inc (int *x)
+_cairo_atomic_int_inc (cairo_atomic_intptr_t *x)
 {
     CAIRO_MUTEX_LOCK (_cairo_atomic_mutex);
     *x += 1;
@@ -50,7 +50,7 @@ _cairo_atomic_int_inc (int *x)
 }
 
 cairo_bool_t
-_cairo_atomic_int_dec_and_test (int *x)
+_cairo_atomic_int_dec_and_test (cairo_atomic_intptr_t *x)
 {
     cairo_bool_t ret;
 
@@ -61,10 +61,10 @@ _cairo_atomic_int_dec_and_test (int *x)
     return ret;
 }
 
-int
-_cairo_atomic_int_cmpxchg_return_old_impl (int *x, int oldv, int newv)
+cairo_atomic_intptr_t
+_cairo_atomic_int_cmpxchg_return_old_impl (cairo_atomic_intptr_t *x, cairo_atomic_intptr_t oldv, cairo_atomic_intptr_t newv)
 {
-    int ret;
+    cairo_atomic_intptr_t ret;
 
     CAIRO_MUTEX_LOCK (_cairo_atomic_mutex);
     ret = *x;
@@ -90,10 +90,10 @@ _cairo_atomic_ptr_cmpxchg_return_old_impl (void **x, void *oldv, void *newv)
 }
 
 #ifdef ATOMIC_OP_NEEDS_MEMORY_BARRIER
-int
-_cairo_atomic_int_get (int *x)
+cairo_atomic_intptr_t
+_cairo_atomic_int_get (cairo_atomic_intptr_t *x)
 {
-    int ret;
+    cairo_atomic_intptr_t ret;
 
     CAIRO_MUTEX_LOCK (_cairo_atomic_mutex);
     ret = *x;


More information about the cairo-commit mailing list