summaryrefslogtreecommitdiffstats
path: root/src/os.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-01-23 05:12:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-01-23 05:12:58 +0000
commit362c6d4a6148dbd5de3b66e2e9eaa274dca37f5c (patch)
tree9fac4d36641fad50af57fadbd0bd1d0f0790f95d /src/os.c
parentAdding upstream version 2.13.1. (diff)
downloaddnsperf-362c6d4a6148dbd5de3b66e2e9eaa274dca37f5c.tar.xz
dnsperf-362c6d4a6148dbd5de3b66e2e9eaa274dca37f5c.zip
Adding upstream version 2.14.0.upstream/2.14.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/os.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/os.c b/src/os.c
index a36cbed..d16d3b3 100644
--- a/src/os.c
+++ b/src/os.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2019-2023 OARC, Inc.
+ * Copyright 2019-2024 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.
@@ -32,6 +32,10 @@
#include <string.h>
#include <poll.h>
+#if defined(HAVE_PTHREAD_NP_H)
+#include <pthread_np.h>
+#endif /* if defined(HAVE_PTHREAD_NP_H) */
+
void perf_os_blocksignal(int sig, bool block)
{
sigset_t sset;
@@ -149,3 +153,23 @@ perf_os_waituntilanywritable(struct perf_net_socket** socks, unsigned int nfds,
return (PERF_R_SUCCESS);
}
}
+
+void perf_os_thread_setname(pthread_t thread, const char* name)
+{
+#if defined(HAVE_PTHREAD_SETNAME_NP) && !defined(__APPLE__)
+ /*
+ * macOS has pthread_setname_np but only works on the
+ * current thread so it's not used here
+ */
+#if defined(__NetBSD__)
+ (void)pthread_setname_np(thread, name, NULL);
+#else /* if defined(__NetBSD__) */
+ (void)pthread_setname_np(thread, name);
+#endif /* if defined(__NetBSD__) */
+#elif defined(HAVE_PTHREAD_SET_NAME_NP)
+ (void)pthread_set_name_np(thread, name);
+#else /* if defined(HAVE_PTHREAD_SETNAME_NP) && !defined(__APPLE__) */
+ (void)(thread);
+ (void)(name);
+#endif /* if defined(HAVE_PTHREAD_SETNAME_NP) && !defined(__APPLE__) */
+}