From patchwork Wed Oct 23 20:18:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 99455 X-Patchwork-Delegate: arjun.is@lostca.se Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 07DFC3858D21 for ; Wed, 23 Oct 2024 20:19:06 +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 110093858D21 for ; Wed, 23 Oct 2024 20:18:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 110093858D21 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 110093858D21 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=1729714724; cv=none; b=LaRxTxNdPinxM2FWnqC47U4FhIzOSHltsxsh2oKUpyLWAkxxgw+fgj5BvkO31iqdTnZS9AWPtnM3pnBWcji1UJyu70LiXE1YYb1w7y54DftHn+mtCxy5AtViA0BwpaE0FvpH7b1WeBHYGpWv/Y/KBYdwoDq8/FXMwvZgzIV2CFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729714724; c=relaxed/simple; bh=uLiBlRwx+ugoxbszvJ9XqepuiEEzTnzakOkEMX8WFa4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=K/rje0ePzEA8zO/GgfAuPDfzmLaFhLuE7StKaHsebnXJXqXOyFSbXLcdF4MDJPHQaqfMuluoS5ZP7I8h+IkBaFGCfRonhSLVFCFh2RWCW2L0tLILbHvHvAzDRPp0EkF41tBAkeS1hw/qzDAkytogT6iTduTqrvAxo7t6VC+tvm4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1729714720; bh=uLiBlRwx+ugoxbszvJ9XqepuiEEzTnzakOkEMX8WFa4=; h=From:To:Cc:Subject:Date:From; b=TbBlMm4sQ5k8XbHcSUd+gacv5Q7NhgVb/O2tUAFx7mYd7j6x8B6YrQsiGNObB2hBo GvnmaxKD1Xhw/h+aRHHWvRVyHSccTazjyBJO6vdr0X0aFFasLbXO2//+rXwTNFVILz cXM5uHqcCXMV48OQZb/dylEILV0umX+mnH1ckgNR/aHGjp+VaL6jA8Z8mqX8Q320sn qIb/sblpuYttiXMgFViN6W9gtq9ZQU331Af1PnT9h6vRXWSsGMUl0j9N2K7frpxJFN EFSIvXHPu1MdmJzPJnXDPlVBGCBxoTYWf79wrO0GzA1PJFhQAzE7pco0B3EmKeaDJw 04W8uPFdBbp7A== 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 4XYgNc31mRzjNR; Wed, 23 Oct 2024 16:18:40 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Yinyu Cai , mengqinggang Subject: [PATCH] nptl: Add for LoongArch Date: Wed, 23 Oct 2024 16:18:06 -0400 Message-ID: <20241023201826.573788-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~patchwork=sourceware.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. Both code paths are compile tested with build-many-glibcs.py but I don't have access to any hardware to run the tests. Signed-off-by: Michael Jeanson Reviewed-by: Arjun Shankar --- Cc: Florian Weimer Cc: Yinyu Cai Cc: mengqinggang --- sysdeps/loongarch/nptl/thread_pointer.h | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 sysdeps/loongarch/nptl/thread_pointer.h diff --git a/sysdeps/loongarch/nptl/thread_pointer.h b/sysdeps/loongarch/nptl/thread_pointer.h new file mode 100644 index 0000000000..5dec2ef4c6 --- /dev/null +++ b/sysdeps/loongarch/nptl/thread_pointer.h @@ -0,0 +1,36 @@ +/* __thread_pointer definition. loongarch 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 + void *__thread_register; + __asm__ ("move %0, $tp" : "=r" (__thread_register)); + return __thread_register; +#endif +} + +#endif /* _SYS_THREAD_POINTER_H */