From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id B2D953857733 for ; Sat, 15 Apr 2023 11:23:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B2D953857733 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1681557837; bh=sfmBMlgV3JqYncyjExreQngTKo1Pl1vuXdlsks4Hn60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MVzaqJ84ExQwghzb5hkLdvGXlDvg3ZfHejanuWh7Nehfww1p3XfGgSI0sTFOeUIEo q6XLVXk1EeTwG0l0td6VYALgbMioPjRdOKG8hLLwDH6kaOmotCDFHpmv3clyyDjAvE 9chnjN9HA4r7K3GDj+1mNUo0Pam9ZkAhgECcLtR4= Received: from stargazer.. (unknown [113.140.11.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id C5E8C660BB; Sat, 15 Apr 2023 07:23:56 -0400 (EDT) From: Xi Ruoyao To: libc-alpha@sourceware.org Cc: caiyinyu , Wang Xuerui , Adhemerval Zanella Netto , Xi Ruoyao Subject: [PATCH 2/5] LoongArch: Add LOONGARCH_HAVE_UAL macro Date: Sat, 15 Apr 2023 19:23:37 +0800 Message-Id: <20230415112340.38431-3-xry111@xry111.site> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230415112340.38431-1-xry111@xry111.site> References: <20230415112340.38431-1-xry111@xry111.site> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,LIKELY_SPAM_FROM,RCVD_IN_BARRACUDACENTRAL,SPF_HELO_PASS,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 List-Id: On Linux, we can determine if the CPU supports unaligned access via HWCAP. Otherwise, we conservatively assume the CPU does not support unaligned access. Maybe we should add a built-in macro for GCC to tell if -m[no-]strict-align is used, but it won't happen for GCC 12 and 13. --- sysdeps/loongarch/loongarch-features.h | 26 ++++++++++++++++ .../sysv/linux/loongarch/loongarch-features.h | 30 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 sysdeps/loongarch/loongarch-features.h create mode 100644 sysdeps/unix/sysv/linux/loongarch/loongarch-features.h diff --git a/sysdeps/loongarch/loongarch-features.h b/sysdeps/loongarch/loongarch-features.h new file mode 100644 index 0000000000..722b4b61dc --- /dev/null +++ b/sysdeps/loongarch/loongarch-features.h @@ -0,0 +1,26 @@ +/* Macros to test for CPU features on LoongArch. + Copyright (C) 2023 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 _LOONGARCH_LOONGARCH_FEATURES_H +#define _LOONGARCH_LOONGARCH_FEATURES_H 1 + +#ifndef LOONGARCH_HAVE_UAL +# define LOONGARCH_HAVE_UAL 0 +#endif + +#endif /* loongarch-features.h */ diff --git a/sysdeps/unix/sysv/linux/loongarch/loongarch-features.h b/sysdeps/unix/sysv/linux/loongarch/loongarch-features.h new file mode 100644 index 0000000000..d4c18d3cfe --- /dev/null +++ b/sysdeps/unix/sysv/linux/loongarch/loongarch-features.h @@ -0,0 +1,30 @@ +/* Macros to test for CPU features on LoongArch. Linux version. + Copyright (C) 2023 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 _LINUX_LOONGARCH_FEATURES_H +#define _LINUX_LOONGARCH_FEATURES_H 1 + +#ifndef __ASSEMBLER__ +# include + +# define LOONGARCH_HAVE_UAL (GLRO (dl_hwcap) & HWCAP_LOONGARCH_UAL) +#endif + +#include_next + +#endif /* loongarch-features.h */ -- 2.39.2