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])