Index: compiler-rt/lib/scudo/scudo_utils.cpp =================================================================== --- compiler-rt/lib/scudo/scudo_utils.cpp +++ compiler-rt/lib/scudo/scudo_utils.cpp @@ -16,7 +16,12 @@ #if defined(__x86_64__) || defined(__i386__) # include #elif defined(__arm__) || defined(__aarch64__) -# include "sanitizer_common/sanitizer_getauxval.h" +# if SANITIZER_FUCHSIA +# include +# include +# else +# include "sanitizer_common/sanitizer_getauxval.h" +# endif // SANITIZER_FUCHSIA # if SANITIZER_POSIX # include "sanitizer_common/sanitizer_posix.h" # include @@ -80,6 +85,24 @@ # ifndef HWCAP_CRC32 # define HWCAP_CRC32 (1 << 7) // HWCAP_CRC32 is missing on older platforms. # endif + +# 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 + # if SANITIZER_POSIX bool hasHardwareCRC32ARMPosix() { uptr F = internal_open("/proc/self/auxv", O_RDONLY); @@ -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__)