[cairo] Recent pthread mutexes addition in cairo

Albert Chin cairo at mlists.thewrittenword.com
Fri Jul 8 17:26:23 PDT 2005


On Fri, Jul 08, 2005 at 07:17:09PM -0500, Albert Chin wrote:
> On Fri, Jul 08, 2005 at 08:07:32PM -0400, Jason Dorje Short wrote:
> > Jason Dorje Short wrote:
> > > Albert Chin wrote:
> > > 
> > >>We have access to a diverse set of systems so I tried to determine
> > >>what platforms would require -lpthread because of the recent addition
> > >>of the pthread_mutex_* functions for cache locking:
> > > 
> > > 
> > > I don't see what the purpose of this is.  Simply add an
> > > 
> > >   AC_CHECK_LIB([pthread], [pthread_mutex_init], [LIBS="-lpthread"], [])
> > > 
> > > to configure.ac and everything should be taken care of.
> > 
> > Or more specifically this patch should do it.  If pthread.h isn't
> > available then -lpthread isn't checked.  On my system this gives these
> > results:
> >
> > in "configure":
> > checking pthread.h usability... yes
> > checking pthread.h presence... yes
> > checking for pthread.h... yes
> > checking for pthread_mutex_init in -lpthread... yes
> 
> No. You do *not* want -lpthread. You don't need it if the stubs in
> libc are usable.

Untested but you want something like below.

-- 
albert chin (china at thewrittenword.com)

-- snip snip
Index: configure.in
===================================================================
RCS file: /cvs/cairo/cairo/configure.in,v
retrieving revision 1.109
diff -u -3 -p -r1.109 configure.in
--- configure.in	6 Jul 2005 18:23:39 -0000	1.109
+++ configure.in	9 Jul 2005 00:25:42 -0000
@@ -311,7 +311,48 @@ dnl ====================================
 # The FreeType backend uses pthread locking when avaialble
 #
 
-AC_CHECK_HEADERS([pthread.h])
+AC_CHECK_HEADERS([pthread.h], [
+  AC_MSG_CHECKING([if posix mutexes require -lpthread])
+  AC_TRY_RUN([
+#include <stdlib.h>
+#include <pthread.h>
+
+int main (void)
+{
+  pthread_mutex_t lck;
+  if (pthread_mutex_init(&lck, 0) != 0)
+    exit (1);
+  if (pthread_mutex_lock(&lck) != 0)
+    exit (1);
+  if (pthread_mutex_unlock(&lck) != 0)
+    exit (1);
+  if (pthread_mutex_destroy(&lck) != 0)
+    exit (1);
+  exit (0);
+}], [
+    AC_MSG_RESULT(no)], [
+    _libs=$LIBS
+    LIBS="$LIBS -lpthread"
+    AC_TRY_RUN([
+#include <stdlib.h>
+#include <pthread.h>
+
+int main (void)
+{
+  pthread_mutex_t lck;
+  if (pthread_mutex_init(&lck, 0) != 0)
+    exit (1);
+  if (pthread_mutex_lock(&lck) != 0)
+    exit (1);
+  if (pthread_mutex_unlock(&lck) != 0)
+    exit (1);
+  if (pthread_mutex_destroy(&lck) != 0)
+    exit (1);
+  exit (0);
+}], [
+      AC_MSG_RESULT(yes)], [
+      AC_MSG_RESULT(unavailable)
+      LIBS=$_libs])])
 
 dnl ===========================================================================
 



More information about the cairo mailing list