From patchwork Thu Oct 10 17:47:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1995576 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=pSwIA2RB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XPcgK71xvz1xtv for ; Fri, 11 Oct 2024 04:48:29 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E05DD385840B for ; Thu, 10 Oct 2024 17:48:27 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by sourceware.org (Postfix) with ESMTPS id C50FA3858D37 for ; Thu, 10 Oct 2024 17:48:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C50FA3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C50FA3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=167.114.26.122 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728582493; cv=none; b=JGx8AlcUoFwOo/x97Bq1sA10N6zoffNAcPH/z7whJCmESxD9ikZtn5pRDNWKpu1dVTusPMgbXG0/TISPWQzzQFP2EjauFP9Ov2vEkJkv+q8CLAIwrbGrFJRhHvhiGFaPD1Kh3yg2WtUz8ggb2UzGeG4ez5jYc1QM/B1b+SXNBGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728582493; c=relaxed/simple; bh=6iOQiQdIr7p7VQg4qsDN5A7J/495xpkWTfUaY7Sp7Kc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XfFkspDX7Wd5YSDBu6l9ve2fktfbLVDd3NcRbprI/ruKKRVvTackxnlMhOY47XuUOZPWIAyUwznXjbr28BS8QSsUb1Dnx5cnsLtg1XV+0LKimyFNHMlyH2G4QESvGYlpNmvvuFs2qgW5l9lwoiMg9esO/nCTn4t5KjiObxlU3tc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1728582490; bh=6iOQiQdIr7p7VQg4qsDN5A7J/495xpkWTfUaY7Sp7Kc=; h=From:To:Cc:Subject:Date:From; b=pSwIA2RBJ6xyfcGNStdr3oAeFvZVgaMH+/PH2PnMaB2x6HcA1sNqsNweafNJg4obG K5AdchsI2BtQbXwvxelMAdnhu1qMyh/WeUKauhjpSRz5fxNO07blYLcsR4N32k7xBj MOUvYgN87O6BwqYHlZC4BS+nT/9e2ANbBPGfjanTRWQcZaFjYqQ3MDqPkFeG++1GKW yw0U51cINRpZn1rXdn2lYQE767P6FWG5tEMyUOvP/Nm15qM9Clurb9V3oDpi2x1hbK QW5B0ru9G5deR23lpxtoYX0D+5Jj3uA+DTj6jfNqbCqEvl/2rXUGeyZgTp2+i+LnRR JPfyd6G9S68fQ== Received: from laptop-mjeanson.internal.efficios.com (96-127-217-162.qc.cable.ebox.net [96.127.217.162]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4XPcfy5FKZzqlr; Thu, 10 Oct 2024 13:48:10 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Palmer Dabbelt , Darius Rad , Jeff Law Subject: [PATCH v2] nptl: Add for RISC-V Date: Thu, 10 Oct 2024 13:47:42 -0400 Message-ID: <20241010174748.51840-1-mjeanson@efficios.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org This will be required by the rseq extensible ABI implementation on all Linux architectures exposing the '__rseq_size' and '__rseq_offset' symbols to set the initial value of the 'cpu_id' field which can be used by applications to test if rseq is available and registered. As long as the symbols are exposed it is valid for an application to perform this test even if rseq is not yet implemented in libc for this architecture. Signed-off-by: Michael Jeanson --- Changes since v1: - Use __glibc_has_builtin instead of GCC version check - Use 'register' variable instead of inline asm --- Cc: Florian Weimer Cc: Palmer Dabbelt Cc: Darius Rad Cc: Jeff Law --- sysdeps/riscv/nptl/thread_pointer.h | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 sysdeps/riscv/nptl/thread_pointer.h diff --git a/sysdeps/riscv/nptl/thread_pointer.h b/sysdeps/riscv/nptl/thread_pointer.h new file mode 100644 index 0000000000..76d73f659f --- /dev/null +++ b/sysdeps/riscv/nptl/thread_pointer.h @@ -0,0 +1,35 @@ +/* __thread_pointer definition. riscv version. + Copyright (C) 2021-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#ifndef _SYS_THREAD_POINTER_H +#define _SYS_THREAD_POINTER_H + +#include + +static inline void * +__thread_pointer (void) +{ +#if __glibc_has_builtin (__builtin_thread_pointer) + return __builtin_thread_pointer (); +#else + register void *__tp __asm__ ("tp"); + return __tp; +#endif +} + +#endif /* _SYS_THREAD_POINTER_H */