[cairo-commit] 2 commits - src/cairo-atomic.c src/cairo-atomic-private.h src/cairo-surface.c
Chris Wilson
ickle at kemper.freedesktop.org
Fri Jun 5 10:36:41 PDT 2009
src/cairo-atomic-private.h | 6 ++++++
src/cairo-atomic.c | 13 +++++++++++++
src/cairo-surface.c | 6 +++---
3 files changed, 22 insertions(+), 3 deletions(-)
New commits:
commit 24e51dd2ee04884e1f6f9f527b6675ad5f883ee2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri Jun 5 18:34:29 2009 +0100
[atomic] Hide compiler warnings
Add uint variants of _cairo_atomic_int_*() to hide the compiler warnings
about sign conversions.
diff --git a/src/cairo-atomic-private.h b/src/cairo-atomic-private.h
index a1de13e..108cb39 100644
--- a/src/cairo-atomic-private.h
+++ b/src/cairo-atomic-private.h
@@ -95,6 +95,9 @@ _cairo_atomic_int_set (int *x, int value);
#endif
+#define _cairo_atomic_uint_get(x) _cairo_atomic_int_get(x)
+#define _cairo_atomic_uint_cmpxchg(x, oldv, newv) \
+ _cairo_atomic_int_cmpxchg((int *)x, oldv, newv)
#define _cairo_status_set_error(status, err) do { \
/* hide compiler warnings about cairo_status_t != int (gcc treats its as \
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 2a5fbc1..fdb25fa 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -187,7 +187,7 @@ cairo_surface_status (cairo_surface_t *surface)
}
slim_hidden_def (cairo_surface_status);
-static unsigned long
+static unsigned int
_cairo_surface_allocate_unique_id (void)
{
static unsigned int unique_id;
@@ -200,11 +200,11 @@ _cairo_surface_allocate_unique_id (void)
unsigned int old, id;
do {
- old = _cairo_atomic_int_get (&unique_id);
+ old = _cairo_atomic_uint_get (&unique_id);
id = old + 1;
if (id == 0)
id = 1;
- } while (! _cairo_atomic_int_cmpxchg (&unique_id, old, id));
+ } while (! _cairo_atomic_uint_cmpxchg (&unique_id, old, id));
return id;
#endif
commit 4ae5e2d44555a7219eb76ee187a8f588606c112f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri Jun 5 18:29:40 2009 +0100
[atomic] Provide mutex-based ptr cmpxchg
To handle those CPUs where we do not have an atomic cmpxchg.
diff --git a/src/cairo-atomic-private.h b/src/cairo-atomic-private.h
index 97e2e0f..a1de13e 100644
--- a/src/cairo-atomic-private.h
+++ b/src/cairo-atomic-private.h
@@ -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
diff --git a/src/cairo-atomic.c b/src/cairo-atomic.c
index c569000..777ba5c 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
More information about the cairo-commit
mailing list