[cairo-commit] 4 commits - src/cairo-beos-surface.cpp src/cairo-mutex-private.h

Behdad Esfahbod behdad at kemper.freedesktop.org
Sun Apr 22 13:13:14 PDT 2007


 src/cairo-beos-surface.cpp |   34 ----------------------------------
 src/cairo-mutex-private.h  |   38 ++++++++++++++++++--------------------
 2 files changed, 18 insertions(+), 54 deletions(-)

New commits:
diff-tree ce91a176489f4cb8f40c5ec29f23881d1e013a9f (from 97b50e99bfa785d77b4900d3070f22a22827db22)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Apr 22 16:13:22 2007 -0400

    [cairo-mutex] Add a poor man's mutex implementation in case of CAIRO_NO_MUTEX
    just for fun.

diff --git a/src/cairo-mutex-private.h b/src/cairo-mutex-private.h
index 9277010..9b9adba 100644
--- a/src/cairo-mutex-private.h
+++ b/src/cairo-mutex-private.h
@@ -57,11 +57,14 @@ CAIRO_BEGIN_DECLS
 
 #if CAIRO_NO_MUTEX
 
-typedef int cairo_mutex_t;
-# define CAIRO_MUTEX_INITIALIZE()	CAIRO_MUTEX_NOOP
-# define CAIRO_MUTEX_LOCK(name)		CAIRO_MUTEX_NOOP
-# define CAIRO_MUTEX_UNLOCK(name)	CAIRO_MUTEX_NOOP
-# define CAIRO_MUTEX_NIL_INITIALIZER	0
+/* A poor man's mutex */
+
+  typedef int cairo_mutex_t;
+
+# define CAIRO_MUTEX_INITIALIZE() CAIRO_MUTEX_NOOP
+# define CAIRO_MUTEX_LOCK(name) do { while (name) ; (name) = 1; } while (0)
+# define CAIRO_MUTEX_UNLOCK(name) (name) = 0
+# define CAIRO_MUTEX_NIL_INITIALIZER 0
 
 #elif HAVE_PTHREAD_H /*******************************************************/
 
diff-tree 97b50e99bfa785d77b4900d3070f22a22827db22 (from 0fd13a3db00e7e11915b5a7bbe81bf8f43f1941f)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Apr 22 16:05:25 2007 -0400

    [BeOS] Remove old-style mutex initialization cruft

