Debian Codegraph @

compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/android.inc

raw
1 #include <string.h>
2 #include <sys/auxv.h>
3 #include <sys/system_properties.h>
4
5 static bool __isExynos9810(void) {
6 char arch[PROP_VALUE_MAX];
7 return __system_property_get("ro.arch", arch) > 0 &&
8 strncmp(arch, "exynos9810", sizeof("exynos9810") - 1) == 0;
9 }
10
11 static void CONSTRUCTOR_ATTRIBUTE init_have_lse_atomics(void) {
12 unsigned long hwcap = getauxval(AT_HWCAP);
13 _Bool result = (hwcap & HWCAP_ATOMICS) != 0;
14 if (result) {
15 // Some cores in the Exynos 9810 CPU are ARMv8.2 and others are ARMv8.0;
16 // only the former support LSE atomics. However, the kernel in the
17 // initial Android 8.0 release of Galaxy S9/S9+ devices incorrectly
18 // reported the feature as being supported.
19 //
20 // The kernel appears to have been corrected to mark it unsupported as of
21 // the Android 9.0 release on those devices, and this issue has not been
22 // observed anywhere else. Thus, this workaround may be removed if
23 // compiler-rt ever drops support for Android 8.0.
24 if (__isExynos9810())
25 result = false;
26 }
27 __aarch64_have_lse_atomics = result;
28 }