[cairo] Recent pthread mutexes addition in cairo

Jason Dorje Short jdorje at users.sf.net
Fri Jul 8 17:34:52 PDT 2005


Albert Chin wrote:
> 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.

Ahh, now I understand.

The problem with AC_TRY_RUN is it won't work when cross-compiling.
Would an AC_LINK_IFELSE check be sufficient?

http://www.gnu.org/software/autoconf/manual/autoconf-2.57/html_chapter/autoconf_6.html#SEC77

-jason
-------------- next part --------------
Index: configure.in
===================================================================
RCS file: /cvs/cairo/cairo/configure.in,v
retrieving revision 1.109
diff -p -u -r1.109 configure.in
--- configure.in	6 Jul 2005 18:23:39 -0000	1.109
+++ configure.in	9 Jul 2005 00:32:47 -0000
@@ -311,7 +311,27 @@ dnl ====================================
 # The FreeType backend uses pthread locking when avaialble
 #
 
-AC_CHECK_HEADERS([pthread.h])
+AC_CHECK_HEADERS([pthread.h],
+                 [AC_LINK_IFELSE(
+[
+#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);
+}
+], [], [CAIRO_LIBS="$CAIRO_LIBS -lpthread"])])
 
 dnl ===========================================================================
 


More information about the cairo mailing list