]> Savannah Git Hosting - gnulib.git/commitdiff
lock: Fix test-once1 crash on FreeBSD11.
authorBruno Haible <bruno@clisp.org>
Sat, 17 Feb 2018 09:23:35 +0000 (10:23 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 17 Feb 2018 09:23:35 +0000 (10:23 +0100)
* lib/glthread/lock.h: On FreeBSD, test the weak value of the symbol
'pthread_create', not 'pthread_cancel'.

ChangeLog
lib/glthread/lock.h

index ba57230b2082fe4438bbc84ec71e8e68fcb9eee0..82d3f796bff6f12a05bd8621278901e7468f0a21 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-17  Bruno Haible  <bruno@clisp.org>
+
+       lock: Fix test-once1 crash on FreeBSD11.
+       * lib/glthread/lock.h: On FreeBSD, test the weak value of the symbol
+       'pthread_create', not 'pthread_cancel'.
+
 2018-02-17  Bruno Haible  <bruno@clisp.org>
 
        lock: Add test of gl_once.
index 87d9df1152351a629eaaad972ced258d15ccfb76..dd8e1f86013e707793252d28e814f151bdff64e6 100644 (file)
@@ -149,8 +149,18 @@ extern int glthread_in_use (void);
 #  endif
 
 #  if !PTHREAD_IN_USE_DETECTION_HARD
-#   pragma weak pthread_cancel
-#   define pthread_in_use() (pthread_cancel != NULL)
+    /* 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
 #  endif
 
 # else