Subject: Re: no pthread_spinlock_t on Mac OS 10.6.4

From: Paul Eggert <[email-masked]>
Date: Mon, 20 Sep 2010 10:30:17 -0700

On 09/20/10 00:14, Gary V. Vaughan wrote:

> lib/pthread.h does have a typedef for pthread_spinlock_t, but it is predicated on not having HAVE_PTHREAD_T defined (which I do):

Ah, OK.  Could you try the following patch instead?  If you have a
similar problem with (say) pthread_rwlockattr_t, you can treat it just
like pthread_spinlock_t in lib/pthread.in.h and m4/pthread.m4; please
just let us know which types those are.  I'd
rather not add compile-time checks for each dinky little pthread type
unless it's known to be needed, as 'configure' takes too long already.

diff --git a/lib/pthread.in.h b/lib/pthread.in.h
index 4dad22a..84cf913 100644
--- a/lib/pthread.in.h
+++ b/lib/pthread.in.h
@@ -40,6 +40,8 @@
  typedef int pthread_once_t;
  typedef int pthread_rwlock_t;
  typedef int pthread_rwlockattr_t;
+#endif
+#ifndef HAVE_PTHREAD_SPINLOCK_T
  typedef int pthread_spinlock_t;
 #endif
 
diff --git a/m4/pthread.m4 b/m4/pthread.m4
index 69866cb..a2781eb 100644
--- a/m4/pthread.m4
+++ b/m4/pthread.m4
@@ -6,19 +6,21 @@ dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_PTHREAD_CHECK],
   [AC_CHECK_HEADERS_ONCE([pthread.h])
+   gl_keep_pthread_h=$ac_cv_header_pthread_h
+   AC_CHECK_TYPES([pthread_t, pthread_spinlock_t],
+     [],
+     [gl_keep_pthread_h=no])
 
+   PTHREAD_H='pthread.h'
    LIB_PTHREAD=
-   PTHREAD_H=
-   if test "$ac_cv_header_pthread_h" = yes; then
+   if test "$gl_keep_pthread_h" = yes; then
+     PTHREAD_H=
      gl_saved_libs=$LIBS
      AC_SEARCH_LIBS([pthread_create], [pthread],
        [if test "$ac_cv_search_pthread_create" != "none required"; then
           LIB_PTHREAD="$ac_cv_search_pthread_create"
         fi])
      LIBS="$gl_saved_libs"
-   else
-     AC_CHECK_TYPES([pthread_t])
-     PTHREAD_H='pthread.h'
    fi
 
    AC_SUBST([LIB_PTHREAD])