diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2007-10-25 10:24:01 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2007-11-05 08:51:06 +0000 |
commit | e60a7c39cdcdfd474c4f6cc3b4612870726f55dc (patch) | |
tree | e67aa051b8da51c00dba7cdacabbdc8b497e6fac /src/cairo-atomic-private.h | |
parent | 76667b4c2a4243a52ab0dbe372151a9ca7dfe931 (diff) | |
download | cairo-e60a7c39cdcdfd474c4f6cc3b4612870726f55dc.tar.gz |
[cairo-atomic] Check whether we can access int/pointers atomically.
Add a configure check to determine whether the host cpu can read/write
cairo_atomic_t without an explicit memory barrier, and update the macros
within cairo-atomic-private.h to reflect this knowledge.
Diffstat (limited to 'src/cairo-atomic-private.h')
-rw-r--r-- | src/cairo-atomic-private.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/cairo-atomic-private.h b/src/cairo-atomic-private.h index fbf1d9aea..85fe95626 100644 --- a/src/cairo-atomic-private.h +++ b/src/cairo-atomic-private.h @@ -51,9 +51,6 @@ typedef int cairo_atomic_int_t; # 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) -# define _cairo_atomic_int_get(x) (*x) -# define _cairo_atomic_int_set(x, value) ((*x) = value) - # define _cairo_atomic_int_cmpxchg(x, oldv, newv) __sync_val_compare_and_swap (x, oldv, newv) #else @@ -71,16 +68,29 @@ cairo_private cairo_bool_t _cairo_atomic_int_dec_and_test (int *x); cairo_private int +_cairo_atomic_int_cmpxchg (int *x, int oldv, int newv); + +#endif + + +#ifdef CAIRO_ATOMIC_OP_NEEDS_MEMORY_BARRIER + +# include "cairo-compiler-private.h" + +cairo_private int _cairo_atomic_int_get (int *x); cairo_private void _cairo_atomic_int_set (int *x, int value); -cairo_private int -_cairo_atomic_int_cmpxchg (int *x, int oldv, int newv); +#else + +# define _cairo_atomic_int_get(x) (*x) +# define _cairo_atomic_int_set(x, value) ((*x) = value) #endif + #define _cairo_status_set_error(status, err) do { \ /* hide compiler warnings about cairo_status_t != int (gcc treats its as \ * an unsigned integer instead, and about ignoring the return value. */ \ |