From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: timo.myyra@bittivirhe.fi (Timo =?utf-8?Q?Myyr=C3=A4?=) Newsgroups: gmane.emacs.devel Subject: add pthread_set_name_np support Date: Sat, 27 Jun 2020 13:49:24 +0300 Message-ID: <875zbcrdfv.fsf@asteroid.bittivirhe.fi> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="103640"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 27 13:03:35 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jp8cQ-000Qm7-Il for ged-emacs-devel@m.gmane-mx.org; Sat, 27 Jun 2020 13:03:34 +0200 Original-Received: from localhost ([::1]:40318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jp8cP-0000Wu-Le for ged-emacs-devel@m.gmane-mx.org; Sat, 27 Jun 2020 07:03:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jp8Ow-0006wH-IF for emacs-devel@gnu.org; Sat, 27 Jun 2020 06:49:38 -0400 Original-Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:39187) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jp8Os-0000xw-8j for emacs-devel@gnu.org; Sat, 27 Jun 2020 06:49:38 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 3C24E934 for ; Sat, 27 Jun 2020 06:49:30 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sat, 27 Jun 2020 06:49:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bittivirhe.fi; h=from:to:subject:date:message-id:mime-version:content-type; s= fm3; bh=0+Vqij68aIpsRPUnywLwb2LCW8MDbxaurp5/fmFtNec=; b=Mmqj15DB +ziR310878fShCiPGTq0rD14PCR01eYUWWL+5OX9yxET5ONHPcZvvkezC+FUjsx1 A5a+BsOZEUiQfHjpTq/c4zgJGfd9P4Xg5Fu7/laTKGTLXXYtwsyGWj/QZTCO+B4C NFWus7BINAsdfAYT5S9UrioFmQiCSmscscbFtjeJ/jfYJ3TZp4vW97i/TWk0OKCl K33lxW2Z/M5KgY3anTPPfoF08caIU7pd7SyhHG9KyRCGbyVeVAlfsGtswDodQlFd KNPx4X5rvXFbu40QcgLMW3z8nbfMmy+Tuf3rb9eGi6XbEsSJ99Gl+0ECTPrZh00P joRisqJ0W6eKng== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=0+Vqij68aIpsRPUnywLwb2LCW8MDb xaurp5/fmFtNec=; b=uI88CSmpSHOedHCjRuFW+PGETcj8Zkdu4oRWAfmzRbxTK /TdaYIVA/6K834ToIUt9qZLd+ZE29vaIvJl0g+yT0N5xwarKY2OBLnRsK/A8lnO9 EZbJYZcS2YxBBsuiBxKr084CDn+4u7glcGtWUJoT8isRknNE9wJJSiggXd7Ax5n1 ApRTj/N7AXHFpml9WyueZMo3N7ukFe5orpFVCwB9W421HUTETHkiVfOtZzNAyAXA ZvNsRRjRwSqM51//lIV5EE4otr2XKV7a8WWYHugeOdBbuEeXUsObwLi3D4imsZyR Mm+PNWd2X9CQ+pYAaoVqnzwTEyVGlW8uqTHOMv/gg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudelfedgfeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkgggtsehttdertddttd ejnecuhfhrohhmpehtihhmohdrmhihhihrrgessghithhtihhvihhrhhgvrdhfihculdfv ihhmohcuofihhihrmodmnecuggftrfgrthhtvghrnhepgeefhefgffduvdfgtdeuudeutd ekvdejledtveehvdelhedukeegiedvtdegvdegnecukfhppeeluddrudehvddrjeehrddu keeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepth himhhordhmhiihrhgrsegsihhtthhivhhirhhhvgdrfhhi X-ME-Proxy: Original-Received: from asteroid.bittivirhe.fi.bittivirhe.fi (91-152-75-188.elisa-laajakaista.fi [91.152.75.188]) by mail.messagingengine.com (Postfix) with ESMTPA id 104573067A1E for ; Sat, 27 Jun 2020 06:49:28 -0400 (EDT) Received-SPF: pass client-ip=64.147.123.19; envelope-from=timo.myyra@bittivirhe.fi; helo=wout3-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/27 06:49:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Mailman-Approved-At: Sat, 27 Jun 2020 07:03:01 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:252546 Archived-At: Hi, While browsing the emacs code I noticed that pthread_set_name_np is not supported by emacs currently. Here's simple diff to add it. I'm not that well versed in autoconf, probably should check pthread_set_name_np within the pthread_setname_np block so both won't get enabled at the same time. Also I'm not sure if name should be padded, quickly looking OpenBSD sources didn't indicate that padding would be required. LLVM code base seems to pad name argument to max 16 chars on FreeBSD and 32 on OpenBSD. Thoughts? Timo diff --git a/configure.ac b/configure.ac index b1b8c846e1..cfc642f72e 100644 --- a/configure.ac +++ b/configure.ac @@ -4187,7 +4187,8 @@ AC_DEFUN 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 @@ -4222,6 +4223,23 @@ AC_DEFUN fi fi +if test "$ac_cv_func_pthread_set_name_np" = "yes"; then + AC_CACHE_CHECK( + [whether pthread_set_name_np is supported], + [emacs_cv_pthread_set_name_np], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ][#incule ]], + [[pthread_setname_np (1, "a");]])], + [emacs_cv_pthread_set_name_np=yes], + [emacs_cv_pthread_set_name_np=no])]) + if test "$emacs_cv_pthread_set_name_np" = "yes"; then + AC_DEFINE( + HAVE_PTHREAD_SET_NAME_NP, 1, + [Define to 1 if pthread_set_name_np is supported.]) + fi +fi + dnl No need to check for posix_memalign if aligned_alloc works. AC_CHECK_FUNCS([aligned_alloc posix_memalign], [break]) AC_CHECK_DECLS([aligned_alloc], [], [], [[#include ]]) diff --git a/src/systhread.c b/src/systhread.c index 0d600d6895..3087f18d4c 100644 --- a/src/systhread.c +++ b/src/systhread.c @@ -26,6 +26,10 @@ Copyright (C) 2012-2020 Free Software Foundation, Inc. #include "nsterm.h" #endif +#ifdef HAVE_PTHREAD_SET_NAME_NP +#include "pthread_np.h" +#endif + #ifndef THREADS_ENABLED void @@ -222,6 +226,9 @@ #define TASK_COMM_LEN 16 pthread_setname_np (pthread_self (), p_name); # endif #endif +#ifdef HAVE_PTHREAD_SET_NAME_NP + pthread_set_name_np (pthread_self (), name); +#endif } bool