diff options
author | Sam James <sam@gentoo.org> | 2022-09-13 19:37:59 +0100 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-09-15 20:45:42 +0300 |
commit | 4489757f1cc1fe4aa98d4c1ebbe0789b2b308e11 (patch) | |
tree | 0c2db842b736ebd346658677c6d8d8575e8efd66 /configure.ac | |
parent | afbb7e51cb286d899d48f67119f1dfa8e956715e (diff) | |
download | bdwgc-4489757f1cc1fe4aa98d4c1ebbe0789b2b308e11.tar.gz |
Fix 'call to undeclared pthread_setname_np' errors in configure and cmake
Issue #474 (bdwgc).
Clang 15 makes implicit function declarations an error by default
which leads to configure (and cmake script) falsely thinking
pthread_setname_np symbol is not present.
* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT] (check_c_source_compiles):
Always define _GNU_SOURCE before include pthread.h (regardless of
__CYGWIN__, __linux__, __GLIBC__, __GNU__ macros).
* configure.ac [$THREADS==posix] (AC_COMPILE_IFELSE): Likewise.
* include/private/gc_priv.h [!_GNU_SOURCE
&& (HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID
|| HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG
|| HAVE_PTHREAD_SETNAME_NP_WITH_TID)] (_GNU_SOURCE): Define.
Co-authored-by: Ivan Maidanski <ivmai@mail.ru>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/configure.ac b/configure.ac index 1293b037..02b8abb3 100644 --- a/configure.ac +++ b/configure.ac @@ -833,25 +833,25 @@ AS_IF([test "$THREADS" = posix], [AC_MSG_CHECKING(for pthread_setname_np) old_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $CFLAGS_EXTRA -Werror" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>], - [pthread_setname_np("thread-name")])], + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +# define _GNU_SOURCE 1 +# include <pthread.h> + ], [pthread_setname_np("thread-name")])], [AC_MSG_RESULT([yes (w/o tid)]) AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID], [1], [Define to use 'pthread_setname_np(const char*)' function.])], - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>], - [pthread_setname_np(pthread_self(), "thread-name-%u", 0)])], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +# define _GNU_SOURCE 1 +# include <pthread.h> + ], [pthread_setname_np(pthread_self(), "thread-name-%u", 0)])], [AC_MSG_RESULT([yes (with tid and arg)]) AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG], [1], [Define to use 'pthread_setname_np(pthread_t, const char*, void *)' function.])], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ -# ifdef __CYGWIN__ -# define _GNU_SOURCE 1 -# elif defined(__linux__) || defined(__GLIBC__) || defined(__GNU__) -# define _GNU_SOURCE 1 -# endif -# include <pthread.h> - ], [pthread_setname_np(pthread_self(), "thread-name")])], +# define _GNU_SOURCE 1 +# include <pthread.h> + ], [pthread_setname_np(pthread_self(), "thread-name")])], [AC_MSG_RESULT([yes (with tid)]) AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITH_TID], [1], [Define to use 'pthread_setname_np(pthread_t, const char*)' |