From nobody Sun Aug 20 22:44:38 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RTVzV54xRz4qqBd; Sun, 20 Aug 2023 22:44:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RTVzV48cBz4VVj; Sun, 20 Aug 2023 22:44:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692571478; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VbXQtPwDGf5/Ma5IAD7zu++ViExNQKhyZeF/mp72+vU=; b=Q5/6uckKMV2xBCQQZRZYAQ25WIO1zIBNxpGryntFRsF8REHzw1+Woph1m4D3/mYQ1DrOh3 YO8NWgvLnbosFUbht245z7yF6yilxkeEGS1wemDXmyV9zS9O3uuKKPc3cP59DoBB5I3aH8 ykmVKdCZrQeRctLZFaNa10UbhWjiqSD3HY63sVgRfziQF/0lMoeNvw9h2tDLtr4li73Qm3 L5WKt2/WtjKgldeXSd8ZmGrF0tbRoNJ8TifS7fCIG32cIEtud/2mURrlAZkJhP1g4DD8PD JuBcvHjJHa0+X3xjm6l8ujwK3R3T5YkBZP4oyyFE1obvIitcp205N77QnaZbnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692571478; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VbXQtPwDGf5/Ma5IAD7zu++ViExNQKhyZeF/mp72+vU=; b=pfO0Fbgff1HoTIeZfrAPyQr3yGTPdmlMrpxZClWiXIxCs92/eM6bT0fajzJd5R7LIzZHj0 Rzk5pzu7f/wUjc1LbN0UBKAYo3rEUkhbZA+p0J07ZZQdlmCyXr/DAlyQ0BpKf53NkI2bjM UWqJ3/z2d8Jt1oSNMQxCa5HNV+thYCbhTqzIjK8aJYWIjrZnUA1Qa+PO2/FT/IOiBNAQQ/ 6lmzIeGDXFam4VrCbInPc3NfDqYDXlt5dBGQrBE0NHxd6oZrjCSKpv1RBn+GzPl3d4gD9P EDHwBgbc6SFzX5q2CzgG8fwXx/dA3MahPiLIhHvhLDyR8gzkyrFNk3ZV9aFxYA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692571478; a=rsa-sha256; cv=none; b=M+5+CCrK9ystECwUQV4XwAt9NTgKTCyL0d4BW1R/ULo4je2Ei+ch0ZOf6bFbIczejT1yso wtoxkWfIu5UK3ShYkWOQCyolZnQh5onDJB5toKi+YZYchzL1IthLDl/6nLmrI0vm7Kd8U9 wYqekXazRN7OVMBR9N01EVWO3voPd0t9tVPrj6FHSBhbbzU+qeJqmYkIaZup4V73P3CcKh kK4MzN5k04iPBNMyrH/r5YXSKWt9Ke4DK70DHCdbAZRkVeMxu6BTleW/PzuxjEc3l5JuIN qX7ICoiqTP2vRxlLS9TrzDNCv2lWvmzhSy/DH9CYRsilFlhBSysOUZkREARXtw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RTVzV3BD8zwgj; Sun, 20 Aug 2023 22:44:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37KMicxw056203; Sun, 20 Aug 2023 22:44:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37KMicfH056200; Sun, 20 Aug 2023 22:44:38 GMT (envelope-from git) Date: Sun, 20 Aug 2023 22:44:38 GMT Message-Id: <202308202244.37KMicfH056200@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 0dc52b72108e - main - libc: export pthread_getname_np stub List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0dc52b72108e321a99022785713c58d278696af2 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0dc52b72108e321a99022785713c58d278696af2 commit 0dc52b72108e321a99022785713c58d278696af2 Author: Minsoo Choo AuthorDate: 2023-08-14 22:21:24 +0000 Commit: Konstantin Belousov CommitDate: 2023-08-20 22:44:17 +0000 libc: export pthread_getname_np stub pthread_getname_np needs to be provided by libc in order to import jemalloc 5.3.0. A stub implementation for libc pthread_getname_np() is added for _pthread_stubs.c, which always reports empty name for the main thread. Internal _pthread_getname_np() is not exported, but provided for libc own use. Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D41461 --- lib/libc/gen/Symbol.map | 1 + lib/libc/gen/_pthread_stubs.c | 13 +++++++++++++ lib/libc/include/libc_private.h | 1 + lib/libthr/thread/thr_info.c | 7 ++++--- lib/libthr/thread/thr_init.c | 1 + lib/libthr/thread/thr_private.h | 1 + 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index 9dd7334728a4..bdd659197644 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -426,6 +426,7 @@ FBSD_1.6 { eventfd_write; getlogin_r; memalign; + pthread_getname_np; scandir_b; sigandset; sigisemptyset; diff --git a/lib/libc/gen/_pthread_stubs.c b/lib/libc/gen/_pthread_stubs.c index 6741c6a5ec51..25dfeb2cc270 100644 --- a/lib/libc/gen/_pthread_stubs.c +++ b/lib/libc/gen/_pthread_stubs.c @@ -58,6 +58,7 @@ static int stub_fail(void); static int stub_true(void); static void stub_exit(void); static int stub_esrch(void); +static int stub_getname_np(pthread_t, char *, size_t); #define PJT_DUAL_ENTRY(entry) \ (pthread_func_t)entry, (pthread_func_t)entry @@ -131,6 +132,7 @@ pthread_func_entry_t __thr_jtable[PJT_MAX] = { [PJT_MUTEXATTR_SETROBUST] = {PJT_DUAL_ENTRY(stub_zero)}, [PJT_GETTHREADID_NP] = {PJT_DUAL_ENTRY(stub_zero)}, [PJT_ATTR_GET_NP] = {PJT_DUAL_ENTRY(stub_esrch)}, + [PJT_GETNAME_NP] = {PJT_DUAL_ENTRY(stub_getname_np)}, }; /* @@ -289,6 +291,7 @@ STUB_FUNC3(__pthread_cleanup_push_imp, PJT_CLEANUP_PUSH_IMP, void, void *, STUB_FUNC1(_pthread_cancel_enter, PJT_CANCEL_ENTER, void, int) STUB_FUNC1(_pthread_cancel_leave, PJT_CANCEL_LEAVE, void, int) STUB_FUNC2(pthread_attr_get_np, PJT_ATTR_GET_NP, int, pthread_t, pthread_attr_t *) +STUB_FUNC3(pthread_getname_np, PJT_GETNAME_NP, int, pthread_t, char *, size_t) static int stub_zero(void) @@ -337,3 +340,13 @@ stub_esrch(void) { return (ESRCH); } + +static int +stub_getname_np(pthread_t thread, char *buf, size_t len) +{ + if (thread != &main_thread) + return (ESRCH); + if (len >= 1) + buf[0] = '\0'; + return (0); +} diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h index 5c740edf3fcc..a9ad2ef21b0b 100644 --- a/lib/libc/include/libc_private.h +++ b/lib/libc/include/libc_private.h @@ -184,6 +184,7 @@ typedef enum { PJT_MUTEXATTR_SETROBUST, PJT_GETTHREADID_NP, PJT_ATTR_GET_NP, + PJT_GETNAME_NP, PJT_MAX } pjt_index_t; diff --git a/lib/libthr/thread/thr_info.c b/lib/libthr/thread/thr_info.c index b5b84b733db6..41ab7f0bcf0c 100644 --- a/lib/libthr/thread/thr_info.c +++ b/lib/libthr/thread/thr_info.c @@ -114,9 +114,10 @@ thr_get_name_np(struct pthread *thread, char *buf, size_t len) buf[0] = '\0'; } -__weak_reference(_pthread_getname_np, pthread_getname_np); +__weak_reference(_thr_getname_np, pthread_getname_np); +__weak_reference(_thr_getname_np, _pthread_getname_np); int -_pthread_getname_np(pthread_t thread, char *buf, size_t len) +_thr_getname_np(pthread_t thread, char *buf, size_t len) { struct pthread *curthread; int res; @@ -147,5 +148,5 @@ __weak_reference(_pthread_get_name_np, pthread_get_name_np); void _pthread_get_name_np(pthread_t thread, char *buf, size_t len) { - (void)_pthread_getname_np(thread, buf, len); + (void)_thr_getname_np(thread, buf, len); } diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c index ef8c7d59d729..b59678c3f6c3 100644 --- a/lib/libthr/thread/thr_init.c +++ b/lib/libthr/thread/thr_init.c @@ -271,6 +271,7 @@ static pthread_func_t jmp_table[][2] = { [PJT_MUTEXATTR_SETROBUST] = {DUAL_ENTRY(_thr_mutexattr_setrobust)}, [PJT_GETTHREADID_NP] = {DUAL_ENTRY(_thr_getthreadid_np)}, [PJT_ATTR_GET_NP] = {DUAL_ENTRY(_thr_attr_get_np)}, + [PJT_GETNAME_NP] = {DUAL_ENTRY(_thr_getname_np)}, }; static int init_once = 0; diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h index fba3b78e43c5..3475029f8996 100644 --- a/lib/libthr/thread/thr_private.h +++ b/lib/libthr/thread/thr_private.h @@ -1073,6 +1073,7 @@ int _thr_cond_wait(pthread_cond_t *, pthread_mutex_t *); int _thr_detach(pthread_t); int _thr_equal(pthread_t, pthread_t); void _Tthr_exit(void *); +int _thr_getname_np(pthread_t, char *, size_t); int _thr_key_create(pthread_key_t *, void (*)(void *)); int _thr_key_delete(pthread_key_t); int _thr_setspecific(pthread_key_t, const void *);