Hi Andreas,

> -----Original Message-----
> From: Gcc-patches <gcc-patches-boun...@gcc.gnu.org> On Behalf Of
> Andreas Tobler
> Sent: 06 May 2020 21:17
> To: GCC Patches <gcc-patches@gcc.gnu.org>
> Subject: [PATCH] libgcc: aarch64: Get hwcap for FreeBSD
> 
> 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?

This whole thing is gated on __gnu_linux__.  Does FreeBSD set that?

Thanks,
Kyrill

> 
> 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;
>   }

Reply via email to