android.inc 1.1 KB

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