[cairo-commit] build/configure.ac.system src/cairo-atomic-private.h

Chris Wilson ickle at kemper.freedesktop.org
Sun Jun 21 14:27:36 PDT 2009


 build/configure.ac.system  |    3 +++
 src/cairo-atomic-private.h |   19 ++++++++++++-------
 2 files changed, 15 insertions(+), 7 deletions(-)

New commits:
commit b82e7740c102afa7b9184b2556b887cf7a0211b0
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jun 21 22:25:08 2009 +0100

    [atomic] Silence compiler warnings by defining an intptr_t
    
    Evaulate the integer sizes during configure to find one of the exact same
    size as a void* to use in the conversion of the atomic ptr cmpxchg to an
    atomic int cmpxchg.

diff --git a/build/configure.ac.system b/build/configure.ac.system
index 07d30c2..30bcb8e 100644
--- a/build/configure.ac.system
+++ b/build/configure.ac.system
@@ -11,6 +11,9 @@ CAIRO_BIGENDIAN
 CAIRO_CHECK_NATIVE_ATOMIC_PRIMITIVES
 CAIRO_CHECK_ATOMIC_OP_NEEDS_MEMORY_BARRIER
 AC_CHECK_SIZEOF(void *)
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long)
+AC_CHECK_SIZEOF(long long)
 AC_CHECK_SIZEOF(size_t)
 
 AC_MSG_CHECKING([for native Win32])
diff --git a/src/cairo-atomic-private.h b/src/cairo-atomic-private.h
index 10860fe..10c014c 100644
--- a/src/cairo-atomic-private.h
+++ b/src/cairo-atomic-private.h
@@ -55,14 +55,19 @@ typedef int cairo_atomic_int_t;
 # define _cairo_atomic_int_dec_and_test(x) (__sync_fetch_and_add(x, -1) == 1)
 # define _cairo_atomic_int_cmpxchg(x, oldv, newv) __sync_val_compare_and_swap (x, oldv, newv)
 
+#if SIZEOF_VOID_P==SIZEOF_INT
+typedef int cairo_atomic_intptr_t;
+#elif SIZEOF_VOID_P==SIZEOF_LONG
+typedef long cairo_atomic_intptr_t;
+#elif SIZEOF_VOID_P==SIZEOF_LONG_LONG
+typedef long long cairo_atomic_intptr_t;
+#else
+#error No matching integer pointer type
+#endif
+
 # define _cairo_atomic_ptr_cmpxchg(x, oldv, newv) \
-  (sizeof(void*) == sizeof(int) ?\
-    (void*)__sync_val_compare_and_swap ((int*)x, (int)oldv, (int)newv) :\
-   sizeof(void*) == sizeof(long) ?\
-    (void*)__sync_val_compare_and_swap ((long*)x, (long)oldv, (long)newv) :\
-   sizeof(void*) == sizeof(long long) ?\
-    (void*)__sync_val_compare_and_swap ((long long*)x, (long long)oldv, (long long)newv) :\
-   (void*)(oldv)/*impossible*/)
+    (void*)__sync_val_compare_and_swap ((cairo_atomic_intptr_t*)x, (cairo_atomic_intptr_t)oldv, (cairo_atomic_intptr_t)newv)
+
 #endif
 
 


More information about the cairo-commit mailing list