mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 05:18:01 +02:00
Use intptr_t for cairo_atomic_intptr_t
Since we now require C11 we can use intptr_t instead of figuring out the right int size.
This commit is contained in:
parent
24d00b6309
commit
8d0650bb60
1 changed files with 7 additions and 55 deletions
|
|
@ -45,12 +45,6 @@
|
|||
|
||||
#include <assert.h>
|
||||
|
||||
/* The autoconf on OpenBSD 4.5 produces the malformed constant name
|
||||
* SIZEOF_VOID__ rather than SIZEOF_VOID_P. Work around that here. */
|
||||
#if !defined(SIZEOF_VOID_P) && defined(SIZEOF_VOID__)
|
||||
# define SIZEOF_VOID_P SIZEOF_VOID__
|
||||
#endif
|
||||
|
||||
CAIRO_BEGIN_DECLS
|
||||
|
||||
/* C++11 atomic primitives were designed to be more flexible than the
|
||||
|
|
@ -97,15 +91,7 @@ _cairo_atomic_ptr_get (void **x)
|
|||
# define _cairo_atomic_int_dec(x) ((void) __atomic_fetch_sub(x, 1, __ATOMIC_SEQ_CST))
|
||||
# define _cairo_atomic_int_dec_and_test(x) (__atomic_fetch_sub(x, 1, __ATOMIC_SEQ_CST) == 1)
|
||||
|
||||
#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
|
||||
typedef intptr_t cairo_atomic_intptr_t;
|
||||
|
||||
static cairo_always_inline cairo_bool_t
|
||||
_cairo_atomic_int_cmpxchg_impl(cairo_atomic_int_t *x,
|
||||
|
|
@ -193,15 +179,7 @@ _cairo_atomic_ptr_get (void **x)
|
|||
# define _cairo_atomic_int_cmpxchg(x, oldv, newv) __sync_bool_compare_and_swap (x, oldv, newv)
|
||||
# define _cairo_atomic_int_cmpxchg_return_old(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
|
||||
typedef intptr_t cairo_atomic_intptr_t;
|
||||
|
||||
# define _cairo_atomic_ptr_cmpxchg(x, oldv, newv) \
|
||||
__sync_bool_compare_and_swap ((cairo_atomic_intptr_t*)x, (cairo_atomic_intptr_t)oldv, (cairo_atomic_intptr_t)newv)
|
||||
|
|
@ -227,15 +205,7 @@ typedef AO_t cairo_atomic_int_t;
|
|||
# define _cairo_atomic_int_dec_and_test(x) (AO_fetch_and_sub1_full(x) == 1)
|
||||
# define _cairo_atomic_int_cmpxchg(x, oldv, newv) AO_compare_and_swap_full(x, oldv, newv)
|
||||
|
||||
#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 intptr_t cairo_atomic_intptr_t;
|
||||
|
||||
# define _cairo_atomic_ptr_get(x) _cairo_atomic_intptr_to_voidptr (AO_load_full (x))
|
||||
# define _cairo_atomic_ptr_cmpxchg(x, oldv, newv) \
|
||||
|
|
@ -259,13 +229,13 @@ typedef int32_t cairo_atomic_int_t;
|
|||
# define _cairo_atomic_int_dec_and_test(x) (OSAtomicDecrement32Barrier (x) == 0)
|
||||
# define _cairo_atomic_int_cmpxchg(x, oldv, newv) OSAtomicCompareAndSwap32Barrier(oldv, newv, x)
|
||||
|
||||
typedef intptr_t cairo_atomic_intptr_t;
|
||||
|
||||
#if SIZEOF_VOID_P==4
|
||||
typedef int32_t cairo_atomic_intptr_t;
|
||||
# define _cairo_atomic_ptr_cmpxchg(x, oldv, newv) \
|
||||
OSAtomicCompareAndSwap32Barrier((cairo_atomic_intptr_t)oldv, (cairo_atomic_intptr_t)newv, (cairo_atomic_intptr_t *)x)
|
||||
|
||||
#elif SIZEOF_VOID_P==8
|
||||
typedef int64_t cairo_atomic_intptr_t;
|
||||
# define _cairo_atomic_ptr_cmpxchg(x, oldv, newv) \
|
||||
OSAtomicCompareAndSwap64Barrier((cairo_atomic_intptr_t)oldv, (cairo_atomic_intptr_t)newv, (cairo_atomic_intptr_t *)x)
|
||||
|
||||
|
|
@ -283,16 +253,7 @@ typedef int64_t cairo_atomic_intptr_t;
|
|||
#define HAS_ATOMIC_OPS 1
|
||||
|
||||
typedef int32_t 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 intptr_t cairo_atomic_intptr_t;
|
||||
|
||||
static cairo_always_inline cairo_atomic_int_t
|
||||
_cairo_atomic_int_get (cairo_atomic_int_t *x)
|
||||
|
|
@ -341,16 +302,7 @@ _cairo_atomic_ptr_cmpxchg_return_old (void **x, void *oldv, void *newv)
|
|||
#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 intptr_t cairo_atomic_intptr_t;
|
||||
|
||||
cairo_private void
|
||||
_cairo_atomic_int_inc (cairo_atomic_int_t *x);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue