public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: libc-alpha@sourceware.org
Cc: caiyinyu <caiyinyu@loongson.cn>, Wang Xuerui <i@xen0n.name>,
	Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	Xi Ruoyao <xry111@xry111.site>
Subject: [PATCH 2/5] LoongArch: Add LOONGARCH_HAVE_UAL macro
Date: Sat, 15 Apr 2023 19:23:37 +0800	[thread overview]
Message-ID: <20230415112340.38431-3-xry111@xry111.site> (raw)
In-Reply-To: <20230415112340.38431-1-xry111@xry111.site>

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
+   <https://www.gnu.org/licenses/>.  */
+
+#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
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _LINUX_LOONGARCH_FEATURES_H
+#define _LINUX_LOONGARCH_FEATURES_H 1
+
+#ifndef __ASSEMBLER__
+# include <ldsodefs.h>
+
+# define LOONGARCH_HAVE_UAL	(GLRO (dl_hwcap) & HWCAP_LOONGARCH_UAL)
+#endif
+
+#include_next <loongarch-features.h>
+
+#endif  /* loongarch-features.h */
-- 
2.39.2


  parent reply	other threads:[~2023-04-15 11:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-15 11:23 [PATCH 0/5] LoongArch: Multiarch string and memory copy routines for unaligned access Xi Ruoyao
2023-04-15 11:23 ` [PATCH 1/5] LoongArch: Add bits/hwcap.h for Linux Xi Ruoyao
2023-04-15 11:23 ` Xi Ruoyao [this message]
2023-04-15 11:23 ` [PATCH 3/5] string: stpcpy.c: Only alias __stpcpy to stpcpy if STPCPY undefined Xi Ruoyao
2023-04-15 11:23 ` [PATCH 4/5] LoongArch: Multiarch stpcpy for unaligned access Xi Ruoyao
2023-04-15 11:23 ` [PATCH 5/5] LoongArch: Multiarch memcpy " Xi Ruoyao
2023-04-18  3:01 ` [PATCH 0/5] LoongArch: Multiarch string and memory copy routines " caiyinyu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230415112340.38431-3-xry111@xry111.site \
    --to=xry111@xry111.site \
    --cc=adhemerval.zanella@linaro.org \
    --cc=caiyinyu@loongson.cn \
    --cc=i@xen0n.name \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).