Skip to content

Commit

Permalink
build: Drop support for pthread_set_name_np()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dridi authored and walid-git committed Dec 23, 2024
1 parent 32935f5 commit 772d738
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
15 changes: 8 additions & 7 deletions bin/varnishd/cache/cache_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
}

Expand Down
1 change: 0 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

2 comments on commit 772d738

@catap
Copy link
Contributor

@catap catap commented on 772d738 Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@catap
Copy link
Contributor

@catap catap commented on 772d738 Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that OpenBSD hasn't got pthread_setname_np, instead it expects pthread_set_name_np.

Please sign in to comment.