Mercurial > gnulib
changeset 39246:ef22bb0a9591
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'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 17 Feb 2018 10:23:35 +0100 |
parents | f6cb783d3822 |
children | 2a1fb875b76e |
files | ChangeLog lib/glthread/lock.h |
diffstat | 2 files changed, 18 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sat Feb 17 10:05:01 2018 +0100 +++ b/ChangeLog Sat Feb 17 10:23:35 2018 +0100 @@ -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.
--- a/lib/glthread/lock.h Sat Feb 17 10:05:01 2018 +0100 +++ b/lib/glthread/lock.h Sat Feb 17 10:23:35 2018 +0100 @@ -149,8 +149,18 @@ # 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