]> git.eshelyaron.com Git - emacs.git/commitdiff
Add thread-naming support for OpenBSD
authorTimo Myyrä <timo.myyra@bittivirhe.fi>
Sun, 28 Jun 2020 08:27:21 +0000 (10:27 +0200)
committerMattias Engdegård <mattiase@acm.org>
Sun, 28 Jun 2020 08:27:21 +0000 (10:27 +0200)
OpenBSD has pthread_set_name_np; FreeBSD appears to have both
this call and pthread_setname_np (the latter call is used in preference).

* configure.ac: Detect pthread_set_name_np.
* sys/systhread.c:
Include <pthread_np.h> and call pthread_set_name_np if available.

configure.ac
src/systhread.c

index b1b8c846e14d266e3458d3aeeaf5e8ffe82b797c..9edd2273b193f6a775f6e8da49de7bc558fcc59b 100644 (file)
@@ -4187,7 +4187,8 @@ pthread_sigmask strsignal setitimer timer_getoverrun \
 sendto recvfrom getsockname getifaddrs freeifaddrs \
 gai_strerror sync \
 getpwent endpwent getgrent endgrent \
-cfmakeraw cfsetspeed __executable_start log2 pthread_setname_np)
+cfmakeraw cfsetspeed __executable_start log2 pthread_setname_np \
+pthread_set_name_np)
 LIBS=$OLD_LIBS
 
 if test "$ac_cv_func_pthread_setname_np" = "yes"; then
index 0d600d6895e32734e1fc11fab0d7a80ab1694805..ebd75526495845bc05f99555e88e370ce24558bd 100644 (file)
@@ -26,6 +26,10 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 #include "nsterm.h"
 #endif
 
+#ifdef HAVE_PTHREAD_SET_NAME_NP
+#include <pthread_np.h>
+#endif
+
 #ifndef THREADS_ENABLED
 
 void
@@ -221,6 +225,10 @@ sys_thread_set_name (const char *name)
 # else
   pthread_setname_np (pthread_self (), p_name);
 # endif
+#elif HAVE_PTHREAD_SET_NAME_NP
+  /* The name will automatically be truncated if it exceeds a
+     system-specific length.  */
+  pthread_set_name_np (pthread_self (), name);
 #endif
 }