mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-27 18:38:16 +02:00
[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.
This commit is contained in:
parent
a2d4fb5009
commit
b82e7740c1
2 changed files with 15 additions and 7 deletions
|
|
@ -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])
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue