Hi all,
Since FreeBSD 12, FreeBSD has a sys/auxv.h header too but it doesn't
provide the getauxval function. Instead it offers the elf_aux_info
function which provides a similar functionality.
This patch gets the hwcap for FreeBSD.
Is this ok for trunk?
TIA,
Andreas
+2020-05-05 Andreas Tobler <andre...@gcc.gnu.org>
+
+ * config/aarch64/lse-init.c: Get hwcap for FreeBSD.
+
diff --git a/libgcc/config/aarch64/lse-init.c
b/libgcc/config/aarch64/lse-init.c
index 00e9ab8cd1c..ab0d6b2f754 100644
--- a/libgcc/config/aarch64/lse-init.c
+++ b/libgcc/config/aarch64/lse-init.c
@@ -41,7 +41,16 @@ unsigned long int __getauxval (unsigned long int);
static void __attribute__((constructor))
init_have_lse_atomics (void)
{
+#ifndef __FreeBSD__
unsigned long hwcap = __getauxval (AT_HWCAP);
+#else
+ unsigned long hwcap;
+ int err;
+
+ err = elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
+ if (err)
+ hwcap = 0;
+#endif
__aarch64_have_lse_atomics = (hwcap & HWCAP_ATOMICS) != 0;
}