]> Savannah Git Hosting - gnulib.git/commitdiff
lock, cond, thread, tls: Use a different symbol as libpthread witness.
authorBruno Haible <bruno@clisp.org>
Fri, 11 May 2018 00:07:00 +0000 (02:07 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 11 May 2018 00:07:00 +0000 (02:07 +0200)
Reported by Devin Hussey <husseydevin@gmail.com>.
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
lib/glthread/cond.h
lib/glthread/lock.h
lib/glthread/thread.h
lib/glthread/tls.h

index a07d9124812a697eab39c5511028fc0bcfeb720f..3d3924a1427ee123c7fdd208ffd09ee15f9ec05c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2018-05-10  Bruno Haible  <bruno@clisp.org>
+
+       lock, cond, thread, tls: Use a different symbol as libpthread witness.
+       Reported by Devin Hussey <husseydevin@gmail.com>.
+       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  <bruno@clisp.org>
 
        cond tests: Fix compilation error on Solaris.
index 54040ffc50271d15f9696d26faaa5d9cfebfb5e9..32a5f0343f23fb43f7a401559ee6c0cb6bb3dd85 100644 (file)
@@ -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
index dd8e1f86013e707793252d28e814f151bdff64e6..c4251c330bdf4c4b223b2827832e2ef68b2e98f6 100644 (file)
@@ -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
index d8098c4f88db0f6a92d5a3881cfc8059894c44a2..39a71de2f28581f5da61ddfbea3410044eb10f9b 100644 (file)
@@ -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
index 12bf6d5c97673cb25c6acdcacde6f8e0964a6801..af1fb3bba4694a77238381625f143ec74976c6bd 100644 (file)
@@ -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