]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[AArch64] Use __getauxval instead of getauxval in LSE detection code in libgcc
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Wed, 6 May 2020 15:20:38 +0000 (16:20 +0100)
committerAndre Vieira <andre.simoesdiasvieira@arm.com>
Fri, 29 May 2020 13:01:34 +0000 (14:01 +0100)
This version of the fix uses __getauxval instead of getauxval.
The whole thing is guarded simply on __gnu_linux__.
__getauxval was introduced in 2.16 but the aarch64 port was added in 2.17 so in practice I expect all aarch64 glibcs to support __getauxval.

Bootstrapped and tested on aarch64-none-linux-gnu.
Also tested on aarch64-none-elf.

2020-05-06  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

* config/aarch64/lse-init.c (init_have_lse_atomics): Use __getauxval
instead of getauxval.
(AT_HWCAP): Define.
(HWCAP_ATOMICS): Define.
Guard detection on __gnu_linux__.

(cherry picked from commit 1266778548e20de82983b6446f3cb685068cfb1e)

libgcc/config/aarch64/lse-init.c

index 1a8f4c55213f25c67c8bb8cdc1cc6f1bbe3255cb..2f2921349e7e27a9436f9d0fd596be45c0ee5dbe 100644 (file)
@@ -29,19 +29,20 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 _Bool __aarch64_have_lse_atomics
   __attribute__((visibility("hidden"), nocommon));
 
-/* Disable initialization of __aarch64_have_lse_atomics during bootstrap.  */
-#if !defined(inhibit_libc) && defined(HAVE_SYS_AUXV_H)
-# include <sys/auxv.h>
+/* Gate availability of __getauxval on glibc.  All AArch64-supporting glibc
+   versions support it.  */
+#ifdef __gnu_linux__
 
-/* Disable initialization if the system headers are too old.  */
-# if defined(AT_HWCAP) && defined(HWCAP_ATOMICS)
+# define AT_HWCAP      16
+# define HWCAP_ATOMICS (1 << 8)
+
+unsigned long int __getauxval (unsigned long int);
 
 static void __attribute__((constructor))
 init_have_lse_atomics (void)
 {
-  unsigned long hwcap = getauxval (AT_HWCAP);
+  unsigned long hwcap = __getauxval (AT_HWCAP);
   __aarch64_have_lse_atomics = (hwcap & HWCAP_ATOMICS) != 0;
 }
 
-# endif /* HWCAP */
-#endif /* inhibit_libc */
+#endif /* __gnu_linux__  */