From b82e7740c102afa7b9184b2556b887cf7a0211b0 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 21 Jun 2009 22:25:08 +0100 Subject: [PATCH] [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. --- build/configure.ac.system | 3 +++ src/cairo-atomic-private.h | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/build/configure.ac.system b/build/configure.ac.system index 07d30c2e3..30bcb8e3d 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 10860fe11..10c014ceb 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