Skip to content

Commit

Permalink
compiler-rt: Use FreeBSD's elf_aux_info to detect AArch64 HW features
Browse files Browse the repository at this point in the history
Using the out-of-line LSE atomics helpers for AArch64 on FreeBSD also
requires adding support for initializing __aarch64_have_lse_atomics
correctly. On Linux this is done with getauxval(3), on FreeBSD with
elf_aux_info(3), which has a slightly different interface.

Differential Revision: https://reviews.llvm.org/D109330
  • Loading branch information
DimitryAndric committed Nov 20, 2021
1 parent da47a63 commit 7dbbb5d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions compiler-rt/lib/builtins/cpu_model.c
Expand Up @@ -799,8 +799,14 @@ _Bool __aarch64_have_lse_atomics
#define HWCAP_ATOMICS (1 << 8)
#endif
static void CONSTRUCTOR_ATTRIBUTE init_have_lse_atomics(void) {
#if defined(__FreeBSD__)
unsigned long hwcap;
int result = elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
__aarch64_have_lse_atomics = result == 0 && (hwcap & HWCAP_ATOMICS) != 0;
#else
unsigned long hwcap = getauxval(AT_HWCAP);
__aarch64_have_lse_atomics = (hwcap & HWCAP_ATOMICS) != 0;
#endif
}
#endif // defined(__has_include)
#endif // __has_include(<sys/auxv.h>)
Expand Down

0 comments on commit 7dbbb5d

Please sign in to comment.