[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: no pthread_spinlock_t on Mac OS 10.6.4
From: |
Gary V. Vaughan |
Subject: |
Re: no pthread_spinlock_t on Mac OS 10.6.4 |
Date: |
Tue, 21 Sep 2010 07:43:52 +0700 |
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 (address@hidden)
PGP.sig
Description: This is a digitally signed message part
- no pthread_spinlock_t on Mac OS 10.6.4, Gary V. Vaughan, 2010/09/19
- Re: no pthread_spinlock_t on Mac OS 10.6.4, Paul Eggert, 2010/09/20
- Re: no pthread_spinlock_t on Mac OS 10.6.4, Gary V. Vaughan, 2010/09/20
- Re: no pthread_spinlock_t on Mac OS 10.6.4, Paul Eggert, 2010/09/20
- Re: no pthread_spinlock_t on Mac OS 10.6.4,
Gary V. Vaughan <=
- Re: no pthread_spinlock_t on Mac OS 10.6.4, Paul Eggert, 2010/09/21
- Re: no pthread_spinlock_t on Mac OS 10.6.4, Bruno Haible, 2010/09/21
- Re: no pthread_spinlock_t on Mac OS 10.6.4, Paul Eggert, 2010/09/21
- Re: no pthread_spinlock_t on Mac OS 10.6.4, Bruno Haible, 2010/09/21
- Re: no pthread_spinlock_t on Mac OS 10.6.4, Paul Eggert, 2010/09/21
- Re: threadlib vs. pthread modules, Bruno Haible, 2010/09/22
- Re: threadlib vs. pthread modules, Paul Eggert, 2010/09/22
- Re: no pthread_spinlock_t on Mac OS 10.6.4, Paul Eggert, 2010/09/21
- Re: no pthread_spinlock_t on Mac OS 10.6.4, Gary V. Vaughan, 2010/09/22
- Re: no pthread_spinlock_t on Mac OS 10.6.4, Paul Eggert, 2010/09/22