Loading src/crypto/sha.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -125,8 +125,19 @@ static std::vector<uint8_t> sha256_hash_shani(const std::vector<uint8_t>& input) } static bool cpu_has_shani() { #if defined(__GNUC__) || defined(__clang__) #if defined(__SHA__) // Compiled with -msha, assume CPU supports it return true; #elif defined(__GNUC__) || defined(__clang__) #if defined(__linux__) && !defined(__GLIBC__) // musl: use cpuid directly unsigned int eax, ebx, ecx, edx; __asm__ __volatile__("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(7), "c"(0)); return (ebx >> 29) & 1; // SHA bit is bit 29 of EBX for CPUID leaf 7 #else return __builtin_cpu_supports("sha"); #endif #else return false; #endif Loading Loading
src/crypto/sha.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -125,8 +125,19 @@ static std::vector<uint8_t> sha256_hash_shani(const std::vector<uint8_t>& input) } static bool cpu_has_shani() { #if defined(__GNUC__) || defined(__clang__) #if defined(__SHA__) // Compiled with -msha, assume CPU supports it return true; #elif defined(__GNUC__) || defined(__clang__) #if defined(__linux__) && !defined(__GLIBC__) // musl: use cpuid directly unsigned int eax, ebx, ecx, edx; __asm__ __volatile__("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(7), "c"(0)); return (ebx >> 29) & 1; // SHA bit is bit 29 of EBX for CPUID leaf 7 #else return __builtin_cpu_supports("sha"); #endif #else return false; #endif Loading