summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2010-09-18 14:39:13 +0200
committerAndrea Canciani <ranma42@gmail.com>2010-09-18 14:39:13 +0200
commit7d3ff53110a7a5243961720c59d141e6b7e0d8f0 (patch)
treeb7b6e083e170b0db64814ce954f520576b50c9d8
parent6856cc7e8304c4d9307e53ebab5c812c3b713356 (diff)
-rw-r--r--src/Makefile.sources5
-rw-r--r--src/cairo-debug.c4
-rw-r--r--src/cairo-device-private.h4
-rw-r--r--src/cairo-device.c8
-rw-r--r--src/cairo-font-face.c2
-rw-r--r--src/cairo-ft-font.c28
-rw-r--r--src/cairo-image-surface.c5
-rw-r--r--src/cairo-misc.c9
-rw-r--r--src/cairo-mutex-impl-private.h278
-rw-r--r--src/cairo-mutex-list-private.h70
-rw-r--r--src/cairo-mutex-private.h67
-rw-r--r--src/cairo-mutex-type-private.h194
-rw-r--r--src/cairo-mutex.c82
-rw-r--r--src/cairo-pattern.c25
-rw-r--r--src/cairo-scaled-font-private.h4
-rw-r--r--src/cairo-scaled-font.c90
-rw-r--r--src/cairo-surface.c2
-rw-r--r--src/cairo-toy-font-face.c11
-rw-r--r--src/cairo-user-font.c4
-rw-r--r--src/cairo-xcb-connection.c22
-rw-r--r--src/cairo-xcb-screen.c10
-rw-r--r--src/cairo-xcb-shm.c18
-rw-r--r--src/cairo-xcb-surface-render.c4
-rw-r--r--src/cairo-xlib-display.c15
-rw-r--r--src/cairo-xlib-surface.c4
-rw-r--r--src/cairo.c11
-rw-r--r--src/cairoint.h1
-rw-r--r--src/drm/cairo-drm-intel.c20
-rw-r--r--src/drm/cairo-drm.c8
29 files changed, 141 insertions, 864 deletions
diff --git a/src/Makefile.sources b/src/Makefile.sources
index ccae6645d..89f9f065d 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -74,10 +74,6 @@ cairo_private = \
cairo-list-private.h \
cairo-malloc-private.h \
cairo-recording-surface-private.h \
- cairo-mutex-impl-private.h \
- cairo-mutex-list-private.h \
- cairo-mutex-private.h \
- cairo-mutex-type-private.h \
cairo-output-stream-private.h \
cairo-paginated-private.h \
cairo-paginated-surface-private.h \
@@ -136,7 +132,6 @@ cairo_sources = \
cairo-matrix.c \
cairo-recording-surface.c \
cairo-misc.c \
- cairo-mutex.c \
cairo-observer.c \
cairo-output-stream.c \
cairo-paginated-surface.c \
diff --git a/src/cairo-debug.c b/src/cairo-debug.c
index c95675318..4bb74db85 100644
--- a/src/cairo-debug.c
+++ b/src/cairo-debug.c
@@ -59,8 +59,6 @@
void
cairo_debug_reset_static_data (void)
{
- CAIRO_MUTEX_INITIALIZE ();
-
_cairo_scaled_font_map_destroy ();
_cairo_toy_font_face_reset_static_data ();
@@ -84,8 +82,6 @@ cairo_debug_reset_static_data (void)
#endif
_cairo_reset_static_data ();
-
- CAIRO_MUTEX_FINALIZE ();
}
#if HAVE_VALGRIND
diff --git a/src/cairo-device-private.h b/src/cairo-device-private.h
index 6eb44f3b6..cd309ad50 100644
--- a/src/cairo-device-private.h
+++ b/src/cairo-device-private.h
@@ -37,9 +37,9 @@
#define _CAIRO_DEVICE_PRIVATE_H_
#include "cairo-compiler-private.h"
-#include "cairo-mutex-private.h"
#include "cairo-reference-count-private.h"
#include "cairo-types-private.h"
+#include "simpleops/mutex/simpleops-mutex.h"
struct _cairo_device {
cairo_reference_count_t ref_count;
@@ -48,7 +48,7 @@ struct _cairo_device {
const cairo_device_backend_t *backend;
- cairo_recursive_mutex_t mutex;
+ simpleops_mutex_t mutex;
unsigned mutex_depth;
cairo_bool_t finished;
diff --git a/src/cairo-device.c b/src/cairo-device.c
index 15b048477..66a7c4b8c 100644
--- a/src/cairo-device.c
+++ b/src/cairo-device.c
@@ -171,7 +171,7 @@ _cairo_device_init (cairo_device_t *device,
device->backend = backend;
- CAIRO_RECURSIVE_MUTEX_INIT (device->mutex);
+ simpleops_mutex_init_recursive (&device->mutex);
device->mutex_depth = 0;
device->finished = FALSE;
@@ -332,7 +332,7 @@ cairo_device_destroy (cairo_device_t *device)
cairo_device_finish (device);
assert (device->mutex_depth == 0);
- CAIRO_MUTEX_FINI (device->mutex);
+ simpleops_mutex_fini (&device->mutex);
user_data = device->user_data;
@@ -408,7 +408,7 @@ cairo_device_acquire (cairo_device_t *device)
if (unlikely (device->finished))
return _cairo_device_set_error (device, CAIRO_STATUS_SURFACE_FINISHED); /* XXX */
- CAIRO_MUTEX_LOCK (device->mutex);
+ simpleops_mutex_lock (&device->mutex);
if (device->mutex_depth++ == 0) {
if (device->backend->lock != NULL)
device->backend->lock (device);
@@ -440,7 +440,7 @@ cairo_device_release (cairo_device_t *device)
device->backend->unlock (device);
}
- CAIRO_MUTEX_UNLOCK (device->mutex);
+ simpleops_mutex_unlock (&device->mutex);
}
slim_hidden_def (cairo_device_release);
diff --git a/src/cairo-font-face.c b/src/cairo-font-face.c
index a66054ead..4e9d2ed11 100644
--- a/src/cairo-font-face.c
+++ b/src/cairo-font-face.c
@@ -86,8 +86,6 @@ void
_cairo_font_face_init (cairo_font_face_t *font_face,
const cairo_font_face_backend_t *backend)
{
- CAIRO_MUTEX_INITIALIZE ();
-
font_face->status = CAIRO_STATUS_SUCCESS;
CAIRO_REFERENCE_COUNT_INIT (&font_face->ref_count, 1);
font_face->backend = backend;
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 67eb2758e..4591fa7da 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -153,7 +153,7 @@ struct _cairo_ft_unscaled_font {
cairo_matrix_t current_shape;
FT_Matrix Current_Shape;
- cairo_mutex_t mutex;
+ simpleops_mutex_t mutex;
int lock_count;
cairo_ft_font_face_t *faces; /* Linked list of faces for this font */
@@ -222,7 +222,7 @@ typedef struct _cairo_ft_unscaled_font_map {
} cairo_ft_unscaled_font_map_t;
static cairo_ft_unscaled_font_map_t *cairo_ft_unscaled_font_map = NULL;
-
+static simpleops_mutex_t _cairo_ft_unscaled_font_map_mutex;
static void
_font_map_release_face_lock_held (cairo_ft_unscaled_font_map_t *font_map,
@@ -295,10 +295,10 @@ _cairo_ft_unscaled_font_map_destroy (void)
{
cairo_ft_unscaled_font_map_t *font_map;
- CAIRO_MUTEX_LOCK (_cairo_ft_unscaled_font_map_mutex);
+ simpleops_mutex_lock (&_cairo_ft_unscaled_font_map_mutex);
font_map = cairo_ft_unscaled_font_map;
cairo_ft_unscaled_font_map = NULL;
- CAIRO_MUTEX_UNLOCK (_cairo_ft_unscaled_font_map_mutex);
+ simpleops_mutex_unlock (&_cairo_ft_unscaled_font_map_mutex);
if (font_map != NULL) {
_cairo_hash_table_foreach (font_map->hash_table,
@@ -317,11 +317,11 @@ _cairo_ft_unscaled_font_map_destroy (void)
static cairo_ft_unscaled_font_map_t *
_cairo_ft_unscaled_font_map_lock (void)
{
- CAIRO_MUTEX_LOCK (_cairo_ft_unscaled_font_map_mutex);
+ simpleops_mutex_lock (&_cairo_ft_unscaled_font_map_mutex);
if (unlikely (cairo_ft_unscaled_font_map == NULL)) {
if (unlikely (_cairo_ft_unscaled_font_map_create ())) {
- CAIRO_MUTEX_UNLOCK (_cairo_ft_unscaled_font_map_mutex);
+ simpleops_mutex_unlock (&_cairo_ft_unscaled_font_map_mutex);
return NULL;
}
}
@@ -332,7 +332,7 @@ _cairo_ft_unscaled_font_map_lock (void)
static void
_cairo_ft_unscaled_font_map_unlock (void)
{
- CAIRO_MUTEX_UNLOCK (_cairo_ft_unscaled_font_map_mutex);
+ simpleops_mutex_unlock (&_cairo_ft_unscaled_font_map_mutex);
}
static void
@@ -405,7 +405,7 @@ _cairo_ft_unscaled_font_init (cairo_ft_unscaled_font_t *unscaled,
}
unscaled->have_scale = FALSE;
- CAIRO_MUTEX_INIT (unscaled->mutex);
+ simpleops_mutex_init (&unscaled->mutex);
unscaled->lock_count = 0;
unscaled->faces = NULL;
@@ -434,7 +434,7 @@ _cairo_ft_unscaled_font_fini (cairo_ft_unscaled_font_t *unscaled)
unscaled->filename = NULL;
}
- CAIRO_MUTEX_FINI (unscaled->mutex);
+ simpleops_mutex_fini (&unscaled->mutex);
}
static int
@@ -627,7 +627,7 @@ _cairo_ft_unscaled_font_lock_face (cairo_ft_unscaled_font_t *unscaled)
cairo_ft_unscaled_font_map_t *font_map;
FT_Face face = NULL;
- CAIRO_MUTEX_LOCK (unscaled->mutex);
+ simpleops_mutex_lock (&unscaled->mutex);
unscaled->lock_count++;
if (unscaled->face)
@@ -661,7 +661,7 @@ _cairo_ft_unscaled_font_lock_face (cairo_ft_unscaled_font_t *unscaled)
&face) != FT_Err_Ok)
{
unscaled->lock_count--;
- CAIRO_MUTEX_UNLOCK (unscaled->mutex);
+ simpleops_mutex_unlock (&unscaled->mutex);
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -683,7 +683,7 @@ _cairo_ft_unscaled_font_unlock_face (cairo_ft_unscaled_font_t *unscaled)
unscaled->lock_count--;
- CAIRO_MUTEX_UNLOCK (unscaled->mutex);
+ simpleops_mutex_unlock (&unscaled->mutex);
}
@@ -3155,7 +3155,7 @@ cairo_ft_scaled_font_lock_face (cairo_scaled_font_t *abstract_font)
* opportunity for creating deadlock. This is obviously unsafe,
* but as documented, the user must add manual locking when using
* this function. */
- CAIRO_MUTEX_UNLOCK (scaled_font->unscaled->mutex);
+ simpleops_mutex_unlock (&scaled_font->unscaled->mutex);
return face;
}
@@ -3186,7 +3186,7 @@ cairo_ft_scaled_font_unlock_face (cairo_scaled_font_t *abstract_font)
* cairo_ft_scaled_font_lock_face, so we have to acquire it again
* as _cairo_ft_unscaled_font_unlock_face expects it to be held
* when we call into it. */
- CAIRO_MUTEX_LOCK (scaled_font->unscaled->mutex);
+ simpleops_mutex_lock (&scaled_font->unscaled->mutex);
_cairo_ft_unscaled_font_unlock_face (scaled_font->unscaled);
}
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 1ac219daf..d9e8b26d7 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -1003,6 +1003,7 @@ static struct {
pixman_image_t *image;
} cache[16];
static int n_cached;
+static simpleops_mutex_t _cairo_image_solid_cache_mutex;
void
_cairo_image_reset_static_data ()
@@ -1056,7 +1057,7 @@ _pixman_image_for_solid (const cairo_solid_pattern_t *pattern)
}
#endif
- CAIRO_MUTEX_LOCK (_cairo_image_solid_cache_mutex);
+ simpleops_mutex_lock (&_cairo_image_solid_cache_mutex);
for (i = 0; i < n_cached; i++) {
if (_cairo_color_equal (&cache[i].color, &pattern->color)) {
image = pixman_image_ref (cache[i].image);
@@ -1083,7 +1084,7 @@ _pixman_image_for_solid (const cairo_solid_pattern_t *pattern)
cache[i].color = pattern->color;
UNLOCK:
- CAIRO_MUTEX_UNLOCK (_cairo_image_solid_cache_mutex);
+ simpleops_mutex_unlock (&_cairo_image_solid_cache_mutex);
return image;
}
diff --git a/src/cairo-misc.c b/src/cairo-misc.c
index 603725955..4928be82e 100644
--- a/src/cairo-misc.c
+++ b/src/cairo-misc.c
@@ -829,6 +829,7 @@ typedef struct _cairo_intern_string {
} cairo_intern_string_t;
static cairo_hash_table_t *_cairo_intern_string_ht;
+static simpleops_mutex_t _cairo_intern_string_mutex;
static unsigned long
_intern_string_hash (const char *str, int len)
@@ -870,7 +871,7 @@ _cairo_intern_string (const char **str_inout, int len)
tmpl.len = len;
tmpl.string = (char *) str;
- CAIRO_MUTEX_LOCK (_cairo_intern_string_mutex);
+ simpleops_mutex_lock (&_cairo_intern_string_mutex);
if (_cairo_intern_string_ht == NULL) {
_cairo_intern_string_ht = _cairo_hash_table_create (_intern_string_equal);
if (unlikely (_cairo_intern_string_ht == NULL)) {
@@ -905,7 +906,7 @@ _cairo_intern_string (const char **str_inout, int len)
*str_inout = istring->string;
BAIL:
- CAIRO_MUTEX_UNLOCK (_cairo_intern_string_mutex);
+ simpleops_mutex_unlock (&_cairo_intern_string_mutex);
return status;
}
@@ -919,7 +920,7 @@ _intern_string_pluck (void *entry, void *closure)
void
_cairo_intern_string_reset_static_data (void)
{
- CAIRO_MUTEX_LOCK (_cairo_intern_string_mutex);
+ simpleops_mutex_lock (&_cairo_intern_string_mutex);
if (_cairo_intern_string_ht != NULL) {
_cairo_hash_table_foreach (_cairo_intern_string_ht,
_intern_string_pluck,
@@ -927,5 +928,5 @@ _cairo_intern_string_reset_static_data (void)
_cairo_hash_table_destroy(_cairo_intern_string_ht);
_cairo_intern_string_ht = NULL;
}
- CAIRO_MUTEX_UNLOCK (_cairo_intern_string_mutex);
+ simpleops_mutex_unlock (&_cairo_intern_string_mutex);
}
diff --git a/src/cairo-mutex-impl-private.h b/src/cairo-mutex-impl-private.h
deleted file mode 100644
index 25223f3ea..000000000
--- a/src/cairo-mutex-impl-private.h
+++ /dev/null
@@ -1,278 +0,0 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005,2007 Red Hat, Inc.
- * Copyright © 2007 Mathias Hasselmann
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Mathias Hasselmann <mathias.hasselmann@gmx.de>
- * Behdad Esfahbod <behdad@behdad.org>
- */
-
-#ifndef CAIRO_MUTEX_IMPL_PRIVATE_H
-#define CAIRO_MUTEX_IMPL_PRIVATE_H
-
-#include "cairo.h"
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#if HAVE_LOCKDEP
-#include <lockdep.h>
-#endif
-
-/* A fully qualified no-operation statement */
-#define CAIRO_MUTEX_IMPL_NOOP do {/*no-op*/} while (0)
-/* And one that evaluates its argument once */
-#define CAIRO_MUTEX_IMPL_NOOP1(expr) do { (void)(expr); } while (0)
-/* Note: 'if (expr) {}' is an alternative to '(void)(expr);' that will 'use' the
- * result of __attribute__((warn_used_result)) functions. */
-
-/* Cairo mutex implementation:
- *
- * Any new mutex implementation needs to do the following:
- *
- * - Condition on the right header or feature. Headers are
- * preferred as eg. you still can use win32 mutex implementation
- * on a win32 system even if you do not compile the win32
- * surface/backend.
- *
- * - typedef #cairo_mutex_impl_t to the proper mutex type on your target
- * system. Note that you may or may not need to use a pointer,
- * depending on what kinds of initialization your mutex
- * implementation supports. No trailing semicolon needed.
- * You should be able to compile the following snippet (don't try
- * running it):
- *
- * <programlisting>
- * cairo_mutex_impl_t _cairo_some_mutex;
- * </programlisting>
- *
- * - #define %CAIRO_MUTEX_IMPL_<NAME> 1 with suitable name for your platform. You
- * can later use this symbol in cairo-system.c.
- *
- * - #define CAIRO_MUTEX_IMPL_LOCK(mutex) and CAIRO_MUTEX_IMPL_UNLOCK(mutex) to
- * proper statement to lock/unlock the mutex object passed in.
- * You can (and should) assume that the mutex is already
- * initialized, and is-not-already-locked/is-locked,
- * respectively. Use the "do { ... } while (0)" idiom if necessary.
- * No trailing semicolons are needed (in any macro you define here).
- * You should be able to compile the following snippet:
- *
- * <programlisting>
- * cairo_mutex_impl_t _cairo_some_mutex;
- *
- * if (1)
- * CAIRO_MUTEX_IMPL_LOCK (_cairo_some_mutex);
- * else
- * CAIRO_MUTEX_IMPL_UNLOCK (_cairo_some_mutex);
- * </programlisting>
- *
- * - #define %CAIRO_MUTEX_IMPL_NIL_INITIALIZER to something that can
- * initialize the #cairo_mutex_impl_t type you defined. Most of the
- * time one of 0, %NULL, or {} works. At this point
- * you should be able to compile the following snippet:
- *
- * <programlisting>
- * cairo_mutex_impl_t _cairo_some_mutex = CAIRO_MUTEX_IMPL_NIL_INITIALIZER;
- *
- * if (1)
- * CAIRO_MUTEX_IMPL_LOCK (_cairo_some_mutex);
- * else
- * CAIRO_MUTEX_IMPL_UNLOCK (_cairo_some_mutex);
- * </programlisting>
- *
- * - If the above code is not enough to initialize a mutex on
- * your platform, #define CAIRO_MUTEX_IMPL_INIT(mutex) to statement
- * to initialize the mutex (allocate resources, etc). Such that
- * you should be able to compile AND RUN the following snippet:
- *
- * <programlisting>
- * cairo_mutex_impl_t _cairo_some_mutex = CAIRO_MUTEX_IMPL_NIL_INITIALIZER;
- *
- * CAIRO_MUTEX_IMPL_INIT (_cairo_some_mutex);
- *
- * if (1)
- * CAIRO_MUTEX_IMPL_LOCK (_cairo_some_mutex);
- * else
- * CAIRO_MUTEX_IMPL_UNLOCK (_cairo_some_mutex);
- * </programlisting>
- *
- * - If you define CAIRO_MUTEX_IMPL_INIT(mutex), cairo will use it to
- * initialize all static mutex'es. If for any reason that should
- * not happen (eg. %CAIRO_MUTEX_IMPL_INIT is just a faster way than
- * what cairo does using %CAIRO_MUTEX_IMPL_NIL_INITIALIZER), then
- * <programlisting>
- * #define CAIRO_MUTEX_IMPL_INITIALIZE() CAIRO_MUTEX_IMPL_NOOP
- * </programlisting>
- *
- * - If your system supports freeing a mutex object (deallocating
- * resources, etc), then #define CAIRO_MUTEX_IMPL_FINI(mutex) to do
- * that.
- *
- * - If you define CAIRO_MUTEX_IMPL_FINI(mutex), cairo will use it to
- * define a finalizer function to finalize all static mutex'es.
- * However, it's up to you to call CAIRO_MUTEX_IMPL_FINALIZE() at
- * proper places, eg. when the system is unloading the cairo library.
- * So, if for any reason finalizing static mutex'es is not needed
- * (eg. you never call CAIRO_MUTEX_IMPL_FINALIZE()), then
- * <programlisting>
- * #define CAIRO_MUTEX_IMPL_FINALIZE() CAIRO_MUTEX_IMPL_NOOP
- * </programlisting>
- *
- * - That is all. If for any reason you think the above API is
- * not enough to implement #cairo_mutex_impl_t on your system, please
- * stop and write to the cairo mailing list about it. DO NOT
- * poke around cairo-mutex-private.h for possible solutions.
- */
-
-#if CAIRO_NO_MUTEX
-
-/* No mutexes */
-
- typedef int cairo_mutex_impl_t;
-
-# define CAIRO_MUTEX_IMPL_NO 1
-# define CAIRO_MUTEX_IMPL_INITIALIZE() CAIRO_MUTEX_IMPL_NOOP
-# define CAIRO_MUTEX_IMPL_LOCK(mutex) CAIRO_MUTEX_IMPL_NOOP1(mutex)
-# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) CAIRO_MUTEX_IMPL_NOOP1(mutex)
-# define CAIRO_MUTEX_IMPL_NIL_INITIALIZER 0
-
-# define CAIRO_MUTEX_HAS_RECURSIVE_IMPL 1
-
- typedef int cairo_recursive_mutex_impl_t;
-
-# define CAIRO_RECURSIVE_MUTEX_IMPL_INIT(mutex)
-# define CAIRO_RECURSIVE_MUTEX_IMPL_NIL_INITIALIZER 0
-
-#elif defined(_WIN32) /******************************************************/
-
-#define WIN32_LEAN_AND_MEAN
-/* We require Windows 2000 features such as ETO_PDY */
-#if !defined(WINVER) || (WINVER < 0x0500)
-# define WINVER 0x0500
-#endif
-#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
-# define _WIN32_WINNT 0x0500
-#endif
-
-# include <windows.h>
-
- typedef CRITICAL_SECTION cairo_mutex_impl_t;
-
-# define CAIRO_MUTEX_IMPL_WIN32 1
-# define CAIRO_MUTEX_IMPL_LOCK(mutex) EnterCriticalSection (&(mutex))
-# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) LeaveCriticalSection (&(mutex))
-# define CAIRO_MUTEX_IMPL_INIT(mutex) InitializeCriticalSection (&(mutex))
-# define CAIRO_MUTEX_IMPL_FINI(mutex) DeleteCriticalSection (&(mutex))
-# define CAIRO_MUTEX_IMPL_NIL_INITIALIZER { NULL, 0, 0, NULL, NULL, 0 }
-
-#elif defined __OS2__ /******************************************************/
-
-# define INCL_BASE
-# define INCL_PM
-# include <os2.h>
-
- typedef HMTX cairo_mutex_impl_t;
-
-# define CAIRO_MUTEX_IMPL_OS2 1
-# define CAIRO_MUTEX_IMPL_LOCK(mutex) DosRequestMutexSem(mutex, SEM_INDEFINITE_WAIT)
-# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) DosReleaseMutexSem(mutex)
-# define CAIRO_MUTEX_IMPL_INIT(mutex) DosCreateMutexSem (NULL, &(mutex), 0L, FALSE)
-# define CAIRO_MUTEX_IMPL_FINI(mutex) DosCloseMutexSem (mutex)
-# define CAIRO_MUTEX_IMPL_NIL_INITIALIZER 0
-
-#elif CAIRO_HAS_BEOS_SURFACE /***********************************************/
-
- typedef BLocker* cairo_mutex_impl_t;
-
-# define CAIRO_MUTEX_IMPL_BEOS 1
-# define CAIRO_MUTEX_IMPL_LOCK(mutex) (mutex)->Lock()
-# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) (mutex)->Unlock()
-# define CAIRO_MUTEX_IMPL_INIT(mutex) (mutex) = new BLocker()
-# define CAIRO_MUTEX_IMPL_FINI(mutex) delete (mutex)
-# define CAIRO_MUTEX_IMPL_NIL_INITIALIZER NULL
-
-#elif CAIRO_HAS_PTHREAD /* and finally if there are no native mutexes ********/
-
-# include <pthread.h>
-
- typedef pthread_mutex_t cairo_mutex_impl_t;
- typedef pthread_mutex_t cairo_recursive_mutex_impl_t;
-
-# define CAIRO_MUTEX_IMPL_PTHREAD 1
-#if HAVE_LOCKDEP
-/* expose all mutexes to the validator */
-# define CAIRO_MUTEX_IMPL_INIT(mutex) pthread_mutex_init (&(mutex), NULL)
-#endif
-# define CAIRO_MUTEX_IMPL_LOCK(mutex) pthread_mutex_lock (&(mutex))
-# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) pthread_mutex_unlock (&(mutex))
-#if HAVE_LOCKDEP
-# define CAIRO_MUTEX_IS_LOCKED(mutex) LOCKDEP_IS_LOCKED (&(mutex))
-# define CAIRO_MUTEX_IS_UNLOCKED(mutex) LOCKDEP_IS_UNLOCKED (&(mutex))
-#endif
-# define CAIRO_MUTEX_IMPL_FINI(mutex) pthread_mutex_destroy (&(mutex))
-#if ! HAVE_LOCKDEP
-# define CAIRO_MUTEX_IMPL_FINALIZE() CAIRO_MUTEX_IMPL_NOOP
-#endif
-# define CAIRO_MUTEX_IMPL_NIL_INITIALIZER PTHREAD_MUTEX_INITIALIZER
-
-# define CAIRO_MUTEX_HAS_RECURSIVE_IMPL 1
-# define CAIRO_RECURSIVE_MUTEX_IMPL_INIT(mutex) do { \
- pthread_mutexattr_t attr; \
- pthread_mutexattr_init (&attr); \
- pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); \
- pthread_mutex_init (&(mutex), &attr); \
- pthread_mutexattr_destroy (&attr); \
-} while (0)
-# define CAIRO_RECURSIVE_MUTEX_IMPL_NIL_INITIALIZER PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-
-#else /**********************************************************************/
-
-# error "XXX: No mutex implementation found. Cairo will not work with multiple threads. Define CAIRO_NO_MUTEX to 1 to acknowledge and accept this limitation and compile cairo without thread-safety support."
-
-#endif
-
-/* By default mutex implementations are assumed to be recursive */
-#if ! CAIRO_MUTEX_HAS_RECURSIVE_IMPL
-
-# define CAIRO_MUTEX_HAS_RECURSIVE_IMPL 1
-
- typedef cairo_mutex_impl_t cairo_recursive_mutex_impl_t;
-
-# define CAIRO_RECURSIVE_MUTEX_IMPL_INIT(mutex) CAIRO_MUTEX_IMPL_INIT(mutex)
-# define CAIRO_RECURSIVE_MUTEX_IMPL_NIL_INITIALIZER CAIRO_MUTEX_IMPL_NIL_INITIALIZER
-
-#endif
-
-#endif
diff --git a/src/cairo-mutex-list-private.h b/src/cairo-mutex-list-private.h
deleted file mode 100644
index 2ca43d231..000000000
--- a/src/cairo-mutex-list-private.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007 Mathias Hasselmann
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * Contributor(s):
- * Mathias Hasselmann <mathias.hasselmann@gmx.de>
- */
-
-#ifndef CAIRO_FEATURES_H
-/* This block is to just make this header file standalone */
-#define CAIRO_MUTEX_DECLARE(mutex)
-#endif
-
-CAIRO_MUTEX_DECLARE (_cairo_pattern_solid_surface_cache_lock)
-
-CAIRO_MUTEX_DECLARE (_cairo_image_solid_cache_mutex)
-
-CAIRO_MUTEX_DECLARE (_cairo_error_mutex)
-CAIRO_MUTEX_DECLARE (_cairo_toy_font_face_mutex)
-CAIRO_MUTEX_DECLARE (_cairo_intern_string_mutex)
-CAIRO_MUTEX_DECLARE (_cairo_scaled_font_map_mutex)
-CAIRO_MUTEX_DECLARE (_cairo_scaled_glyph_page_cache_mutex)
-CAIRO_MUTEX_DECLARE (_cairo_scaled_font_error_mutex)
-
-#if CAIRO_HAS_FT_FONT
-CAIRO_MUTEX_DECLARE (_cairo_ft_unscaled_font_map_mutex)
-#endif
-
-#if CAIRO_HAS_XLIB_SURFACE
-CAIRO_MUTEX_DECLARE (_cairo_xlib_display_mutex)
-#endif
-
-#if CAIRO_HAS_XCB_SURFACE
-CAIRO_MUTEX_DECLARE (_cairo_xcb_connections_mutex)
-#endif
-
-#if CAIRO_HAS_GL_SURFACE
-CAIRO_MUTEX_DECLARE (_cairo_gl_context_mutex)
-#endif
-
-#if CAIRO_HAS_DRM_SURFACE
-CAIRO_MUTEX_DECLARE (_cairo_drm_device_mutex)
-#endif
-/* Undefine, to err on unintended inclusion */
-#undef CAIRO_MUTEX_DECLARE
diff --git a/src/cairo-mutex-private.h b/src/cairo-mutex-private.h
deleted file mode 100644
index 61a7160a0..000000000
--- a/src/cairo-mutex-private.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005,2007 Red Hat, Inc.
- * Copyright © 2007 Mathias Hasselmann
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Mathias Hasselmann <mathias.hasselmann@gmx.de>
- * Behdad Esfahbod <behdad@behdad.org>
- */
-
-#ifndef CAIRO_MUTEX_PRIVATE_H
-#define CAIRO_MUTEX_PRIVATE_H
-
-#include "cairo-mutex-type-private.h"
-
-CAIRO_BEGIN_DECLS
-
-#if _CAIRO_MUTEX_IMPL_USE_STATIC_INITIALIZER
-cairo_private void _cairo_mutex_initialize (void);
-#endif
-#if _CAIRO_MUTEX_IMPL_USE_STATIC_FINALIZER
-cairo_private void _cairo_mutex_finalize (void);
-#endif
-/* only if using static initializer and/or finalizer define the boolean */
-#if _CAIRO_MUTEX_IMPL_USE_STATIC_INITIALIZER || _CAIRO_MUTEX_IMPL_USE_STATIC_FINALIZER
- cairo_private extern cairo_bool_t _cairo_mutex_initialized;
-#endif
-
-/* Finally, extern the static mutexes and undef */
-
-#define CAIRO_MUTEX_DECLARE(mutex) cairo_private extern cairo_mutex_t mutex;
-#include "cairo-mutex-list-private.h"
-#undef CAIRO_MUTEX_DECLARE
-
-CAIRO_END_DECLS
-
-#endif
diff --git a/src/cairo-mutex-type-private.h b/src/cairo-mutex-type-private.h
deleted file mode 100644
index e8c493985..000000000
--- a/src/cairo-mutex-type-private.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005,2007 Red Hat, Inc.
- * Copyright © 2007 Mathias Hasselmann
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Mathias Hasselmann <mathias.hasselmann@gmx.de>
- * Behdad Esfahbod <behdad@behdad.org>
- */
-
-#ifndef CAIRO_MUTEX_TYPE_PRIVATE_H
-#define CAIRO_MUTEX_TYPE_PRIVATE_H
-
-#include "cairo-compiler-private.h"
-#include "cairo-mutex-impl-private.h"
-
-/* Only the following four are mandatory at this point */
-#ifndef CAIRO_MUTEX_IMPL_LOCK
-# error "CAIRO_MUTEX_IMPL_LOCK not defined. Check cairo-mutex-impl-private.h."
-#endif
-#ifndef CAIRO_MUTEX_IMPL_UNLOCK
-# error "CAIRO_MUTEX_IMPL_UNLOCK not defined. Check cairo-mutex-impl-private.h."
-#endif
-#ifndef CAIRO_MUTEX_IMPL_NIL_INITIALIZER
-# error "CAIRO_MUTEX_IMPL_NIL_INITIALIZER not defined. Check cairo-mutex-impl-private.h."
-#endif
-#ifndef CAIRO_RECURSIVE_MUTEX_IMPL_INIT
-# error "CAIRO_RECURSIVE_MUTEX_IMPL_INIT not defined. Check cairo-mutex-impl-private.h."
-#endif
-
-
-/* make sure implementations don't fool us: we decide these ourself */
-#undef _CAIRO_MUTEX_IMPL_USE_STATIC_INITIALIZER
-#undef _CAIRO_MUTEX_IMPL_USE_STATIC_FINALIZER
-
-
-#ifdef CAIRO_MUTEX_IMPL_INIT
-
-/* If %CAIRO_MUTEX_IMPL_INIT is defined, we may need to initialize all
- * static mutex'es. */
-# ifndef CAIRO_MUTEX_IMPL_INITIALIZE
-# define CAIRO_MUTEX_IMPL_INITIALIZE() do { \
- if (!_cairo_mutex_initialized) \
- _cairo_mutex_initialize (); \
- } while(0)
-
-/* and make sure we implement the above */
-# define _CAIRO_MUTEX_IMPL_USE_STATIC_INITIALIZER 1
-# endif /* CAIRO_MUTEX_IMPL_INITIALIZE */
-
-#else /* no CAIRO_MUTEX_IMPL_INIT */
-
-/* Otherwise we probably don't need to initialize static mutex'es, */
-# ifndef CAIRO_MUTEX_IMPL_INITIALIZE
-# define CAIRO_MUTEX_IMPL_INITIALIZE() CAIRO_MUTEX_IMPL_NOOP
-# endif /* CAIRO_MUTEX_IMPL_INITIALIZE */
-
-/* and dynamic ones can be initialized using the static initializer. */
-# define CAIRO_MUTEX_IMPL_INIT(mutex) do { \
- cairo_mutex_t _tmp_mutex = CAIRO_MUTEX_IMPL_NIL_INITIALIZER; \
- memcpy (&(mutex), &_tmp_mutex, sizeof (_tmp_mutex)); \
- } while (0)
-
-#endif /* CAIRO_MUTEX_IMPL_INIT */
-
-#ifdef CAIRO_MUTEX_IMPL_FINI
-
-/* If %CAIRO_MUTEX_IMPL_FINI is defined, we may need to finalize all
- * static mutex'es. */
-# ifndef CAIRO_MUTEX_IMPL_FINALIZE
-# define CAIRO_MUTEX_IMPL_FINALIZE() do { \
- if (_cairo_mutex_initialized) \
- _cairo_mutex_finalize (); \
- } while(0)
-
-/* and make sure we implement the above */
-# define _CAIRO_MUTEX_IMPL_USE_STATIC_FINALIZER 1
-# endif /* CAIRO_MUTEX_IMPL_FINALIZE */
-
-#else /* no CAIRO_MUTEX_IMPL_FINI */
-
-/* Otherwise we probably don't need to finalize static mutex'es, */
-# ifndef CAIRO_MUTEX_IMPL_FINALIZE
-# define CAIRO_MUTEX_IMPL_FINALIZE() CAIRO_MUTEX_IMPL_NOOP
-# endif /* CAIRO_MUTEX_IMPL_FINALIZE */
-
-/* neither do the dynamic ones. */
-# define CAIRO_MUTEX_IMPL_FINI(mutex) CAIRO_MUTEX_IMPL_NOOP1(mutex)
-
-#endif /* CAIRO_MUTEX_IMPL_FINI */
-
-
-#ifndef _CAIRO_MUTEX_IMPL_USE_STATIC_INITIALIZER
-#define _CAIRO_MUTEX_IMPL_USE_STATIC_INITIALIZER 0
-#endif
-#ifndef _CAIRO_MUTEX_IMPL_USE_STATIC_FINALIZER
-#define _CAIRO_MUTEX_IMPL_USE_STATIC_FINALIZER 0
-#endif
-
-
-/* Make sure everything we want is defined */
-#ifndef CAIRO_MUTEX_IMPL_INITIALIZE
-# error "CAIRO_MUTEX_IMPL_INITIALIZE not defined"
-#endif
-#ifndef CAIRO_MUTEX_IMPL_FINALIZE
-# error "CAIRO_MUTEX_IMPL_FINALIZE not defined"
-#endif
-#ifndef CAIRO_MUTEX_IMPL_LOCK
-# error "CAIRO_MUTEX_IMPL_LOCK not defined"
-#endif
-#ifndef CAIRO_MUTEX_IMPL_UNLOCK
-# error "CAIRO_MUTEX_IMPL_UNLOCK not defined"
-#endif
-#ifndef CAIRO_MUTEX_IMPL_INIT
-# error "CAIRO_MUTEX_IMPL_INIT not defined"
-#endif
-#ifndef CAIRO_MUTEX_IMPL_FINI
-# error "CAIRO_MUTEX_IMPL_FINI not defined"
-#endif
-#ifndef CAIRO_MUTEX_IMPL_NIL_INITIALIZER
-# error "CAIRO_MUTEX_IMPL_NIL_INITIALIZER not defined"
-#endif
-
-
-/* Public interface. */
-
-/* By default it simply uses the implementation provided.
- * But we can provide for debugging features by overriding them */
-
-#ifndef CAIRO_MUTEX_DEBUG
-typedef cairo_mutex_impl_t cairo_mutex_t;
-typedef cairo_recursive_mutex_impl_t cairo_recursive_mutex_t;
-#else
-# define cairo_mutex_t cairo_mutex_impl_t
-#endif
-
-#define CAIRO_MUTEX_INITIALIZE CAIRO_MUTEX_IMPL_INITIALIZE
-#define CAIRO_MUTEX_FINALIZE CAIRO_MUTEX_IMPL_FINALIZE
-#define CAIRO_MUTEX_LOCK CAIRO_MUTEX_IMPL_LOCK
-#define CAIRO_MUTEX_UNLOCK CAIRO_MUTEX_IMPL_UNLOCK
-#define CAIRO_MUTEX_INIT CAIRO_MUTEX_IMPL_INIT
-#define CAIRO_MUTEX_FINI CAIRO_MUTEX_IMPL_FINI
-#define CAIRO_MUTEX_NIL_INITIALIZER CAIRO_MUTEX_IMPL_NIL_INITIALIZER
-
-#define CAIRO_RECURSIVE_MUTEX_INIT CAIRO_RECURSIVE_MUTEX_IMPL_INIT
-#define CAIRO_RECURSIVE_MUTEX_NIL_INITIALIZER CAIRO_RECURSIVE_MUTEX_IMPL_NIL_INITIALIZER
-
-#ifndef CAIRO_MUTEX_IS_LOCKED
-# define CAIRO_MUTEX_IS_LOCKED(name) 1
-#endif
-#ifndef CAIRO_MUTEX_IS_UNLOCKED
-# define CAIRO_MUTEX_IS_UNLOCKED(name) 1
-#endif
-
-
-/* Debugging support */
-
-#ifdef CAIRO_MUTEX_DEBUG
-
-/* TODO add mutex debugging facilities here (eg deadlock detection) */
-
-#endif /* CAIRO_MUTEX_DEBUG */
-
-#endif
diff --git a/src/cairo-mutex.c b/src/cairo-mutex.c
deleted file mode 100644
index 0a31dced3..000000000
--- a/src/cairo-mutex.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007 Mathias Hasselmann
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * Contributor(s):
- * Mathias Hasselmann <mathias.hasselmann@gmx.de>
- */
-
-#include "cairoint.h"
-
-#include "cairo-mutex-private.h"
-
-#define CAIRO_MUTEX_DECLARE(mutex) cairo_mutex_t mutex = CAIRO_MUTEX_NIL_INITIALIZER;
-#include "cairo-mutex-list-private.h"
-#undef CAIRO_MUTEX_DECLARE
-
-#if _CAIRO_MUTEX_IMPL_USE_STATIC_INITIALIZER || _CAIRO_MUTEX_IMPL_USE_STATIC_FINALIZER
-
-# if _CAIRO_MUTEX_IMPL_USE_STATIC_INITIALIZER
-# define _CAIRO_MUTEX_IMPL_INITIALIZED_DEFAULT_VALUE FALSE
-# else
-# define _CAIRO_MUTEX_IMPL_INITIALIZED_DEFAULT_VALUE TRUE
-# endif
-
-cairo_bool_t _cairo_mutex_initialized = _CAIRO_MUTEX_IMPL_INITIALIZED_DEFAULT_VALUE;
-
-# undef _CAIRO_MUTEX_IMPL_INITIALIZED_DEFAULT_VALUE
-
-#endif
-
-#if _CAIRO_MUTEX_IMPL_USE_STATIC_INITIALIZER
-void _cairo_mutex_initialize (void)
-{
- if (_cairo_mutex_initialized)
- return;
-
- _cairo_mutex_initialized = TRUE;
-
-#define CAIRO_MUTEX_DECLARE(mutex) CAIRO_MUTEX_INIT (mutex);
-#include "cairo-mutex-list-private.h"
-#undef CAIRO_MUTEX_DECLARE
-}
-#endif
-
-#if _CAIRO_MUTEX_IMPL_USE_STATIC_FINALIZER
-void _cairo_mutex_finalize (void)
-{
- if (!_cairo_mutex_initialized)
- return;
-
- _cairo_mutex_initialized = FALSE;
-
-#define CAIRO_MUTEX_DECLARE(mutex) CAIRO_MUTEX_FINI (mutex);
-#include "cairo-mutex-list-private.h"
-#undef CAIRO_MUTEX_DECLARE
-}
-#endif
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 1b79011be..ce3cff6c4 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -507,8 +507,6 @@ _cairo_pattern_create_in_error (cairo_status_t status)
if (status == CAIRO_STATUS_NO_MEMORY)
return (cairo_pattern_t *)&_cairo_pattern_nil.base;
- CAIRO_MUTEX_INITIALIZE ();
-
pattern = _cairo_pattern_create_solid (CAIRO_COLOR_BLACK);
if (pattern->status == CAIRO_STATUS_SUCCESS)
status = _cairo_pattern_set_error (pattern, status);
@@ -547,8 +545,6 @@ cairo_pattern_create_rgb (double red, double green, double blue)
_cairo_color_init_rgb (&color, red, green, blue);
- CAIRO_MUTEX_INITIALIZE ();
-
return _cairo_pattern_create_solid (&color);
}
slim_hidden_def (cairo_pattern_create_rgb);
@@ -587,8 +583,6 @@ cairo_pattern_create_rgba (double red, double green, double blue,
_cairo_color_init_rgba (&color, red, green, blue, alpha);
- CAIRO_MUTEX_INITIALIZE ();
-
return _cairo_pattern_create_solid (&color);
}
slim_hidden_def (cairo_pattern_create_rgba);
@@ -631,8 +625,6 @@ cairo_pattern_create_for_surface (cairo_surface_t *surface)
}
}
- CAIRO_MUTEX_INITIALIZE ();
-
_cairo_pattern_init_for_surface (pattern, surface);
CAIRO_REFERENCE_COUNT_INIT (&pattern->base.ref_count, 1);
@@ -681,8 +673,6 @@ cairo_pattern_create_linear (double x0, double y0, double x1, double y1)
}
}
- CAIRO_MUTEX_INITIALIZE ();
-
_cairo_pattern_init_linear (pattern, x0, y0, x1, y1);
CAIRO_REFERENCE_COUNT_INIT (&pattern->base.base.ref_count, 1);
@@ -733,8 +723,6 @@ cairo_pattern_create_radial (double cx0, double cy0, double radius0,
}
}
- CAIRO_MUTEX_INITIALIZE ();
-
_cairo_pattern_init_radial (pattern, cx0, cy0, radius0, cx1, cy1, radius1);
CAIRO_REFERENCE_COUNT_INIT (&pattern->base.base.ref_count, 1);
@@ -1562,6 +1550,7 @@ static struct {
} cache[MAX_SURFACE_CACHE_SIZE];
int size;
} solid_surface_cache;
+static simpleops_mutex_t _cairo_pattern_solid_surface_cache_lock;
static cairo_bool_t
_cairo_pattern_solid_surface_matches (
@@ -1608,7 +1597,7 @@ _cairo_pattern_acquire_surface_for_solid (const cairo_solid_pattern_t *patt
cairo_surface_t *surface, *to_destroy = NULL;
cairo_status_t status;
- CAIRO_MUTEX_LOCK (_cairo_pattern_solid_surface_cache_lock);
+ simpleops_mutex_lock (&_cairo_pattern_solid_surface_cache_lock);
/* Check cache first */
if (i < solid_surface_cache.size &&
@@ -1694,7 +1683,7 @@ NOCACHE:
status = CAIRO_STATUS_SUCCESS;
UNLOCK:
- CAIRO_MUTEX_UNLOCK (_cairo_pattern_solid_surface_cache_lock);
+ simpleops_mutex_unlock (&_cairo_pattern_solid_surface_cache_lock);
if (to_destroy)
cairo_surface_destroy (to_destroy);
@@ -1705,7 +1694,7 @@ UNLOCK:
static void
_cairo_pattern_reset_solid_surface_cache (void)
{
- CAIRO_MUTEX_LOCK (_cairo_pattern_solid_surface_cache_lock);
+ simpleops_mutex_lock (&_cairo_pattern_solid_surface_cache_lock);
/* remove surfaces starting from the end so that solid_surface_cache.cache
* is always in a consistent state when we release the mutex. */
@@ -1718,12 +1707,12 @@ _cairo_pattern_reset_solid_surface_cache (void)
/* release the lock to avoid the possibility of a recursive
* deadlock when the surface destroy closure gets called */
- CAIRO_MUTEX_UNLOCK (_cairo_pattern_solid_surface_cache_lock);
+ simpleops_mutex_unlock (&_cairo_pattern_solid_surface_cache_lock);
cairo_surface_destroy (surface);
- CAIRO_MUTEX_LOCK (_cairo_pattern_solid_surface_cache_lock);
+ simpleops_mutex_lock (&_cairo_pattern_solid_surface_cache_lock);
}
- CAIRO_MUTEX_UNLOCK (_cairo_pattern_solid_surface_cache_lock);
+ simpleops_mutex_unlock (&_cairo_pattern_solid_surface_cache_lock);
}
static void
diff --git a/src/cairo-scaled-font-private.h b/src/cairo-scaled-font-private.h
index 029377b17..1a3834e00 100644
--- a/src/cairo-scaled-font-private.h
+++ b/src/cairo-scaled-font-private.h
@@ -42,8 +42,8 @@
#include "cairo-types-private.h"
#include "cairo-list-private.h"
-#include "cairo-mutex-type-private.h"
#include "cairo-reference-count-private.h"
+#include "simpleops/mutex/simpleops-mutex.h"
typedef struct _cairo_scaled_glyph_page cairo_scaled_glyph_page_t;
@@ -105,7 +105,7 @@ struct _cairo_scaled_font {
cairo_font_extents_t fs_extents; /* font space */
/* The mutex protects modification to all subsequent fields. */
- cairo_mutex_t mutex;
+ simpleops_mutex_t mutex;
cairo_hash_table_t *glyphs;
cairo_list_t glyph_pages;
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index b40e4d40e..1273011cb 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -74,6 +74,7 @@
/* XXX: This number is arbitrary---we've never done any measurement of this. */
#define MAX_GLYPH_PAGES_CACHED 512
static cairo_cache_t cairo_scaled_glyph_page_cache;
+static simpleops_mutex_t _cairo_scaled_glyph_page_cache_mutex;
#define CAIRO_SCALED_GLYPH_PAGE_SIZE 32
struct _cairo_scaled_glyph_page {
@@ -236,14 +237,6 @@ static const cairo_scaled_font_t _cairo_scaled_font_nil = {
1., /* max_scale */
{ 0., 0., 0., 0., 0. }, /* extents */
{ 0., 0., 0., 0., 0. }, /* fs_extents */
- CAIRO_MUTEX_NIL_INITIALIZER,/* mutex */
- NULL, /* glyphs */
- { NULL, NULL }, /* pages */
- FALSE, /* cache_frozen */
- FALSE, /* global_cache_frozen */
- NULL, /* surface_backend */
- NULL, /* surface_private */
- NULL /* backend */
};
/**
@@ -348,6 +341,7 @@ typedef struct _cairo_scaled_font_map {
} cairo_scaled_font_map_t;
static cairo_scaled_font_map_t *cairo_scaled_font_map;
+static simpleops_mutex_t _cairo_scaled_font_map_mutex;
static int
_cairo_scaled_font_keys_equal (const void *abstract_key_a, const void *abstract_key_b);
@@ -355,7 +349,7 @@ _cairo_scaled_font_keys_equal (const void *abstract_key_a, const void *abstract_
static cairo_scaled_font_map_t *
_cairo_scaled_font_map_lock (void)
{
- CAIRO_MUTEX_LOCK (_cairo_scaled_font_map_mutex);
+ simpleops_mutex_lock (&_cairo_scaled_font_map_mutex);
if (cairo_scaled_font_map == NULL) {
cairo_scaled_font_map = malloc (sizeof (cairo_scaled_font_map_t));
@@ -378,7 +372,7 @@ _cairo_scaled_font_map_lock (void)
free (cairo_scaled_font_map);
cairo_scaled_font_map = NULL;
CLEANUP_MUTEX_LOCK:
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_map_mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_font_map_mutex);
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
}
@@ -386,7 +380,7 @@ _cairo_scaled_font_map_lock (void)
static void
_cairo_scaled_font_map_unlock (void)
{
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_map_mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_font_map_mutex);
}
void
@@ -395,7 +389,7 @@ _cairo_scaled_font_map_destroy (void)
cairo_scaled_font_map_t *font_map;
cairo_scaled_font_t *scaled_font;
- CAIRO_MUTEX_LOCK (_cairo_scaled_font_map_mutex);
+ simpleops_mutex_lock (&_cairo_scaled_font_map_mutex);
font_map = cairo_scaled_font_map;
if (unlikely (font_map == NULL)) {
@@ -404,9 +398,9 @@ _cairo_scaled_font_map_destroy (void)
scaled_font = font_map->mru_scaled_font;
if (scaled_font != NULL) {
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_map_mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_font_map_mutex);
cairo_scaled_font_destroy (scaled_font);
- CAIRO_MUTEX_LOCK (_cairo_scaled_font_map_mutex);
+ simpleops_mutex_lock (&_cairo_scaled_font_map_mutex);
}
/* remove scaled_fonts starting from the end so that font_map->holdovers
@@ -434,7 +428,7 @@ _cairo_scaled_font_map_destroy (void)
cairo_scaled_font_map = NULL;
CLEANUP_MUTEX_LOCK:
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_map_mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_font_map_mutex);
}
static void
_cairo_scaled_glyph_page_destroy (void *closure)
@@ -477,8 +471,6 @@ _cairo_scaled_font_register_placeholder_and_unlock_font_map (cairo_scaled_font_t
cairo_status_t status;
cairo_scaled_font_t *placeholder_scaled_font;
- assert (CAIRO_MUTEX_IS_LOCKED (_cairo_scaled_font_map_mutex));
-
status = scaled_font->status;
if (unlikely (status))
return status;
@@ -504,8 +496,8 @@ _cairo_scaled_font_register_placeholder_and_unlock_font_map (cairo_scaled_font_t
if (unlikely (status))
goto FINI_PLACEHOLDER;
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_map_mutex);
- CAIRO_MUTEX_LOCK (placeholder_scaled_font->mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_font_map_mutex);
+ simpleops_mutex_lock (&placeholder_scaled_font->mutex);
return CAIRO_STATUS_SUCCESS;
@@ -522,24 +514,23 @@ _cairo_scaled_font_unregister_placeholder_and_lock_font_map (cairo_scaled_font_t
{
cairo_scaled_font_t *placeholder_scaled_font;
- CAIRO_MUTEX_LOCK (_cairo_scaled_font_map_mutex);
+ simpleops_mutex_lock (&_cairo_scaled_font_map_mutex);
placeholder_scaled_font =
_cairo_hash_table_lookup (cairo_scaled_font_map->hash_table,
&scaled_font->hash_entry);
assert (placeholder_scaled_font != NULL);
assert (placeholder_scaled_font->placeholder);
- assert (CAIRO_MUTEX_IS_LOCKED (placeholder_scaled_font->mutex));
_cairo_hash_table_remove (cairo_scaled_font_map->hash_table,
&placeholder_scaled_font->hash_entry);
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_map_mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_font_map_mutex);
- CAIRO_MUTEX_UNLOCK (placeholder_scaled_font->mutex);
+ simpleops_mutex_unlock (&placeholder_scaled_font->mutex);
cairo_scaled_font_destroy (placeholder_scaled_font);
- CAIRO_MUTEX_LOCK (_cairo_scaled_font_map_mutex);
+ simpleops_mutex_lock (&_cairo_scaled_font_map_mutex);
}
static void
@@ -549,16 +540,16 @@ _cairo_scaled_font_placeholder_wait_for_creation_to_finish (cairo_scaled_font_t
cairo_scaled_font_reference (placeholder_scaled_font);
/* now unlock the fontmap mutex so creation has a chance to finish */
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_map_mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_font_map_mutex);
/* wait on placeholder mutex until we are awaken */
- CAIRO_MUTEX_LOCK (placeholder_scaled_font->mutex);
+ simpleops_mutex_lock (&placeholder_scaled_font->mutex);
/* ok, creation done. just clean up and back out */
- CAIRO_MUTEX_UNLOCK (placeholder_scaled_font->mutex);
+ simpleops_mutex_unlock (&placeholder_scaled_font->mutex);
cairo_scaled_font_destroy (placeholder_scaled_font);
- CAIRO_MUTEX_LOCK (_cairo_scaled_font_map_mutex);
+ simpleops_mutex_lock (&_cairo_scaled_font_map_mutex);
}
/* Fowler / Noll / Vo (FNV) Hash (http://www.isthe.com/chongo/tech/comp/fnv/)
@@ -741,7 +732,7 @@ _cairo_scaled_font_init (cairo_scaled_font_t *scaled_font,
cairo_font_face_reference (font_face);
scaled_font->original_font_face = NULL;
- CAIRO_MUTEX_INIT (scaled_font->mutex);
+ simpleops_mutex_init (&scaled_font->mutex);
scaled_font->surface_backend = NULL;
scaled_font->surface_private = NULL;
@@ -758,7 +749,7 @@ _cairo_scaled_font_freeze_cache (cairo_scaled_font_t *scaled_font)
/* ensure we do not modify an error object */
assert (scaled_font->status == CAIRO_STATUS_SUCCESS);
- CAIRO_MUTEX_LOCK (scaled_font->mutex);
+ simpleops_mutex_lock (&scaled_font->mutex);
scaled_font->cache_frozen = TRUE;
}
@@ -768,14 +759,14 @@ _cairo_scaled_font_thaw_cache (cairo_scaled_font_t *scaled_font)
scaled_font->cache_frozen = FALSE;
if (scaled_font->global_cache_frozen) {
- CAIRO_MUTEX_LOCK (_cairo_scaled_glyph_page_cache_mutex);
+ simpleops_mutex_lock (&_cairo_scaled_glyph_page_cache_mutex);
_cairo_cache_thaw (&cairo_scaled_glyph_page_cache);
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_glyph_page_cache_mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_glyph_page_cache_mutex);
scaled_font->global_cache_frozen = FALSE;
}
- CAIRO_MUTEX_UNLOCK (scaled_font->mutex);
+ simpleops_mutex_unlock (&scaled_font->mutex);
}
void
@@ -783,14 +774,14 @@ _cairo_scaled_font_reset_cache (cairo_scaled_font_t *scaled_font)
{
assert (! scaled_font->cache_frozen);
- CAIRO_MUTEX_LOCK (_cairo_scaled_glyph_page_cache_mutex);
+ simpleops_mutex_lock (&_cairo_scaled_glyph_page_cache_mutex);
while (! cairo_list_is_empty (&scaled_font->glyph_pages)) {
_cairo_cache_remove (&cairo_scaled_glyph_page_cache,
&cairo_list_first_entry (&scaled_font->glyph_pages,
cairo_scaled_glyph_page_t,
link)->cache_entry);
}
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_glyph_page_cache_mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_glyph_page_cache_mutex);
}
cairo_status_t
@@ -833,7 +824,7 @@ _cairo_scaled_font_fini_internal (cairo_scaled_font_t *scaled_font)
cairo_font_face_destroy (scaled_font->font_face);
cairo_font_face_destroy (scaled_font->original_font_face);
- CAIRO_MUTEX_FINI (scaled_font->mutex);
+ simpleops_mutex_fini (&scaled_font->mutex);
if (scaled_font->surface_backend != NULL &&
scaled_font->surface_backend->scaled_font_fini != NULL)
@@ -866,9 +857,9 @@ _cairo_scaled_font_fini (cairo_scaled_font_t *scaled_font)
{
/* Release the lock to avoid the possibility of a recursive
* deadlock when the scaled font destroy closure gets called. */
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_map_mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_font_map_mutex);
_cairo_scaled_font_fini_internal (scaled_font);
- CAIRO_MUTEX_LOCK (_cairo_scaled_font_map_mutex);
+ simpleops_mutex_lock (&_cairo_scaled_font_map_mutex);
}
/**
@@ -1116,6 +1107,7 @@ cairo_scaled_font_create (cairo_font_face_t *font_face,
slim_hidden_def (cairo_scaled_font_create);
static cairo_scaled_font_t *_cairo_scaled_font_nil_objects[CAIRO_STATUS_LAST_STATUS + 1];
+static simpleops_mutex_t _cairo_scaled_font_error_mutex;
/* XXX This should disappear in favour of a common pool of error objects. */
cairo_scaled_font_t *
@@ -1128,12 +1120,12 @@ _cairo_scaled_font_create_in_error (cairo_status_t status)
if (status == CAIRO_STATUS_NO_MEMORY)
return (cairo_scaled_font_t *) &_cairo_scaled_font_nil;
- CAIRO_MUTEX_LOCK (_cairo_scaled_font_error_mutex);
+ simpleops_mutex_lock (&_cairo_scaled_font_error_mutex);
scaled_font = _cairo_scaled_font_nil_objects[status];
if (unlikely (scaled_font == NULL)) {
scaled_font = malloc (sizeof (cairo_scaled_font_t));
if (unlikely (scaled_font == NULL)) {
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_error_mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_font_error_mutex);
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_scaled_font_t *) &_cairo_scaled_font_nil;
}
@@ -1142,7 +1134,7 @@ _cairo_scaled_font_create_in_error (cairo_status_t status)
scaled_font->status = status;
_cairo_scaled_font_nil_objects[status] = scaled_font;
}
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_error_mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_font_error_mutex);
return scaled_font;
}
@@ -1152,7 +1144,7 @@ _cairo_scaled_font_reset_static_data (void)
{
int status;
- CAIRO_MUTEX_LOCK (_cairo_scaled_font_error_mutex);
+ simpleops_mutex_lock (&_cairo_scaled_font_error_mutex);
for (status = CAIRO_STATUS_SUCCESS;
status <= CAIRO_STATUS_LAST_STATUS;
status++)
@@ -1162,14 +1154,14 @@ _cairo_scaled_font_reset_static_data (void)
_cairo_scaled_font_nil_objects[status] = NULL;
}
}
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_error_mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_font_error_mutex);
- CAIRO_MUTEX_LOCK (_cairo_scaled_glyph_page_cache_mutex);
+ simpleops_mutex_lock (&_cairo_scaled_glyph_page_cache_mutex);
if (cairo_scaled_glyph_page_cache.hash_table != NULL) {
_cairo_cache_fini (&cairo_scaled_glyph_page_cache);
cairo_scaled_glyph_page_cache.hash_table = NULL;
}
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_glyph_page_cache_mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_glyph_page_cache_mutex);
}
/**
@@ -1215,8 +1207,6 @@ cairo_scaled_font_destroy (cairo_scaled_font_t *scaled_font)
cairo_scaled_font_t *lru = NULL;
cairo_scaled_font_map_t *font_map;
- assert (CAIRO_MUTEX_IS_UNLOCKED (_cairo_scaled_font_map_mutex));
-
if (scaled_font == NULL ||
CAIRO_REFERENCE_COUNT_IS_INVALID (&scaled_font->ref_count))
return;
@@ -2691,7 +2681,7 @@ _cairo_scaled_font_allocate_glyph (cairo_scaled_font_t *scaled_font,
page->cache_entry.size = 1; /* XXX occupancy weighting? */
page->num_glyphs = 0;
- CAIRO_MUTEX_LOCK (_cairo_scaled_glyph_page_cache_mutex);
+ simpleops_mutex_lock (&_cairo_scaled_glyph_page_cache_mutex);
if (scaled_font->global_cache_frozen == FALSE) {
if (unlikely (cairo_scaled_glyph_page_cache.hash_table == NULL)) {
status = _cairo_cache_init (&cairo_scaled_glyph_page_cache,
@@ -2700,7 +2690,7 @@ _cairo_scaled_font_allocate_glyph (cairo_scaled_font_t *scaled_font,
_cairo_scaled_glyph_page_destroy,
MAX_GLYPH_PAGES_CACHED);
if (unlikely (status)) {
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_glyph_page_cache_mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_glyph_page_cache_mutex);
free (page);
return status;
}
@@ -2712,7 +2702,7 @@ _cairo_scaled_font_allocate_glyph (cairo_scaled_font_t *scaled_font,
status = _cairo_cache_insert (&cairo_scaled_glyph_page_cache,
&page->cache_entry);
- CAIRO_MUTEX_UNLOCK (_cairo_scaled_glyph_page_cache_mutex);
+ simpleops_mutex_unlock (&_cairo_scaled_glyph_page_cache_mutex);
if (unlikely (status)) {
free (page);
return status;
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 6be269f83..f913a447a 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -392,8 +392,6 @@ _cairo_surface_init (cairo_surface_t *surface,
cairo_device_t *device,
cairo_content_t content)
{
- CAIRO_MUTEX_INITIALIZE ();
-
surface->backend = backend;
surface->device = cairo_device_reference (device);
surface->content = content;
diff --git a/src/cairo-toy-font-face.c b/src/cairo-toy-font-face.c
index 4c690da53..59cafd2c1 100644
--- a/src/cairo-toy-font-face.c
+++ b/src/cairo-toy-font-face.c
@@ -78,6 +78,7 @@ static const cairo_font_face_t _cairo_font_face_invalid_weight = {
static const cairo_font_face_backend_t _cairo_toy_font_face_backend;
+static simpleops_mutex_t _cairo_toy_font_face_mutex;
static int
_cairo_toy_font_face_keys_equal (const void *key_a,
@@ -98,7 +99,7 @@ static cairo_hash_table_t *cairo_toy_font_face_hash_table = NULL;
static cairo_hash_table_t *
_cairo_toy_font_face_hash_table_lock (void)
{
- CAIRO_MUTEX_LOCK (_cairo_toy_font_face_mutex);
+ simpleops_mutex_lock (&_cairo_toy_font_face_mutex);
if (cairo_toy_font_face_hash_table == NULL)
{
@@ -106,7 +107,7 @@ _cairo_toy_font_face_hash_table_lock (void)
_cairo_hash_table_create (_cairo_toy_font_face_keys_equal);
if (cairo_toy_font_face_hash_table == NULL) {
- CAIRO_MUTEX_UNLOCK (_cairo_toy_font_face_mutex);
+ simpleops_mutex_unlock (&_cairo_toy_font_face_mutex);
return NULL;
}
}
@@ -117,7 +118,7 @@ _cairo_toy_font_face_hash_table_lock (void)
static void
_cairo_toy_font_face_hash_table_unlock (void)
{
- CAIRO_MUTEX_UNLOCK (_cairo_toy_font_face_mutex);
+ simpleops_mutex_unlock (&_cairo_toy_font_face_mutex);
}
/**
@@ -516,10 +517,10 @@ _cairo_toy_font_face_reset_static_data (void)
/* We manually acquire the lock rather than calling
* cairo_toy_font_face_hash_table_lock simply to avoid
* creating the table only to destroy it again. */
- CAIRO_MUTEX_LOCK (_cairo_toy_font_face_mutex);
+ simpleops_mutex_lock (&_cairo_toy_font_face_mutex);
hash_table = cairo_toy_font_face_hash_table;
cairo_toy_font_face_hash_table = NULL;
- CAIRO_MUTEX_UNLOCK (_cairo_toy_font_face_mutex);
+ simpleops_mutex_unlock (&_cairo_toy_font_face_mutex);
if (hash_table != NULL)
_cairo_hash_table_destroy (hash_table);
diff --git a/src/cairo-user-font.c b/src/cairo-user-font.c
index a524d588f..3961b2fb0 100644
--- a/src/cairo-user-font.c
+++ b/src/cairo-user-font.c
@@ -450,7 +450,7 @@ _cairo_user_font_face_scaled_font_create (void *abstract_
{
/* Lock the scaled_font mutex such that user doesn't accidentally try
* to use it just yet. */
- CAIRO_MUTEX_LOCK (user_scaled_font->base.mutex);
+ simpleops_mutex_lock (&user_scaled_font->base.mutex);
/* Give away fontmap lock such that user-font can use other fonts */
status = _cairo_scaled_font_register_placeholder_and_unlock_font_map (&user_scaled_font->base);
@@ -477,7 +477,7 @@ _cairo_user_font_face_scaled_font_create (void *abstract_
_cairo_scaled_font_unregister_placeholder_and_lock_font_map (&user_scaled_font->base);
}
- CAIRO_MUTEX_UNLOCK (user_scaled_font->base.mutex);
+ simpleops_mutex_unlock (&user_scaled_font->base.mutex);
}
if (status == CAIRO_STATUS_SUCCESS)
diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c
index 0488390ab..470ee21a0 100644
--- a/src/cairo-xcb-connection.c
+++ b/src/cairo-xcb-connection.c
@@ -479,14 +479,14 @@ _device_flush (void *device)
if (unlikely (status))
return status;
- CAIRO_MUTEX_LOCK (connection->screens_mutex);
+ simpleops_mutex_lock (&connection->screens_mutex);
cairo_list_foreach_entry (screen, cairo_xcb_screen_t,
&connection->screens, link)
{
if (screen->device != NULL)
cairo_device_flush (screen->device);
}
- CAIRO_MUTEX_UNLOCK (connection->screens_mutex);
+ simpleops_mutex_unlock (&connection->screens_mutex);
xcb_flush (connection->xcb_connection);
@@ -516,9 +516,9 @@ _device_finish (void *device)
cairo_bool_t was_cached = FALSE;
if (! cairo_list_is_empty (&connection->link)) {
- CAIRO_MUTEX_LOCK (_cairo_xcb_connections_mutex);
+ simpleops_mutex_lock (&_cairo_xcb_connections_mutex);
cairo_list_del (&connection->link);
- CAIRO_MUTEX_UNLOCK (_cairo_xcb_connections_mutex);
+ simpleops_mutex_unlock (&_cairo_xcb_connections_mutex);
was_cached = TRUE;
}
@@ -597,7 +597,7 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection)
CAIRO_MUTEX_INITIALIZE ();
- CAIRO_MUTEX_LOCK (_cairo_xcb_connections_mutex);
+ simpleops_mutex_lock (&_cairo_xcb_connections_mutex);
if (connections.next == NULL) {
/* XXX _cairo_init () */
cairo_list_init (&connections);
@@ -660,7 +660,7 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection)
CAIRO_MUTEX_INIT (connection->shm_mutex);
CAIRO_MUTEX_INIT (connection->screens_mutex);
- CAIRO_MUTEX_LOCK (connection->device.mutex);
+ simpleops_mutex_lock (&connection->device.mutex);
connection->flags = 0;
@@ -684,7 +684,7 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection)
if (ext != NULL && ext->present) {
status = _cairo_xcb_connection_query_render (connection);
if (unlikely (status)) {
- CAIRO_MUTEX_UNLOCK (connection->device.mutex);
+ simpleops_mutex_unlock (&connection->device.mutex);
_cairo_xcb_connection_destroy (connection);
connection = NULL;
goto unlock;
@@ -717,11 +717,11 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection)
}
#endif
- CAIRO_MUTEX_UNLOCK (connection->device.mutex);
+ simpleops_mutex_unlock (&connection->device.mutex);
cairo_list_add (&connection->link, &connections);
unlock:
- CAIRO_MUTEX_UNLOCK (_cairo_xcb_connections_mutex);
+ simpleops_mutex_unlock (&_cairo_xcb_connections_mutex);
return connection;
}
@@ -792,9 +792,9 @@ _cairo_xcb_return_socket (void *closure)
{
cairo_xcb_connection_t *connection = closure;
- CAIRO_MUTEX_LOCK (connection->device.mutex);
+ simpleops_mutex_lock (&connection->device.mutex);
connection->has_socket = FALSE;
- CAIRO_MUTEX_UNLOCK (connection->device.mutex);
+ simpleops_mutex_unlock (&connection->device.mutex);
}
cairo_status_t
diff --git a/src/cairo-xcb-screen.c b/src/cairo-xcb-screen.c
index c80bf2d9a..340707084 100644
--- a/src/cairo-xcb-screen.c
+++ b/src/cairo-xcb-screen.c
@@ -46,9 +46,9 @@ _cairo_xcb_screen_finish (cairo_xcb_screen_t *screen)
{
int i;
- CAIRO_MUTEX_LOCK (screen->connection->screens_mutex);
+ simpleops_mutex_lock (&screen->connection->screens_mutex);
cairo_list_del (&screen->link);
- CAIRO_MUTEX_UNLOCK (screen->connection->screens_mutex);
+ simpleops_mutex_unlock (&screen->connection->screens_mutex);
while (! cairo_list_is_empty (&screen->surfaces)) {
cairo_surface_t *surface;
@@ -224,7 +224,7 @@ _cairo_xcb_screen_get (xcb_connection_t *xcb_connection,
if (unlikely (connection == NULL))
return NULL;
- CAIRO_MUTEX_LOCK (connection->screens_mutex);
+ simpleops_mutex_lock (&connection->screens_mutex);
cairo_list_foreach_entry (screen,
cairo_xcb_screen_t,
@@ -291,7 +291,7 @@ _cairo_xcb_screen_get (xcb_connection_t *xcb_connection,
cairo_list_add (&screen->link, &connection->screens);
unlock:
- CAIRO_MUTEX_UNLOCK (connection->screens_mutex);
+ simpleops_mutex_unlock (&connection->screens_mutex);
return screen;
@@ -300,7 +300,7 @@ error_linear:
error_surface:
_cairo_cache_fini (&screen->surface_pattern_cache);
error_screen:
- CAIRO_MUTEX_UNLOCK (connection->screens_mutex);
+ simpleops_mutex_unlock (&connection->screens_mutex);
cairo_device_destroy (screen->device);
free (screen);
diff --git a/src/cairo-xcb-shm.c b/src/cairo-xcb-shm.c
index 417496eca..19ed9e5bf 100644
--- a/src/cairo-xcb-shm.c
+++ b/src/cairo-xcb-shm.c
@@ -425,7 +425,7 @@ _cairo_xcb_connection_allocate_shm_info (cairo_xcb_connection_t *connection,
assert (connection->flags & CAIRO_XCB_HAS_SHM);
- CAIRO_MUTEX_LOCK (connection->shm_mutex);
+ simpleops_mutex_lock (&connection->shm_mutex);
cairo_list_foreach_entry_safe (pool, next, cairo_xcb_shm_mem_pool_t,
&connection->shm_pools, link)
{
@@ -447,7 +447,7 @@ _cairo_xcb_connection_allocate_shm_info (cairo_xcb_connection_t *connection,
pool = malloc (sizeof (cairo_xcb_shm_mem_pool_t));
if (unlikely (pool == NULL)) {
- CAIRO_MUTEX_UNLOCK (connection->shm_mutex);
+ simpleops_mutex_unlock (&connection->shm_mutex);
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
@@ -471,7 +471,7 @@ _cairo_xcb_connection_allocate_shm_info (cairo_xcb_connection_t *connection,
if (! (err == EINVAL || err == ENOMEM))
connection->flags &= ~CAIRO_XCB_HAS_SHM;
free (pool);
- CAIRO_MUTEX_UNLOCK (connection->shm_mutex);
+ simpleops_mutex_unlock (&connection->shm_mutex);
return CAIRO_INT_STATUS_UNSUPPORTED;
}
@@ -479,7 +479,7 @@ _cairo_xcb_connection_allocate_shm_info (cairo_xcb_connection_t *connection,
if (unlikely (pool->base == (char *) -1)) {
shmctl (pool->shmid, IPC_RMID, NULL);
free (pool);
- CAIRO_MUTEX_UNLOCK (connection->shm_mutex);
+ simpleops_mutex_unlock (&connection->shm_mutex);
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
@@ -490,7 +490,7 @@ _cairo_xcb_connection_allocate_shm_info (cairo_xcb_connection_t *connection,
if (unlikely (status)) {
shmdt (pool->base);
free (pool);
- CAIRO_MUTEX_UNLOCK (connection->shm_mutex);
+ simpleops_mutex_unlock (&connection->shm_mutex);
return status;
}
@@ -504,7 +504,7 @@ _cairo_xcb_connection_allocate_shm_info (cairo_xcb_connection_t *connection,
shm_info = _cairo_freepool_alloc (&connection->shm_info_freelist);
if (unlikely (shm_info == NULL)) {
_cairo_xcb_shm_mem_pool_free (pool, mem);
- CAIRO_MUTEX_UNLOCK (connection->shm_mutex);
+ simpleops_mutex_unlock (&connection->shm_mutex);
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
@@ -524,7 +524,7 @@ _cairo_xcb_connection_allocate_shm_info (cairo_xcb_connection_t *connection,
_cairo_xcb_shm_mem_pool_destroy (pool);
}
}
- CAIRO_MUTEX_UNLOCK (connection->shm_mutex);
+ simpleops_mutex_unlock (&connection->shm_mutex);
*shm_info_out = shm_info;
return CAIRO_STATUS_SUCCESS;
@@ -535,7 +535,7 @@ _cairo_xcb_shm_info_destroy (cairo_xcb_shm_info_t *shm_info)
{
cairo_xcb_connection_t *connection = shm_info->connection;
- CAIRO_MUTEX_LOCK (connection->shm_mutex);
+ simpleops_mutex_lock (&connection->shm_mutex);
_cairo_xcb_shm_mem_pool_free (shm_info->pool, shm_info->mem);
_cairo_freepool_free (&connection->shm_info_freelist, shm_info);
@@ -562,7 +562,7 @@ _cairo_xcb_shm_info_destroy (cairo_xcb_shm_info_t *shm_info)
cairo_list_move (head.next, &connection->shm_pools);
}
- CAIRO_MUTEX_UNLOCK (connection->shm_mutex);
+ simpleops_mutex_unlock (&connection->shm_mutex);
}
void
diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index 8294a4728..4b965340b 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -3948,10 +3948,10 @@ _cairo_xcb_font_finish (cairo_xcb_font_t *font)
scaled_font = font->scaled_font;
- CAIRO_MUTEX_LOCK (scaled_font->mutex);
+ simpleops_mutex_lock (&scaled_font->mutex);
scaled_font->surface_private = NULL;
_cairo_scaled_font_reset_cache (scaled_font);
- CAIRO_MUTEX_UNLOCK (scaled_font->mutex);
+ simpleops_mutex_unlock (&scaled_font->mutex);
_cairo_xcb_font_destroy (font);
}
diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c
index dd60484c8..4a85231c5 100644
--- a/src/cairo-xlib-display.c
+++ b/src/cairo-xlib-display.c
@@ -65,6 +65,7 @@ struct _cairo_xlib_job {
};
static cairo_xlib_display_t *_cairo_xlib_display_list;
+static simpleops_mutex_t _cairo_xlib_display_mutex;
static void
_cairo_xlib_remove_close_display_hook_internal (cairo_xlib_display_t *display,
@@ -191,11 +192,11 @@ _cairo_xlib_close_display (Display *dpy, XExtCodes *codes)
cairo_xlib_display_t *display, **prev, *next;
cairo_xlib_error_func_t old_handler;
- CAIRO_MUTEX_LOCK (_cairo_xlib_display_mutex);
+ simpleops_mutex_lock (&_cairo_xlib_display_mutex);
for (display = _cairo_xlib_display_list; display; display = display->next)
if (display->display == dpy)
break;
- CAIRO_MUTEX_UNLOCK (_cairo_xlib_display_mutex);
+ simpleops_mutex_unlock (&_cairo_xlib_display_mutex);
if (display == NULL)
return 0;
@@ -219,7 +220,7 @@ _cairo_xlib_close_display (Display *dpy, XExtCodes *codes)
/*
* Unhook from the global list
*/
- CAIRO_MUTEX_LOCK (_cairo_xlib_display_mutex);
+ simpleops_mutex_lock (&_cairo_xlib_display_mutex);
prev = &_cairo_xlib_display_list;
for (display = _cairo_xlib_display_list; display; display = next) {
next = display->next;
@@ -229,7 +230,7 @@ _cairo_xlib_close_display (Display *dpy, XExtCodes *codes)
} else
prev = &display->next;
}
- CAIRO_MUTEX_UNLOCK (_cairo_xlib_display_mutex);
+ simpleops_mutex_unlock (&_cairo_xlib_display_mutex);
assert (display != NULL);
@@ -269,8 +270,6 @@ _cairo_xlib_device_create (Display *dpy)
XExtCodes *codes;
const char *env;
- CAIRO_MUTEX_INITIALIZE ();
-
/* There is an apparent deadlock between this mutex and the
* mutex for the display, but it's actually safe. For the
* app to call XCloseDisplay() while any other thread is
@@ -278,7 +277,7 @@ _cairo_xlib_device_create (Display *dpy)
* app, and the CloseDisplay hook is the only other place we
* acquire this mutex.
*/
- CAIRO_MUTEX_LOCK (_cairo_xlib_display_mutex);
+ simpleops_mutex_lock (&_cairo_xlib_display_mutex);
for (prev = &_cairo_xlib_display_list; (display = *prev); prev = &(*prev)->next)
{
@@ -438,7 +437,7 @@ _cairo_xlib_device_create (Display *dpy)
device = &display->base;
UNLOCK:
- CAIRO_MUTEX_UNLOCK (_cairo_xlib_display_mutex);
+ simpleops_mutex_unlock (&_cairo_xlib_display_mutex);
return device;
}
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index c74f656bf..db34915a1 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -3842,12 +3842,12 @@ _cairo_xlib_surface_remove_scaled_font (cairo_xlib_display_t *display,
close_display_hook);
scaled_font = font_private->scaled_font;
- CAIRO_MUTEX_LOCK (scaled_font->mutex);
+ simpleops_mutex_lock (&scaled_font->mutex);
font_private = scaled_font->surface_private;
scaled_font->surface_private = NULL;
_cairo_scaled_font_reset_cache (scaled_font);
- CAIRO_MUTEX_UNLOCK (scaled_font->mutex);
+ simpleops_mutex_unlock (&scaled_font->mutex);
if (font_private != NULL) {
int i;
diff --git a/src/cairo.c b/src/cairo.c
index 826e7affe..1adbe2a5e 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -280,6 +280,7 @@ _context_put (cairo_t *cr)
/* XXX This should disappear in favour of a common pool of error objects. */
static cairo_t *_cairo_nil__objects[CAIRO_STATUS_LAST_STATUS + 1];
+static simpleops_mutex_t _cairo_error_mutex;
static cairo_t *
_cairo_create_in_error (cairo_status_t status)
@@ -296,12 +297,12 @@ _cairo_create_in_error (cairo_status_t status)
return (cairo_t *) &_cairo_nil__null_pointer;
}
- CAIRO_MUTEX_LOCK (_cairo_error_mutex);
+ simpleops_mutex_lock (&_cairo_error_mutex);
cr = _cairo_nil__objects[status];
if (cr == NULL) {
cr = malloc (sizeof (cairo_t));
if (unlikely (cr == NULL)) {
- CAIRO_MUTEX_UNLOCK (_cairo_error_mutex);
+ simpleops_mutex_unlock (&_cairo_error_mutex);
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_t *) &_cairo_nil;
}
@@ -310,7 +311,7 @@ _cairo_create_in_error (cairo_status_t status)
cr->status = status;
_cairo_nil__objects[status] = cr;
}
- CAIRO_MUTEX_UNLOCK (_cairo_error_mutex);
+ simpleops_mutex_unlock (&_cairo_error_mutex);
return cr;
}
@@ -320,7 +321,7 @@ _cairo_reset_static_data (void)
{
int status;
- CAIRO_MUTEX_LOCK (_cairo_error_mutex);
+ simpleops_mutex_lock (&_cairo_error_mutex);
for (status = CAIRO_STATUS_SUCCESS;
status <= CAIRO_STATUS_LAST_STATUS;
status++)
@@ -330,7 +331,7 @@ _cairo_reset_static_data (void)
_cairo_nil__objects[status] = NULL;
}
}
- CAIRO_MUTEX_UNLOCK (_cairo_error_mutex);
+ simpleops_mutex_unlock (&_cairo_error_mutex);
}
/**
diff --git a/src/cairoint.h b/src/cairoint.h
index 90e5728e3..87730caac 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2517,7 +2517,6 @@ _cairo_pattern_analyze_filter (const cairo_pattern_t *pattern,
CAIRO_END_DECLS
-#include "cairo-mutex-private.h"
#include "cairo-fixed-private.h"
#include "cairo-wideint-private.h"
#include "cairo-malloc-private.h"
diff --git a/src/drm/cairo-drm-intel.c b/src/drm/cairo-drm-intel.c
index ab139d591..d4e0c2064 100644
--- a/src/drm/cairo-drm-intel.c
+++ b/src/drm/cairo-drm-intel.c
@@ -420,7 +420,7 @@ intel_bo_create (intel_device_t *device,
bo = NULL;
- CAIRO_MUTEX_LOCK (device->bo_mutex);
+ simpleops_mutex_lock (&device->bo_mutex);
if (bucket < INTEL_BO_CACHE_BUCKETS) {
int loop = MIN (3, INTEL_BO_CACHE_BUCKETS - bucket);
/* Our goal is to avoid clflush which occur on CPU->GPU
@@ -509,7 +509,7 @@ intel_bo_create (intel_device_t *device,
bo = _cairo_freepool_alloc (&device->bo_pool);
if (unlikely (bo == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
- CAIRO_MUTEX_UNLOCK (device->bo_mutex);
+ simpleops_mutex_unlock (&device->bo_mutex);
return bo;
}
@@ -544,7 +544,7 @@ intel_bo_create (intel_device_t *device,
if (unlikely (ret != 0)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
_cairo_freepool_free (&device->bo_pool, bo);
- CAIRO_MUTEX_UNLOCK (device->bo_mutex);
+ simpleops_mutex_unlock (&device->bo_mutex);
return NULL;
}
@@ -555,7 +555,7 @@ SIZE:
intel_bo_set_real_size (device, bo, real_size);
INIT:
CAIRO_REFERENCE_COUNT_INIT (&bo->base.ref_count, 1);
- CAIRO_MUTEX_UNLOCK (device->bo_mutex);
+ simpleops_mutex_unlock (&device->bo_mutex);
DONE:
bo->tiling = tiling;
bo->stride = stride;
@@ -570,9 +570,9 @@ intel_bo_create_for_name (intel_device_t *device, uint32_t name)
intel_bo_t *bo;
int ret;
- CAIRO_MUTEX_LOCK (device->bo_mutex);
+ simpleops_mutex_lock (&device->bo_mutex);
bo = _cairo_freepool_alloc (&device->bo_pool);
- CAIRO_MUTEX_UNLOCK (device->bo_mutex);
+ simpleops_mutex_unlock (&device->bo_mutex);
if (unlikely (bo == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
@@ -617,9 +617,9 @@ intel_bo_create_for_name (intel_device_t *device, uint32_t name)
return bo;
FAIL:
- CAIRO_MUTEX_LOCK (device->bo_mutex);
+ simpleops_mutex_lock (&device->bo_mutex);
_cairo_freepool_free (&device->bo_pool, bo);
- CAIRO_MUTEX_UNLOCK (device->bo_mutex);
+ simpleops_mutex_unlock (&device->bo_mutex);
return NULL;
}
@@ -638,7 +638,7 @@ intel_bo_release (void *_dev, void *_bo)
bucket = bo->bucket;
- CAIRO_MUTEX_LOCK (device->bo_mutex);
+ simpleops_mutex_lock (&device->bo_mutex);
if (bo->base.name == 0 &&
bucket < INTEL_BO_CACHE_BUCKETS &&
intel_bo_madvise (device, bo, I915_MADV_DONTNEED))
@@ -656,7 +656,7 @@ intel_bo_release (void *_dev, void *_bo)
_cairo_drm_bo_close (&device->base, &bo->base);
_cairo_freepool_free (&device->bo_pool, bo);
}
- CAIRO_MUTEX_UNLOCK (device->bo_mutex);
+ simpleops_mutex_unlock (&device->bo_mutex);
}
void
diff --git a/src/drm/cairo-drm.c b/src/drm/cairo-drm.c
index 051b79e4f..592a560b2 100644
--- a/src/drm/cairo-drm.c
+++ b/src/drm/cairo-drm.c
@@ -73,7 +73,7 @@ _device_finish (void *abstract_device)
{
cairo_drm_device_t *device = abstract_device;
- CAIRO_MUTEX_LOCK (_cairo_drm_device_mutex);
+ simpleops_mutex_lock (&_cairo_drm_device_mutex);
if (device->prev != NULL)
device->prev->next = device->next;
else
@@ -81,7 +81,7 @@ _device_finish (void *abstract_device)
if (device->next != NULL)
device->next->prev = device->prev;
- CAIRO_MUTEX_UNLOCK (_cairo_drm_device_mutex);
+ simpleops_mutex_unlock (&_cairo_drm_device_mutex);
if (_cairo_atomic_ptr_cmpxchg (&_cairo_drm_default_device,
device, NULL))
@@ -191,7 +191,7 @@ cairo_drm_device_get (struct udev_device *device)
devid = udev_device_get_devnum (device);
- CAIRO_MUTEX_LOCK (_cairo_drm_device_mutex);
+ simpleops_mutex_lock (&_cairo_drm_device_mutex);
for (dev = _cairo_drm_known_devices; dev != NULL; dev = dev->next) {
if (dev->id == devid) {
dev = (cairo_drm_device_t *) cairo_device_reference (&dev->base);
@@ -247,7 +247,7 @@ cairo_drm_device_get (struct udev_device *device)
close (fd);
DONE:
- CAIRO_MUTEX_UNLOCK (_cairo_drm_device_mutex);
+ simpleops_mutex_unlock (&_cairo_drm_device_mutex);
return &dev->base;
}