From c02f84fc08ac4c6c89f4ad1f7e39be935413ec37 Mon Sep 17 00:00:00 2001 From: sunerok Date: Mon, 9 Sep 2024 19:28:21 -0400 Subject: [PATCH] fix use-sse2 for arm64 --- src/crypto/pow/scrypt.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/crypto/pow/scrypt.cpp b/src/crypto/pow/scrypt.cpp index a5410e68..3fd52e75 100644 --- a/src/crypto/pow/scrypt.cpp +++ b/src/crypto/pow/scrypt.cpp @@ -37,13 +37,24 @@ // #include #include -// #if defined(_MSC_VER) -// #include -// #elif defined(__GNUC__) -// #include -// #endif +#if defined(USE_SSE2) && !defined(USE_SSE2_ALWAYS) -/* +#ifdef _MSC_VER + +// MSVC 64bit is unable to use inline asm + +#include + +#else + // GCC Linux or i686-w64-mingw32 + +#include + +#endif + +#endif + +#ifndef __FreeBSD__ static inline uint32_t be32dec(const void *pp) { const uint8_t *p = (uint8_t const *)pp; @@ -61,6 +72,8 @@ static inline void be32enc(void *pp, uint32_t x) p[0] = (x >> 24) & 0xff; } +#endif + /** * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen): * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and @@ -220,7 +233,7 @@ void scrypt_1024_1_1_256_sp_generic(const char *input, char *output, char *scrat PBKDF2_SHA256((const uint8_t *)input, 80, B, 128, 1, (uint8_t *)output, 32); } -#if defined(HAVE_SSE2) +#if defined(USE_SSE2) // By default, set to generic scrypt function. This will prevent crash in case when scrypt_detect_sse2() wasn't called void (*scrypt_1024_1_1_256_sp_detected)(const char *input, char *output, char *scratchpad) = &scrypt_1024_1_1_256_sp_generic;