aboutsummaryrefslogtreecommitdiff
path: root/openmp/runtime/src/z_Linux_util.cpp
diff options
context:
space:
mode:
authorBrad Smith <brad@comstyle.com>2024-08-31 16:53:33 -0400
committerGitHub <noreply@github.com>2024-08-31 16:53:33 -0400
commit37e109c6f86e7562a7f0b54a229f57e36b778f05 (patch)
tree9d267a6910a05df525d49d26c6f12faccca3255e /openmp/runtime/src/z_Linux_util.cpp
parentec588175370a32dd40df86dc4672e65926817f25 (diff)
downloadllvm-37e109c6f86e7562a7f0b54a229f57e36b778f05.zip
llvm-37e109c6f86e7562a7f0b54a229f57e36b778f05.tar.gz
llvm-37e109c6f86e7562a7f0b54a229f57e36b778f05.tar.bz2
[OpenMP] Support setting POSIX thread name on *BSD's and Solaris (#106489)
Diffstat (limited to 'openmp/runtime/src/z_Linux_util.cpp')
-rw-r--r--openmp/runtime/src/z_Linux_util.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 337a345..bdb7a12 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -71,6 +71,9 @@
#if KMP_OS_NETBSD
#include <sched.h>
#endif
+#if KMP_OS_OPENBSD
+#include <pthread_np.h>
+#endif
#elif KMP_OS_SOLARIS
#include <libproc.h>
#include <procfs.h>
@@ -878,12 +881,18 @@ void __kmp_create_worker(int gtid, kmp_info_t *th, size_t stack_size) {
KMP_SYSFAIL("pthread_create", status);
}
-#ifdef LIBOMP_HAVE_LINUX_PTHREAD_SETNAME
// Rename worker threads for improved debuggability
if (!KMP_UBER_GTID(gtid)) {
+#if defined(LIBOMP_HAVE_PTHREAD_SET_NAME_NP)
+ pthread_set_name_np(handle, "openmp_worker");
+#elif defined(LIBOMP_HAVE_PTHREAD_SETNAME_NP) && !KMP_OS_DARWIN
+#if KMP_OS_NETBSD
+ pthread_setname_np(handle, "%s", const_cast<char *>("openmp_worker"));
+#else
pthread_setname_np(handle, "openmp_worker");
- }
#endif
+#endif
+ }
th->th.th_info.ds.ds_thread = handle;