]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Support the NetBSD version of pthread_setname_np
authorChristian Biesinger <cbiesinger@google.com>
Fri, 24 Jan 2020 13:58:29 +0000 (14:58 +0100)
committerChristian Biesinger <cbiesinger@google.com>
Fri, 24 Jan 2020 15:39:01 +0000 (16:39 +0100)
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

gdbsupport/ChangeLog
gdbsupport/thread-pool.c

index 3583e5bd34707706fc7f8a9347019be5b67d2771..6ea2f2c2530e8b7019ec2f7763ff31ee4fbeb7ad 100644 (file)
@@ -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.
index fc83ff765f655baa526f239e4969c7519aff8b28..be9ca22682a0bf59e13bd8bf8098be09cc2487ae 100644 (file)
 #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)