GNU bug report logs - #7073
no pthread_spinlock_t on Mac OS 10.6.4

Previous Next

Package: coreutils;

Reported by: "Gary V. Vaughan" <gary <at> gnu.org>

Date: Mon, 20 Sep 2010 05:52:01 UTC

Severity: normal

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #41 received at 7073 <at> debbugs.gnu.org (full text, mbox):

From: "Gary V. Vaughan" <gary <at> gnu.org>
To: Paul Eggert <eggert <at> CS.UCLA.EDU>
Cc: bug-gnulib List <bug-gnulib <at> gnu.org>, bug-coreutils <at> gnu.org,
	7073 <at> debbugs.gnu.org
Subject: Re: no pthread_spinlock_t on Mac OS 10.6.4
Date: Tue, 21 Sep 2010 07:43:52 +0700
[Message part 1 (text/plain, inline)]
Hi Paul,

On 21 Sep 2010, at 00:30, Paul Eggert wrote:
> 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?

The patch you attached allows compilation to complete on my mac, and produces a working (according to my very cursory testing!) sort binary.

I notice the following warnings though:

../../lib/glthread/lock.c: In function 'glthread_recursive_lock_init_multithreaded':
../../lib/glthread/lock.c:319: warning: implicit declaration of function 'pthread_mutexattr_init'
../../lib/glthread/lock.c:322: warning: implicit declaration of function 'pthread_mutexattr_settype'
../../lib/glthread/lock.c:325: warning: implicit declaration of function 'pthread_mutexattr_destroy'

Which is odd, because /usr/include/pthread.h contains (unguarded) prototypes for all those functions - so I assume the system pthread.h is either being mangled, or entirely skipped when glthread/lock.c includes the gnulib/pthread.h?

* time passes *

Hmm... looking at gnulib/pthread.h, am I right in assuming that threads are now effectively disabled by gnulib on the mac in favour of a selection of stub functions?  In which case, I suppose those warnings indicate that glthread/lock.c may attempt to call unstubbed functions along some codepath and will then crash.

> 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])

Cheers,
-- 
Gary V. Vaughan (gary <at> gnu.org)

[PGP.sig (application/pgp-signature, inline)]

This bug report was last modified 6 years and 201 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.