[atomic] Provide mutex-based ptr cmpxchg

To handle those CPUs where we do not have an atomic cmpxchg.
This commit is contained in:
Chris Wilson 2009-06-05 18:29:40 +01:00
parent a1d0a06b62
commit 4ae5e2d445
2 changed files with 16 additions and 0 deletions

View file

@ -72,6 +72,9 @@ _cairo_atomic_int_dec_and_test (int *x);
cairo_private int
_cairo_atomic_int_cmpxchg (int *x, int oldv, int newv);
cairo_private void *
_cairo_atomic_ptr_cmpxchg (void **x, void *oldv, void *newv);
#endif

View file

@ -71,6 +71,19 @@ _cairo_atomic_int_cmpxchg (int *x, int oldv, int newv)
return ret;
}
void *
_cairo_atomic_ptr_cmpxchg (void **x, void *oldv, void *newv)
{
void *ret;
CAIRO_MUTEX_LOCK (_cairo_atomic_mutex);
ret = *x;
if (ret == oldv)
*x = newv;
CAIRO_MUTEX_UNLOCK (_cairo_atomic_mutex);
return ret;
}
#endif
#ifdef ATOMIC_OP_NEEDS_MEMORY_BARRIER