mirror of
https://github.com/Icinga/icinga2.git
synced 2026-02-03 20:40:17 -05:00
Merge pull request #10641 from brad0/netbsd_pthread_setname_np
Some checks are pending
Container Image / Container Image (push) Waiting to run
Linux / alpine:bash (push) Waiting to run
Linux / amazonlinux:2 (push) Waiting to run
Linux / amazonlinux:2023 (push) Waiting to run
Linux / debian:11 (linux/386) (push) Waiting to run
Linux / debian:11 (push) Waiting to run
Linux / debian:12 (linux/386) (push) Waiting to run
Linux / debian:12 (push) Waiting to run
Linux / debian:13 (push) Waiting to run
Linux / fedora:41 (push) Waiting to run
Linux / fedora:42 (push) Waiting to run
Linux / opensuse/leap:15.6 (push) Waiting to run
Linux / opensuse/leap:16.0 (push) Waiting to run
Linux / registry.suse.com/suse/sle15:15.6 (push) Waiting to run
Linux / registry.suse.com/suse/sle15:15.7 (push) Waiting to run
Linux / rockylinux/rockylinux:10 (push) Waiting to run
Linux / rockylinux:8 (push) Waiting to run
Linux / rockylinux:9 (push) Waiting to run
Linux / ubuntu:22.04 (push) Waiting to run
Linux / ubuntu:24.04 (push) Waiting to run
Linux / ubuntu:25.04 (push) Waiting to run
Linux / ubuntu:25.10 (push) Waiting to run
Windows / Windows (push) Waiting to run
Some checks are pending
Container Image / Container Image (push) Waiting to run
Linux / alpine:bash (push) Waiting to run
Linux / amazonlinux:2 (push) Waiting to run
Linux / amazonlinux:2023 (push) Waiting to run
Linux / debian:11 (linux/386) (push) Waiting to run
Linux / debian:11 (push) Waiting to run
Linux / debian:12 (linux/386) (push) Waiting to run
Linux / debian:12 (push) Waiting to run
Linux / debian:13 (push) Waiting to run
Linux / fedora:41 (push) Waiting to run
Linux / fedora:42 (push) Waiting to run
Linux / opensuse/leap:15.6 (push) Waiting to run
Linux / opensuse/leap:16.0 (push) Waiting to run
Linux / registry.suse.com/suse/sle15:15.6 (push) Waiting to run
Linux / registry.suse.com/suse/sle15:15.7 (push) Waiting to run
Linux / rockylinux/rockylinux:10 (push) Waiting to run
Linux / rockylinux:8 (push) Waiting to run
Linux / rockylinux:9 (push) Waiting to run
Linux / ubuntu:22.04 (push) Waiting to run
Linux / ubuntu:24.04 (push) Waiting to run
Linux / ubuntu:25.04 (push) Waiting to run
Linux / ubuntu:25.10 (push) Waiting to run
Windows / Windows (push) Waiting to run
Fix usage of pthread_setname_np() on NetBSD
This commit is contained in:
commit
50b289a7a2
1 changed files with 23 additions and 5 deletions
|
|
@ -1311,6 +1311,23 @@ void Utility::SetThreadName(const String& name, bool os)
|
|||
{
|
||||
m_ThreadName.reset(new String(name));
|
||||
|
||||
#if defined(HAVE_PTHREAD_SET_NAME_NP) || defined(HAVE_PTHREAD_SETNAME_NP)
|
||||
unsigned int len;
|
||||
|
||||
/* https://github.com/llvm/llvm-project/blob/6412184891526690cff804f87f986b1fa039f011/llvm/lib/Support/Unix/Threading.inc#L157 */
|
||||
# ifdef PTHREAD_MAX_NAMELEN_NP
|
||||
len = PTHREAD_MAX_NAMELEN_NP;
|
||||
# elif defined(__APPLE__) /* PTHREAD_MAX_NAMELEN_NP */
|
||||
len = 64;
|
||||
# elif defined(__OpenBSD__) /* __APPLE__ */
|
||||
len = 24;
|
||||
# else /* __OpenBSD__ */
|
||||
len = 16;
|
||||
# endif /* PTHREAD_MAX_NAMELEN_NP */
|
||||
|
||||
String tname = name.SubStr(0, len - 1);
|
||||
#endif
|
||||
|
||||
if (!os)
|
||||
return;
|
||||
|
||||
|
|
@ -1319,13 +1336,14 @@ void Utility::SetThreadName(const String& name, bool os)
|
|||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef HAVE_PTHREAD_SET_NAME_NP
|
||||
pthread_set_name_np(pthread_self(), name.CStr());
|
||||
pthread_set_name_np(pthread_self(), tname.CStr());
|
||||
#elif defined(HAVE_PTHREAD_SETNAME_NP) /* HAVE_PTHREAD_SET_NAME_NP */
|
||||
# ifdef __APPLE__
|
||||
pthread_setname_np(name.CStr());
|
||||
# else /* __APPLE__ */
|
||||
String tname = name.SubStr(0, 15);
|
||||
pthread_setname_np(pthread_self(), tname.CStr());
|
||||
pthread_setname_np(tname.CStr());
|
||||
# elif defined(__NetBSD__) /* __APPLE__ */
|
||||
pthread_setname_np(pthread_self(), "%s", const_cast<char *>(tname.CStr()));
|
||||
# else /* __NetBSD__ */
|
||||
pthread_setname_np(pthread_self(), tname.CStr());
|
||||
# endif /* __APPLE__ */
|
||||
#endif /* HAVE_PTHREAD_SETNAME_NP */
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue