Re: [PATCH] libgcc: aarch64: Get hwcap for FreeBSD
On 07.05.20 09:25, Kyrylo Tkachov wrote: Hi Andreas, -Original Message- From: Gcc-patches On Behalf Of Andreas Tobler Sent: 06 May 2020 21:17 To: GCC Patches 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? :) No, I developed the patch before you introduced the __gnu_linux__ guard. This guard makes the patch obsolete. Thanks, Andreas
RE: [PATCH] libgcc: aarch64: Get hwcap for FreeBSD
Hi Andreas, > -Original Message- > From: Gcc-patches On Behalf Of > Andreas Tobler > Sent: 06 May 2020 21:17 > To: GCC Patches > 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 > + > + * 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, , sizeof(hwcap)); > + if (err) > +hwcap = 0; > +#endif > __aarch64_have_lse_atomics = (hwcap & HWCAP_ATOMICS) != 0; > }
Re: [PATCH] libgcc: aarch64: Get hwcap for FreeBSD
On Wed, 6 May 2020, Andreas Tobler wrote: > +#ifndef __FreeBSD__ >unsigned long hwcap = __getauxval (AT_HWCAP); > +#else > + unsigned long hwcap; Would it make sense to change the logic to #ifdef __FreeBSD__ .. #else .. #endif ? I believe that makes it easier to potentially extend this for other platforms in the future. Gerald
[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? TIA, Andreas +2020-05-05 Andreas Tobler + + * 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, , sizeof(hwcap)); + if (err) +hwcap = 0; +#endif __aarch64_have_lse_atomics = (hwcap & HWCAP_ATOMICS) != 0; }