aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport
diff options
context:
space:
mode:
authorChristian Biesinger <cbiesinger@google.com>2020-01-24 14:58:29 +0100
committerChristian Biesinger <cbiesinger@google.com>2020-01-24 16:39:01 +0100
commit43198d20896df6a785165650914d0b73fc9450a8 (patch)
tree3b086727528f67570c9613ab13f77fd52fd12363 /gdbsupport
parentcaa31cfad6c16ffbd5c396f74273fc9e413906f0 (diff)
downloadbinutils-43198d20896df6a785165650914d0b73fc9450a8.zip
binutils-43198d20896df6a785165650914d0b73fc9450a8.tar.gz
binutils-43198d20896df6a785165650914d0b73fc9450a8.tar.bz2
Support the NetBSD version of pthread_setname_np
On NetBSD, pthread_setname_np takes a printf-style format string plus one argument: https://netbsd.gw.com/cgi-bin/man-cgi?pthread_setname_np++NetBSD-current This patch makes thread-pool.c handle that. gdbsupport/ChangeLog: 2020-01-24 Christian Biesinger <cbiesinger@google.com> * thread-pool.c (set_thread_name): Add an overload for the NetBSD version of pthread_setname_np. Change-Id: I61e664a813eaa7f52b6811b1a43e08ac3082d8ef
Diffstat (limited to 'gdbsupport')
-rw-r--r--gdbsupport/ChangeLog5
-rw-r--r--gdbsupport/thread-pool.c12
2 files changed, 15 insertions, 2 deletions
diff --git a/gdbsupport/ChangeLog b/gdbsupport/ChangeLog
index 3583e5b..6ea2f2c 100644
--- a/gdbsupport/ChangeLog
+++ b/gdbsupport/ChangeLog
@@ -1,3 +1,8 @@
+2020-01-24 Christian Biesinger <cbiesinger@google.com>
+
+ * thread-pool.c (set_thread_name): Add an overload for the NetBSD
+ version of pthread_setname_np.
+
2020-01-17 Pedro Alves <palves@redhat.com>
* Makefile.am: Append CXX_DIALECT to CXX.
diff --git a/gdbsupport/thread-pool.c b/gdbsupport/thread-pool.c
index fc83ff7..be9ca22 100644
--- a/gdbsupport/thread-pool.c
+++ b/gdbsupport/thread-pool.c
@@ -40,8 +40,16 @@
#include <pthread.h>
/* Handle platform discrepancies in pthread_setname_np: macOS uses a
- single-argument form, while Linux uses a two-argument form. This
- wrapper handles the difference. */
+ single-argument form, while Linux uses a two-argument form. NetBSD
+ takes a printf-style format and an argument. This wrapper handles the
+ difference. */
+
+ATTRIBUTE_UNUSED static void
+set_thread_name (int (*set_name) (pthread_t, const char *, void *),
+ const char *name)
+{
+ set_name (pthread_self (), "%s", const_cast<char *> (name));
+}
ATTRIBUTE_UNUSED static void
set_thread_name (int (*set_name) (pthread_t, const char *), const char *name)