From 3b1e0bcd35f006ea401d3dbd2169fd75f31bee3b Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 17 Feb 2018 10:23:35 +0100 Subject: [PATCH] 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'. --- ChangeLog | 6 ++++++ lib/glthread/lock.h | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ba57230b20..82d3f796bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018-02-17 Bruno Haible + + 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 lock: Add test of gl_once. diff --git a/lib/glthread/lock.h b/lib/glthread/lock.h index 87d9df1152..dd8e1f8601 100644 --- a/lib/glthread/lock.h +++ b/lib/glthread/lock.h @@ -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 -- 2.39.5