[babl] Make BablMutex recursive on all platforms.



commit 6bf8a87b83f56e26d947acd5fab78370c4902a26
Author: Nils Philippsen <nils redhat com>
Date:   Fri Feb 13 13:24:52 2015 +0100

    Make BablMutex recursive on all platforms.
    
    Win32 Critical Sections are recursive locks, initialize pthread mutexes
    as recursive as well.

 babl.pc.in             |    3 ++-
 babl/Makefile.am       |    2 +-
 babl/babl-mutex.c      |    7 ++++++-
 configure.ac           |    3 +++
 extensions/Makefile.am |    3 ++-
 tests/Makefile.am      |    2 +-
 tools/Makefile.am      |    4 ++--
 7 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/babl.pc.in b/babl.pc.in
index 76b5e69..3f2049f 100644
--- a/babl.pc.in
+++ b/babl.pc.in
@@ -7,4 +7,5 @@ Name: babl
 Description: Dynamic, any to any, pixel format conversion library
 Version: @BABL_REAL_VERSION@
 Cflags: -I${includedir}/@PACKAGE_NAME -@BABL_API_VERSION@
-Libs: -L${libdir} -l PACKAGE_NAME@- BABL_API_VERSION@ @MATH_LIB@
+Libs: -L${libdir} -l PACKAGE_NAME@- BABL_API_VERSION@
+Libs.private: @MATH_LIB@ @THREAD_LIB@
diff --git a/babl/Makefile.am b/babl/Makefile.am
index 4f59447..6827faa 100644
--- a/babl/Makefile.am
+++ b/babl/Makefile.am
@@ -86,7 +86,7 @@ libbabl_ BABL_API_VERSION@_la_LIBADD=\
        @LTLIBOBJS@
 
 libbabl_ BABL_API_VERSION@_la_LDFLAGS=                 \
-       ${no_undefined} $(MATH_LIB)     \
+       ${no_undefined} $(MATH_LIB) $(THREAD_LIB) \
        -version-info $(BABL_LIBRARY_VERSION)
 
 EXTRA_DIST = babl-ref-pixels.inc
diff --git a/babl/babl-mutex.c b/babl/babl-mutex.c
index 3f82cc5..eacd372 100644
--- a/babl/babl-mutex.c
+++ b/babl/babl-mutex.c
@@ -30,7 +30,12 @@ babl_mutex_new (void)
 #ifdef _WIN32
   InitializeCriticalSection (mutex);
 #else
-  pthread_mutex_init (mutex, NULL);
+  pthread_mutexattr_t mutexattr;
+
+  pthread_mutexattr_init (&mutexattr);
+  pthread_mutexattr_settype (&mutexattr, PTHREAD_MUTEX_RECURSIVE);
+  pthread_mutex_init (mutex, &mutexattr);
+  pthread_mutexattr_destroy (&mutexattr);
 #endif
   return mutex;
 }
diff --git a/configure.ac b/configure.ac
index cffdbfc..5e60760 100644
--- a/configure.ac
+++ b/configure.ac
@@ -254,6 +254,7 @@ AC_MSG_RESULT([$platform_win32])
 AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
 
 MATH_LIB=-lm
+THREAD_LIB=-lpthread
 AC_MSG_CHECKING([for native Win32])
 case "$target_or_host" in
   *-*-mingw*)
@@ -261,6 +262,7 @@ case "$target_or_host" in
     PATH_SEP=';'
     DIR_SEP='\\'
     MATH_LIB=
+    THREAD_LIB=
     ;;
   *)
     os_win32=no
@@ -272,6 +274,7 @@ AC_MSG_RESULT([$os_win32])
 AC_SUBST(PATH_SEP)
 AC_SUBST(DIR_SEP)
 AC_SUBST(MATH_LIB)
+AC_SUBST(THREAD_LIB)
 
 AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
 AM_CONDITIONAL(OS_UNIX, test "$os_win32" != "yes")
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
index 3954739..4a3fb8a 100644
--- a/extensions/Makefile.am
+++ b/extensions/Makefile.am
@@ -53,7 +53,8 @@ ycbcr_la_SOURCES = ycbcr.c
 float_la_SOURCES = float.c
 fast_float_la_SOURCES = fast-float.c
 
-LIBS = $(top_builddir)/babl/libbabl- BABL_API_VERSION@.la $(MATH_LIB)
+LIBS = $(top_builddir)/babl/libbabl- BABL_API_VERSION@.la $(MATH_LIB) \
+       $(THREAD_LIB)
 
 sse2_float_la_CFLAGS = $(SSE2_EXTRA_CFLAGS)
 sse2_int8_la_CFLAGS = $(SSE2_EXTRA_CFLAGS)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2733a28..6e282af 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -35,7 +35,7 @@ AM_LDFLAGS  = -pthread
 endif
 
 LDADD = $(top_builddir)/babl/libbabl- BABL_API_VERSION@.la \
-       $(MATH_LIB)
+       $(MATH_LIB) $(THREAD_LIB)
 
 EXTRA_DIST=common.inc
 
diff --git a/tools/Makefile.am b/tools/Makefile.am
index f67a66e..ad54455 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,9 +1,9 @@
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/babl
 
 LDADD = $(top_builddir)/babl/libbabl- BABL_API_VERSION@.la \
-       $(MATH_LIB)
+       $(MATH_LIB) $(THREAD_LIB)
 
 if HAVE_SRANDOM
 noinst_PROGRAMS =              \
        babl-gen-test-pixels
-endif
\ No newline at end of file
+endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]