unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 39363@debbugs.gnu.org, Thomas Klausner <wiz@NetBSD.org>
Subject: bug#39363: emacs-git version: pthread_setname_np on NetBSD
Date: Fri, 31 Jan 2020 10:02:50 +0100	[thread overview]
Message-ID: <m27e18f16t.fsf@gmail.com> (raw)
In-Reply-To: <83y2tokqwy.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 31 Jan 2020 09:48:13 +0200")

>>>>> On Fri, 31 Jan 2020 09:48:13 +0200, Eli Zaretskii <eliz@gnu.org> said:

    >> Date: Fri, 31 Jan 2020 00:02:13 +0100
    >> From: Thomas Klausner <wiz@NetBSD.org>
    >> 
    >> Recently, emacs from git stopped compiling on NetBSD because it
    >> started using pthread_setname_np. AFAIK, there is no commonly agreed
    >> upon standard for this function, and NetBSD's uses three arguments, see
    >> https://netbsd.gw.com/cgi-bin/man-cgi?pthread_setname_np++NetBSD-current
    >> 
    >> The attached patch makes emacs compile again (on NetBSD-9.99.43/amd64)
    >> but configure should probably be taught to look for that version of
    >> pthread_setname_np instead of the #ifdef __NetBSD__.

    Eli> I think we want instead to modify the configure-time test to include
    Eli> the possibility of 3-argument pthread_setname_np.

Untested patch (I donʼt have any NetBSD machines).

diff --git a/configure.ac b/configure.ac
index f604acb694..1d922d9c02 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4192,6 +4192,21 @@ AC_DEFUN
     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
 
diff --git a/src/systhread.c b/src/systhread.c
index c649ae853a..0d600d6895 100644
--- a/src/systhread.c
+++ b/src/systhread.c
@@ -214,11 +214,13 @@ #define TASK_COMM_LEN 16
   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
 }
 





  reply	other threads:[~2020-01-31  9:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-30 23:02 bug#39363: emacs-git version: pthread_setname_np on NetBSD Thomas Klausner
2020-01-31  7:48 ` Eli Zaretskii
2020-01-31  9:02   ` Robert Pluim [this message]
2020-01-31 17:09     ` Thomas Klausner
2020-02-03 11:37       ` Robert Pluim
2020-02-03 15:35         ` Eli Zaretskii
2020-02-03 15:41           ` Robert Pluim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m27e18f16t.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=39363@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=wiz@NetBSD.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).