[compiler-rt] 4e731ab - [compiler-rt][AArch64] Initialize __aarch64_have_lse_atomics for Fuchsia
Roland McGrath via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 28 11:49:39 PDT 2022
Author: Roland McGrath
Date: 2022-03-28T11:49:31-07:00
New Revision: 4e731abc55681751b5d736b613f7720e50eb1ad4
URL: https://github.com/llvm/llvm-project/commit/4e731abc55681751b5d736b613f7720e50eb1ad4
DIFF: https://github.com/llvm/llvm-project/commit/4e731abc55681751b5d736b613f7720e50eb1ad4.diff
LOG: [compiler-rt][AArch64] Initialize __aarch64_have_lse_atomics for Fuchsia
Use Fuchsia's zx_system_get_features API to determine
whether LSE atomics are available on the machine.
Reviewed By: abrachet
Differential Revision: https://reviews.llvm.org/D118839
Added:
Modified:
compiler-rt/lib/builtins/cpu_model.c
Removed:
################################################################################
diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c
index c5913f763dd24..7651e84f876c0 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -801,12 +801,23 @@ _Bool __aarch64_have_lse_atomics
#if defined(__ANDROID__)
#include <string.h>
#include <sys/system_properties.h>
+#elif defined(__Fuchsia__)
+#include <zircon/features.h>
+#include <zircon/syscalls.h>
#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;
+#elif defined(__Fuchsia__)
+ // This ensures the vDSO is a direct link-time dependency of anything that
+ // needs this initializer code.
+#pragma comment(lib, "zircon")
+ uint32_t features;
+ zx_status_t status = _zx_system_get_features(ZX_FEATURE_KIND_CPU, &features);
+ __aarch64_have_lse_atomics =
+ status == ZX_OK && (features & ZX_ARM64_FEATURE_ISA_ATOMICS) != 0;
#else
unsigned long hwcap = getauxval(AT_HWCAP);
_Bool result = (hwcap & HWCAP_ATOMICS) != 0;
More information about the llvm-commits
mailing list