diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-06-05 18:29:40 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-06-05 18:29:40 +0100 |
commit | 4ae5e2d44555a7219eb76ee187a8f588606c112f (patch) | |
tree | d635ec49699126ed28e6885681b1c4ccb0fa9748 /src/cairo-atomic.c | |
parent | a1d0a06b6275cac3974be84919993e187394fe43 (diff) | |
download | cairo-4ae5e2d44555a7219eb76ee187a8f588606c112f.tar.gz |
[atomic] Provide mutex-based ptr cmpxchg
To handle those CPUs where we do not have an atomic cmpxchg.
Diffstat (limited to 'src/cairo-atomic.c')
-rw-r--r-- | src/cairo-atomic.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/cairo-atomic.c b/src/cairo-atomic.c index c569000cb..777ba5cdf 100644 --- a/src/cairo-atomic.c +++ b/src/cairo-atomic.c @@ -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 |