diff --git a/src/cairo-beos-surface.cpp b/src/cairo-beos-surface.cpp
index e0ff297..abf094a 100644
--- a/src/cairo-beos-surface.cpp
+++ b/src/cairo-beos-surface.cpp
@@ -977,37 +977,3 @@ cairo_beos_surface_create_for_bitmap (BV
 {
     return _cairo_beos_surface_create_internal(view, bmp);
 }
-
-// ---------------------------------------------------------------------------
-// Cairo uses locks without explicit initialization. To support that, we
-// provide a class here which manages the locks and is in global scope, so the
-// compiler will instantiate it on library load and destroy it on library
-// unload.
-
-class BeLocks {
-    public:
-	BLocker _cairo_font_face_mutex;
-	BLocker _cairo_scaled_font_map_mutex;
-#ifdef CAIRO_HAS_FT_FONT
-	BLocker _cairo_ft_unscaled_font_map_mutex;
-#endif
-};
-
-static BeLocks locks;
-
-void* _cairo_font_face_mutex = &locks._cairo_font_face_mutex;
-void* _cairo_scaled_font_map_mutex = &locks._cairo_scaled_font_map_mutex;
-#ifdef CAIRO_HAS_FT_FONT
-void* _cairo_ft_unscaled_font_map_mutex = &locks._cairo_ft_unscaled_font_map_mutex;
-#endif
-
-void _cairo_beos_lock (void* locker) {
-    BLocker* bLocker = reinterpret_cast<BLocker*>(locker);
-    bLocker->Lock();
-}
-
-void _cairo_beos_unlock (void* locker) {
-    BLocker* bLocker = reinterpret_cast<BLocker*>(locker);
-    bLocker->Unlock();
-}
-
diff-tree 0fd13a3db00e7e11915b5a7bbe81bf8f43f1941f (from fc83784525d3f2bb3e09d931cc9c83261c0b73ae)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Apr 22 16:04:49 2007 -0400

    [BeOS] Add mutex implementation

diff --git a/src/cairo-mutex-private.h b/src/cairo-mutex-private.h
index b7db102..9277010 100644
--- a/src/cairo-mutex-private.h
+++ b/src/cairo-mutex-private.h
@@ -120,18 +120,13 @@ typedef int cairo_mutex_t;
 
 #elif CAIRO_HAS_BEOS_SURFACE /***********************************************/
 
-  typedef void* cairo_mutex_t;
+  typedef BLocker* cairo_mutex_t;
 
-  cairo_private void _cairo_beos_lock(cairo_mutex_t*);
-  cairo_private void _cairo_beos_unlock(cairo_mutex_t*);
-
-/* the real initialization takes place in a global constructor */
-# define CAIRO_MUTEX_LOCK(name) _cairo_beos_lock (&(name))
-# define CAIRO_MUTEX_UNLOCK(name) _cairo_beos_unlock (&(name))
-
-# warning "XXX: Someone who understands BeOS needs to add definitions for" \
-          "     cairo_mutex_t, CAIRO_MUTEX_INIT, and CAIRO_MUTEX_FINI," \
-          "     and CAIRO_MUTEX_NIL_INITIALIZER to cairo-mutex-private.h"
+# define CAIRO_MUTEX_LOCK(name) (name)->Lock()
+# define CAIRO_MUTEX_UNLOCK(name) (name)->Unlock()
+# define CAIRO_MUTEX_INIT(mutex) (*(mutex)) = new BLocker()
+# define CAIRO_MUTEX_FINI(mutex) delete (*(mutex))
+# define CAIRO_MUTEX_NIL_INITIALIZER NULL
 
 #else /**********************************************************************/
 
diff-tree fc83784525d3f2bb3e09d931cc9c83261c0b73ae (from 406fc63b68203e86c9236d06448e2ffa2c259669)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Apr 22 15:56:18 2007 -0400

    [cairo-mutex] Properly paranthesize macro arguments

diff --git a/src/cairo-mutex-private.h b/src/cairo-mutex-private.h
index 1e0c068..b7db102 100644
--- a/src/cairo-mutex-private.h
+++ b/src/cairo-mutex-private.h
@@ -70,8 +70,8 @@ typedef int cairo_mutex_t;
   typedef pthread_mutex_t cairo_mutex_t;
 
 # define CAIRO_MUTEX_INITIALIZE() CAIRO_MUTEX_NOOP
-# define CAIRO_MUTEX_LOCK(name) pthread_mutex_lock (&name)
-# define CAIRO_MUTEX_UNLOCK(name) pthread_mutex_unlock (&name)
+# define CAIRO_MUTEX_LOCK(name) pthread_mutex_lock (&(name))
+# define CAIRO_MUTEX_UNLOCK(name) pthread_mutex_unlock (&(name))
 # define CAIRO_MUTEX_FINI(mutex) pthread_mutex_destroy (mutex)
 # define CAIRO_MUTEX_NIL_INITIALIZER PTHREAD_MUTEX_INITIALIZER
 
@@ -93,8 +93,8 @@ typedef int cairo_mutex_t;
 
   typedef CRITICAL_SECTION cairo_mutex_t;
 
-# define CAIRO_MUTEX_LOCK(name) EnterCriticalSection (&name)
-# define CAIRO_MUTEX_UNLOCK(name) LeaveCriticalSection (&name)
+# define CAIRO_MUTEX_LOCK(name) EnterCriticalSection (&(name))
+# define CAIRO_MUTEX_UNLOCK(name) LeaveCriticalSection (&(name))
 # define CAIRO_MUTEX_INIT(mutex) InitializeCriticalSection (mutex)
 # define CAIRO_MUTEX_FINI(mutex) DeleteCriticalSection (mutex)
 # define CAIRO_MUTEX_NIL_INITIALIZER { NULL, 0, 0, NULL, NULL, 0 }
@@ -126,8 +126,8 @@ typedef int cairo_mutex_t;
   cairo_private void _cairo_beos_unlock(cairo_mutex_t*);
 
 /* the real initialization takes place in a global constructor */
-# define CAIRO_MUTEX_LOCK(name) _cairo_beos_lock (&name)
-# define CAIRO_MUTEX_UNLOCK(name) _cairo_beos_unlock (&name)
+# define CAIRO_MUTEX_LOCK(name) _cairo_beos_lock (&(name))
+# define CAIRO_MUTEX_UNLOCK(name) _cairo_beos_unlock (&(name))
 
 # warning "XXX: Someone who understands BeOS needs to add definitions for" \
           "     cairo_mutex_t, CAIRO_MUTEX_INIT, and CAIRO_MUTEX_FINI," \


More information about the cairo-commit mailing list