Index: compiler-rt/lib/scudo/scudo_utils.cpp =================================================================== --- compiler-rt/lib/scudo/scudo_utils.cpp +++ compiler-rt/lib/scudo/scudo_utils.cpp @@ -16,11 +16,17 @@ #if defined(__x86_64__) || defined(__i386__) # include #elif defined(__arm__) || defined(__aarch64__) -# include "sanitizer_common/sanitizer_getauxval.h" # if SANITIZER_POSIX # include "sanitizer_common/sanitizer_posix.h" # include -# endif +# else +# if SANITIZER_FUCHSIA +# include +# include +# else +# include "sanitizer_common/sanitizer_getauxval.h" +# endif //SANITIZER_FUCHSIA +# endif // SANITIZER_POSIX #endif #include @@ -80,6 +86,7 @@ # ifndef HWCAP_CRC32 # define HWCAP_CRC32 (1 << 7) // HWCAP_CRC32 is missing on older platforms. # endif + # if SANITIZER_POSIX bool hasHardwareCRC32ARMPosix() { uptr F = internal_open("/proc/self/auxv", O_RDONLY); @@ -97,6 +104,22 @@ } # else bool hasHardwareCRC32ARMPosix() { return false; } +# if SANITIZER_FUCHSIA +bool hasHardwareCRC32() { + u32 HWCap; + zx_status_t RetVal = zx_system_get_features(ZX_FEATURE_KIND_CPU, &HWCap); + if (RetVal != ZX_OK || (HWCap & ZX_ARM64_FEATURE_ISA_CRC32) == 0) { + return false; + } + return true; +} +# else +bool hasHardwareCRC32() { + if (&getauxval && areBionicGlobalsInitialized()) + return !!(getauxval(AT_HWCAP) & HWCAP_CRC32); + return hasHardwareCRC32ARMPosix(); +} +# endif //SANITIZER_FUCHSIA # endif // SANITIZER_POSIX // Bionic doesn't initialize its globals early enough. This causes issues when @@ -108,12 +131,6 @@ INLINE bool areBionicGlobalsInitialized() { return !SANITIZER_ANDROID || (&__progname && __progname); } - -bool hasHardwareCRC32() { - if (&getauxval && areBionicGlobalsInitialized()) - return !!(getauxval(AT_HWCAP) & HWCAP_CRC32); - return hasHardwareCRC32ARMPosix(); -} #else bool hasHardwareCRC32() { return false; } #endif // defined(__x86_64__) || defined(__i386__)