#include "checksum.h"
#include "atomic_helpers.h"
#include "chunk.h"
#if defined(__x86_64__) || defined(__i386__)
#include <cpuid.h>
#elif defined(__arm__) || defined(__aarch64__)
#if SCUDO_FUCHSIA
#include <zircon/features.h>
#include <zircon/syscalls.h>
#else
#include <sys/auxv.h>
#endif
#elif defined(__loongarch__)
#include <sys/auxv.h>
#endif
namespace scudo {
Checksum HashAlgorithm = …;
#if defined(__x86_64__) || defined(__i386__)
#ifndef bit_SSE4_2
#define bit_SSE4_2 …
#endif
#ifndef signature_HYGON_ebx
#define signature_HYGON_ebx …
#define signature_HYGON_edx …
#define signature_HYGON_ecx …
#endif
bool hasHardwareCRC32() { … }
#elif defined(__arm__) || defined(__aarch64__)
#ifndef AT_HWCAP
#define AT_HWCAP …
#endif
#ifndef HWCAP_CRC32
#define HWCAP_CRC32 …
#endif
bool hasHardwareCRC32() {
#if SCUDO_FUCHSIA
u32 HWCap;
const zx_status_t Status =
zx_system_get_features(ZX_FEATURE_KIND_CPU, &HWCap);
if (Status != ZX_OK)
return false;
return !!(HWCap & ZX_ARM64_FEATURE_ISA_CRC32);
#else
return !!(getauxval(AT_HWCAP) & HWCAP_CRC32);
#endif
}
#elif defined(__loongarch__)
#ifndef HWCAP_LOONGARCH_CRC32
#define HWCAP_LOONGARCH_CRC32 …
#endif
bool hasHardwareCRC32() {
return !!(getauxval(AT_HWCAP) & HWCAP_LOONGARCH_CRC32);
}
#else
bool hasHardwareCRC32() { return false; }
#endif
}