|
Link Here
|
|
|
1 |
--- src/cairo-atomic-private.h.orig 2015-08-08 19:59:56 UTC |
| 2 |
+++ src/cairo-atomic-private.h |
| 3 |
@@ -81,8 +81,14 @@ _cairo_atomic_ptr_get (void **x) |
| 4 |
# define _cairo_atomic_int_inc(x) ((void) __sync_fetch_and_add(x, 1)) |
| 5 |
# define _cairo_atomic_int_dec(x) ((void) __sync_fetch_and_add(x, -1)) |
| 6 |
# define _cairo_atomic_int_dec_and_test(x) (__sync_fetch_and_add(x, -1) == 1) |
| 7 |
+#if defined(__FreeBSD__) |
| 8 |
+#include <machine/atomic.h> |
| 9 |
+# define _cairo_atomic_int_cmpxchg(x, oldv, newv) atomic_cmpset_rel_32 ((uint32_t *)x, (uint32_t)oldv, (uint32_t)newv) |
| 10 |
+# define _cairo_atomic_int_cmpxchg_return_old(x, oldv, newv) atomic_cmpset_rel_32 ((uint32_t *)x, (uint32_t)oldv, (uint32_t)newv) |
| 11 |
+#else |
| 12 |
# define _cairo_atomic_int_cmpxchg(x, oldv, newv) __sync_bool_compare_and_swap (x, oldv, newv) |
| 13 |
# define _cairo_atomic_int_cmpxchg_return_old(x, oldv, newv) __sync_val_compare_and_swap (x, oldv, newv) |
| 14 |
+#endif |
| 15 |
|
| 16 |
#if SIZEOF_VOID_P==SIZEOF_INT |
| 17 |
typedef int cairo_atomic_intptr_t; |
| 18 |
@@ -94,12 +100,19 @@ typedef long long cairo_atomic_intptr_t; |
| 19 |
#error No matching integer pointer type |
| 20 |
#endif |
| 21 |
|
| 22 |
+#if defined(__FreeBSD__) |
| 23 |
+# define _cairo_atomic_ptr_cmpxchg(x, oldv, newv) \ |
| 24 |
+ atomic_cmpset_rel_64 ((uint64_t *)x, (uint64_t)oldv, (uint64_t)newv) |
| 25 |
+# define _cairo_atomic_ptr_cmpxchg_return_old(x, oldv, newv) \ |
| 26 |
+ _cairo_atomic_intptr_to_voidptr (atomic_cmpset_rel_64 ((uint64_t *)x, (uint64_t)oldv, (uint64_t)newv)) |
| 27 |
+#else |
| 28 |
# define _cairo_atomic_ptr_cmpxchg(x, oldv, newv) \ |
| 29 |
__sync_bool_compare_and_swap ((cairo_atomic_intptr_t*)x, (cairo_atomic_intptr_t)oldv, (cairo_atomic_intptr_t)newv) |
| 30 |
|
| 31 |
# define _cairo_atomic_ptr_cmpxchg_return_old(x, oldv, newv) \ |
| 32 |
_cairo_atomic_intptr_to_voidptr (__sync_val_compare_and_swap ((cairo_atomic_intptr_t*)x, (cairo_atomic_intptr_t)oldv, (cairo_atomic_intptr_t)newv)) |
| 33 |
|
| 34 |
+#endif /* __FreeBSD__ */ |
| 35 |
#endif |
| 36 |
|
| 37 |
#if HAVE_LIB_ATOMIC_OPS |