summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-05-20 21:54:16 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2010-05-20 21:57:58 +0100
commit97b4aeba44e5f4b23b3ed417b991570b46d4736e (patch)
tree32e99e0b873aa6d1552e1240c84501431a2f99fd
parent24e684c267404528b40fa49b55272d73bd44167d (diff)
atomic: Add memory barriers if required for intel primitives
-rw-r--r--src/cairo-atomic-private.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cairo-atomic-private.h b/src/cairo-atomic-private.h
index 572f8494..8d02ec94 100644
--- a/src/cairo-atomic-private.h
+++ b/src/cairo-atomic-private.h
@@ -59,8 +59,24 @@ CAIRO_BEGIN_DECLS
typedef int cairo_atomic_int_t;
+#ifdef ATOMIC_OP_NEEDS_MEMORY_BARRIER
+static cairo_always_inline cairo_atomic_int_t
+_cairo_atomic_int_get (cairo_atomic_int_t *x)
+{
+ __sync_synchronize ();
+ return *x;
+}
+
+static cairo_always_inline void *
+_cairo_atomic_ptr_get (void **x)
+{
+ __sync_synchronize ();
+ return *x;
+}
+#else
# define _cairo_atomic_int_get(x) (*x)
# define _cairo_atomic_ptr_get(x) (*x)
+#endif
# 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)