From 772d7385dbe2cfa8b70d98af0b5da1236727e58b Mon Sep 17 00:00:00 2001 From: Dridi Boukelmoune Date: Tue, 7 May 2024 09:58:06 +0200 Subject: [PATCH] build: Drop support for pthread_set_name_np() We can rely on pthread_setname_np() for all the platforms we care about. The nested preprocessor conditions for pthread_setname_np are indented to improve readability. Better diff with the --ignore-all-space option. --- bin/varnishd/cache/cache_main.c | 15 ++++++++------- configure.ac | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 91fbdf6b38..c71a6a108c 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -130,6 +130,8 @@ THR_GetWorker(void) static pthread_key_t name_key; +#if defined(HAVE_PTHREAD_SETNAME_NP) && !defined(__APPLE__) && \ + !defined(__NetBSD__) static void thr_setname_generic(const char *name) { @@ -146,22 +148,21 @@ thr_setname_generic(const char *name) //lint --e{438} Last value assigned not used PTOK(pthread_setname_np(pthread_self(), name)); } +#endif void THR_SetName(const char *name) { PTOK(pthread_setspecific(name_key, name)); -#if defined(HAVE_PTHREAD_SET_NAME_NP) - pthread_set_name_np(pthread_self(), name); -#elif defined(HAVE_PTHREAD_SETNAME_NP) -#if defined(__APPLE__) +#if defined(HAVE_PTHREAD_SETNAME_NP) +# if defined(__APPLE__) (void)pthread_setname_np(name); -#elif defined(__NetBSD__) +# elif defined(__NetBSD__) (void)pthread_setname_np(pthread_self(), "%s", (char *)(uintptr_t)name); -#else +# else thr_setname_generic(name); -#endif +# endif #endif } diff --git a/configure.ac b/configure.ac index 54b8c9f3ae..3f7b252571 100644 --- a/configure.ac +++ b/configure.ac @@ -227,7 +227,6 @@ AC_CHECK_FUNCS([fnmatch], [], [AC_MSG_ERROR([fnmatch(3) is required])]) save_LIBS="${LIBS}" LIBS="${PTHREAD_LIBS}" -AC_CHECK_FUNCS([pthread_set_name_np]) AC_CHECK_FUNCS([pthread_setname_np]) AC_CHECK_FUNCS([pthread_mutex_isowned_np]) AC_CHECK_FUNCS([pthread_getattr_np])