[gcc r14-8481] libatomic: Add support for __ifunc_arg_t arg in ifunc resolver
Victor Do Nascimento
victorldn@gcc.gnu.org
Sun Jan 28 20:10:06 GMT 2024
https://gcc.gnu.org/g:a899a1f2f38724cb35db0f76b67b1c3cc102ea7a
commit r14-8481-ga899a1f2f38724cb35db0f76b67b1c3cc102ea7a
Author: Victor Do Nascimento <victor.donascimento@arm.com>
Date: Thu Jan 18 19:27:25 2024 +0000
libatomic: Add support for __ifunc_arg_t arg in ifunc resolver
With support for new atomic features in Armv9.4-a being indicated by
HWCAP2 bits, Libatomic's ifunc resolver must now query its second
argument, of type __ifunc_arg_t*.
We therefore make this argument known to libatomic, allowing us to
query hwcap2 bits in the following manner:
bool
resolver (unsigned long hwcap, const __ifunc_arg_t *features);
{
return (features->hwcap2 & HWCAP2_<FEAT_NAME>);
}
libatomic/ChangeLog:
* config/linux/aarch64/host-config.h (__ifunc_arg_t):
Conditionally-defined if `sys/ifunc.h' not found.
(_IFUNC_ARG_HWCAP): Likewise.
(IFUNC_COND_1): Pass __ifunc_arg_t argument to ifunc.
(ifunc1): Modify function signature to accept __ifunc_arg_t
argument.
* configure.tgt: Add second `const __ifunc_arg_t *features'
argument to IFUNC_RESOLVER_ARGS.
Diff:
---
libatomic/config/linux/aarch64/host-config.h | 15 +++++++++++++--
libatomic/configure.tgt | 2 +-
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/libatomic/config/linux/aarch64/host-config.h b/libatomic/config/linux/aarch64/host-config.h
index 4200293c4e3e..8fd4fe3321ad 100644
--- a/libatomic/config/linux/aarch64/host-config.h
+++ b/libatomic/config/linux/aarch64/host-config.h
@@ -24,9 +24,20 @@
#if HAVE_IFUNC
#include <sys/auxv.h>
+#if __has_include(<sys/ifunc.h>)
+# include <sys/ifunc.h>
+#else
+typedef struct __ifunc_arg_t {
+ unsigned long _size;
+ unsigned long _hwcap;
+ unsigned long _hwcap2;
+} __ifunc_arg_t;
+# define _IFUNC_ARG_HWCAP (1ULL << 62)
+#endif
+
#ifdef HWCAP_USCAT
# if N == 16
-# define IFUNC_COND_1 ifunc1 (hwcap)
+# define IFUNC_COND_1 ifunc1 (hwcap, features)
# else
# define IFUNC_COND_1 (hwcap & HWCAP_ATOMICS)
# endif
@@ -48,7 +59,7 @@
#define MIDR_PARTNUM(midr) (((midr) >> 4) & 0xfff)
static inline bool
-ifunc1 (unsigned long hwcap)
+ifunc1 (unsigned long hwcap, const __ifunc_arg_t *features)
{
if (hwcap & HWCAP_USCAT)
return true;
diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
index b7609132c58c..67a5f2dff80f 100644
--- a/libatomic/configure.tgt
+++ b/libatomic/configure.tgt
@@ -194,7 +194,7 @@ esac
# The type may be different on different architectures.
case "${target}" in
aarch64*-*-*)
- IFUNC_RESOLVER_ARGS="uint64_t hwcap"
+ IFUNC_RESOLVER_ARGS="uint64_t hwcap, const __ifunc_arg_t *features"
;;
*)
IFUNC_RESOLVER_ARGS="void"
More information about the Gcc-cvs
mailing list