From 0f336e1192a40a842b2e8ae04ee04fb85b7584bb Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 11 May 2018 02:07:00 +0200 Subject: [PATCH] lock, cond, thread, tls: Use a different symbol as libpthread witness. Reported by Devin Hussey . Based on a patch by Paul Eggert. * lib/glthread/lock.h (pthread_in_use): Use 'pthread_mutexattr_gettype' as witness of libpthread. * lib/glthread/cond.h (pthread_in_use): Likewise. * lib/glthread/thread.h (pthread_in_use): Likewise. * lib/glthread/tls.h (pthread_in_use): Likewise. --- ChangeLog | 11 +++++++++++ lib/glthread/cond.h | 4 ++-- lib/glthread/lock.h | 20 ++++++++------------ lib/glthread/thread.h | 4 ++-- lib/glthread/tls.h | 4 ++-- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index a07d912481..3d3924a142 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2018-05-10 Bruno Haible + + lock, cond, thread, tls: Use a different symbol as libpthread witness. + Reported by Devin Hussey . + Based on a patch by Paul Eggert. + * lib/glthread/lock.h (pthread_in_use): Use 'pthread_mutexattr_gettype' + as witness of libpthread. + * lib/glthread/cond.h (pthread_in_use): Likewise. + * lib/glthread/thread.h (pthread_in_use): Likewise. + * lib/glthread/tls.h (pthread_in_use): Likewise. + 2018-05-10 Bruno Haible cond tests: Fix compilation error on Solaris. diff --git a/lib/glthread/cond.h b/lib/glthread/cond.h index 54040ffc50..32a5f0343f 100644 --- a/lib/glthread/cond.h +++ b/lib/glthread/cond.h @@ -114,8 +114,8 @@ extern int glthread_in_use (void); # endif # if !PTHREAD_IN_USE_DETECTION_HARD -# pragma weak pthread_cancel -# define pthread_in_use() (pthread_cancel != NULL) +# pragma weak pthread_mutexattr_gettype +# define pthread_in_use() (pthread_mutexattr_gettype != NULL) # endif # else diff --git a/lib/glthread/lock.h b/lib/glthread/lock.h index dd8e1f8601..c4251c330b 100644 --- a/lib/glthread/lock.h +++ b/lib/glthread/lock.h @@ -149,18 +149,14 @@ extern int glthread_in_use (void); # endif # if !PTHREAD_IN_USE_DETECTION_HARD - /* On most platforms, pthread_cancel or pthread_kill can be used to - determine whether libpthread is in use. - On newer versions of FreeBSD, however, this is no longer possible, - because pthread_cancel and pthread_kill got added to libc. Therefore - use pthread_create to test whether libpthread is in use. */ -# if defined __FreeBSD__ || defined __DragonFly__ /* FreeBSD */ -# pragma weak pthread_create -# define pthread_in_use() (pthread_create != NULL) -# else /* glibc, NetBSD, OpenBSD, IRIX, OSF/1, Solaris */ -# pragma weak pthread_cancel -# define pthread_in_use() (pthread_cancel != NULL) -# endif + /* Considering all platforms with USE_POSIX_THREADS_WEAK, only few symbols + can be used to determine whether libpthread is in use. These are: + pthread_mutexattr_gettype + pthread_rwlockattr_destroy + pthread_rwlockattr_init + */ +# pragma weak pthread_mutexattr_gettype +# define pthread_in_use() (pthread_mutexattr_gettype != NULL) # endif # else diff --git a/lib/glthread/thread.h b/lib/glthread/thread.h index d8098c4f88..39a71de2f2 100644 --- a/lib/glthread/thread.h +++ b/lib/glthread/thread.h @@ -149,8 +149,8 @@ extern int glthread_in_use (void); # endif # if !PTHREAD_IN_USE_DETECTION_HARD -# pragma weak pthread_cancel -# define pthread_in_use() (pthread_cancel != NULL) +# pragma weak pthread_mutexattr_gettype +# define pthread_in_use() (pthread_mutexattr_gettype != NULL) # endif # else diff --git a/lib/glthread/tls.h b/lib/glthread/tls.h index 12bf6d5c97..af1fb3bba4 100644 --- a/lib/glthread/tls.h +++ b/lib/glthread/tls.h @@ -76,8 +76,8 @@ extern int glthread_in_use (void); # endif # if !PTHREAD_IN_USE_DETECTION_HARD -# pragma weak pthread_cancel -# define pthread_in_use() (pthread_cancel != NULL) +# pragma weak pthread_mutexattr_gettype +# define pthread_in_use() (pthread_mutexattr_gettype != NULL) # endif # else -- 2.39.5