]> git.eshelyaron.com Git - emacs.git/commitdiff
Cater for 3-argument version of pthread_setname_np
authorRobert Pluim <rpluim@gmail.com>
Fri, 31 Jan 2020 09:22:59 +0000 (10:22 +0100)
committerRobert Pluim <rpluim@gmail.com>
Mon, 3 Feb 2020 15:40:25 +0000 (16:40 +0100)
Fixes Bug#39363.

* configure.ac: Add check for 3-argument version of
pthread_setname_np.
* src/systhread.c (sys_thread_set_name)
[HAVE_PTHREAD_SETNAME_NP_3ARG]: Call pthread_setname_np with
3 arguments.

configure.ac
src/systhread.c

index 3c47da6dcb4cea6e6ef1dc06085740d21af80815..aa2d9ef745fbea0ba7967707d25542ba81f4be06 100644 (file)
@@ -4197,6 +4197,21 @@ if test "$ac_cv_func_pthread_setname_np" = "yes"; then
     AC_DEFINE(
       HAVE_PTHREAD_SETNAME_NP_1ARG, 1,
       [Define to 1 if pthread_setname_np takes a single argument.])
+  else
+    AC_CACHE_CHECK(
+     [whether pthread_setname_np takes three arguments],
+     [emacs_cv_pthread_setname_np_3arg],
+     [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+         [[#include <pthread.h>]],
+         [[pthread_setname_np (0, "%s", "a");]])],
+       [emacs_cv_pthread_setname_np_3arg=yes],
+       [emacs_cv_pthread_setname_np_3arg=no])])
+     if test "$emacs_cv_pthread_setname_np_3arg" = "yes"; then
+       AC_DEFINE(
+         HAVE_PTHREAD_SETNAME_NP_3ARG, 1,
+         [Define to 1 if pthread_setname_np takes three arguments.])
+     fi
   fi
 fi
 
index c649ae853a353322a8244df2ce7a6cd198f373d1..0d600d6895e32734e1fc11fab0d7a80ab1694805 100644 (file)
@@ -214,11 +214,13 @@ sys_thread_set_name (const char *name)
   char p_name[TASK_COMM_LEN];
   strncpy (p_name, name, TASK_COMM_LEN - 1);
   p_name[TASK_COMM_LEN - 1] = '\0';
- #ifdef HAVE_PTHREAD_SETNAME_NP_1ARG
+ifdef HAVE_PTHREAD_SETNAME_NP_1ARG
   pthread_setname_np (p_name);
- #else
+# elif defined HAVE_PTHREAD_SETNAME_NP_3ARG
+  pthread_setname_np (pthread_self (), "%s", p_name);
+# else
   pthread_setname_np (pthread_self (), p_name);
- #endif
+endif
 #endif
 }