[cairo-commit] 3 commits - src/cairo-mutex.c src/cairo-mutex-private.h src/cairo-os2-surface.c src/cairo-win32-surface.c

Mathias Hasselmann hasselmm at kemper.freedesktop.org
Thu Apr 19 04:38:42 PDT 2007


 src/cairo-mutex-private.h |    8 +++++++-
 src/cairo-mutex.c         |   14 ++++++++++++++
 src/cairo-os2-surface.c   |    6 +++---
 src/cairo-win32-surface.c |   30 ++++++++++++++++++++++++++++++
 4 files changed, 54 insertions(+), 4 deletions(-)

New commits:
diff-tree 39a633a8f3618f3b1adb3eefdf36e2fc6d896054 (from 9b348929b51fb45f5985914350a10955d6df17ae)
Author: Mathias Hasselmann <mathias.hasselmann at gmx.de>
Date:   Thu Apr 19 13:15:08 2007 +0200

    Reintroduce DllMain as deterministic mutex initialization path

diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index 5d233a5..e680715 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -1900,3 +1900,33 @@ static const cairo_surface_backend_t cai
  *              it will still copy over the src alpha, because the SCA value (255) will be
  *              multiplied by all the src components.
  */
+
+
+#if !defined(CAIRO_WIN32_STATIC_BUILD)
+
+/* declare to avoid "no previous prototype for 'DllMain'" warning */
+BOOL WINAPI
+DllMain (HINSTANCE hinstDLL,
+         DWORD     fdwReason,
+         LPVOID    lpvReserved);
+
+BOOL WINAPI
+DllMain (HINSTANCE hinstDLL,
+         DWORD     fdwReason,
+         LPVOID    lpvReserved)
+{
+    switch (fdwReason) {
+        case DLL_PROCESS_ATTACH:
+            CAIRO_MUTEX_INITIALIZE ();
+            break;
+
+        case DLL_PROCESS_DETACH:
+            CAIRO_MUTEX_FINALIZE ();
+            break;
+    }
+
+    return TRUE;
+}
+
+#endif
+
diff-tree 9b348929b51fb45f5985914350a10955d6df17ae (from 67767afa09e3622988b9ac67b754114ea9f84105)
Author: Mathias Hasselmann <mathias.hasselmann at gmx.de>
Date:   Thu Apr 19 13:13:42 2007 +0200

    Introduce CAIRO_MUTEX_FINALIZE as counter-part for CAIRO_MUTEX_INITIALIZE

diff --git a/src/cairo-mutex-private.h b/src/cairo-mutex-private.h
index 80f5644..73ca9b3 100644
--- a/src/cairo-mutex-private.h
+++ b/src/cairo-mutex-private.h
@@ -140,11 +140,17 @@ CAIRO_BEGIN_DECLS
 
 #define CAIRO_MUTEX_INITIALIZE() do { \
     if (!_cairo_mutex_initialized) \
-        _cairo_mutex_initialize(); \
+        _cairo_mutex_initialize (); \
+} while(0)
+
+#define CAIRO_MUTEX_FINALIZE() do { \
+    if (_cairo_mutex_initialized) \
+        _cairo_mutex_finalize (); \
 } while(0)
 
 cairo_private extern cairo_bool_t _cairo_mutex_initialized;
 cairo_private void _cairo_mutex_initialize(void);
+cairo_private void _cairo_mutex_finalize(void);
 
 #endif
 
diff --git a/src/cairo-mutex.c b/src/cairo-mutex.c
index 1dc9c93..03b08e5 100644
--- a/src/cairo-mutex.c
+++ b/src/cairo-mutex.c
@@ -52,4 +52,16 @@ void _cairo_mutex_initialize (void)
 #undef CAIRO_MUTEX_DECLARE
 }
 
+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-os2-surface.c b/src/cairo-os2-surface.c
index b2933a5..319a7ab 100644
--- a/src/cairo-os2-surface.c
+++ b/src/cairo-os2-surface.c
@@ -98,6 +98,8 @@ cairo_os2_init (void)
 
     /* Initialize FontConfig */
     FcInit ();
+
+    CAIRO_MUTEX_INITIALIZE ();
 }
 
 cairo_public void
@@ -118,9 +120,7 @@ cairo_os2_fini (void)
     _cairo_ft_font_reset_static_data ();
 #endif
 
-#define CAIRO_MUTEX_DECLARE(name) CAIRO_MUTEX_FINI(name)
-#include "cairo-mutex-list-private.h"
-#undef CAIRO_MUTEX_DECLARE
+    CAIRO_MUTEX_FINALIZE ();
 
     /* Uninitialize FontConfig */
     FcFini ();
diff-tree 67767afa09e3622988b9ac67b754114ea9f84105 (from 41c6eebcd1fab94fd3a91d09f1ef6ee0d8c7a044)
Author: Mathias Hasselmann <mathias.hasselmann at gmx.de>
Date:   Thu Apr 19 12:35:10 2007 +0200

    Update _cairo_mutex_initialized during initialization.

diff --git a/src/cairo-mutex.c b/src/cairo-mutex.c
index 2b0f537..1dc9c93 100644
--- a/src/cairo-mutex.c
+++ b/src/cairo-mutex.c
@@ -45,6 +45,8 @@ 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


More information about the cairo-commit mailing list