[compiler-rt] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)

Jon Roelofs via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 15 10:17:46 PST 2023


================
@@ -0,0 +1,12 @@
+#include <zircon/features.h>
+#include <zircon/syscalls.h>
+
+static void CONSTRUCTOR_ATTRIBUTE init_have_lse_atomics(void) {
+  // 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;
+}
----------------
jroelofs wrote:

- [ ] FIXME: needs EOF newline

https://github.com/llvm/llvm-project/pull/75635


More information about the llvm-commits mailing list