From 7821009bff1c69f6dd20ade6801e61358a659a1a Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Fri, 29 May 2015 12:07:05 +0200 Subject: [PATCH] Do not assume that _MSC_VER being defined implied x86 or x64 --- .../scryptsalsa208sha256/crypto_scrypt-common.c | 6 ++++-- .../sse/pwhash_scryptsalsa208sha256_sse.c | 3 ++- src/libsodium/sodium/runtime.c | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c index 77be6ab9..8e9aceff 100644 --- a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +++ b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c @@ -153,7 +153,8 @@ escrypt_r(escrypt_local_t * local, const uint8_t * passwd, size_t passwdlen, if (need > buflen || need < saltlen) { return NULL; } -#if defined(HAVE_EMMINTRIN_H) || defined(_MSC_VER) +#if defined(HAVE_EMMINTRIN_H) || \ + (defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86))) escrypt_kdf = sodium_runtime_has_sse2() ? escrypt_kdf_sse : escrypt_kdf_nosse; #else @@ -234,7 +235,8 @@ crypto_pwhash_scryptsalsa208sha256_ll(const uint8_t * passwd, size_t passwdlen, if (escrypt_init_local(&local)) { return -1; /* LCOV_EXCL_LINE */ } -#if defined(HAVE_EMMINTRIN_H) || defined(_MSC_VER) +#if defined(HAVE_EMMINTRIN_H) || \ + (defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86))) escrypt_kdf = sodium_runtime_has_sse2() ? escrypt_kdf_sse : escrypt_kdf_nosse; #else diff --git a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c index a5202ed6..faba9f17 100644 --- a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +++ b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c @@ -28,7 +28,8 @@ * online backup system. */ -#if defined(HAVE_EMMINTRIN_H) || defined(_MSC_VER) +#if defined(HAVE_EMMINTRIN_H) || \ + (defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86))) #if __GNUC__ # pragma GCC target("sse2") #endif diff --git a/src/libsodium/sodium/runtime.c b/src/libsodium/sodium/runtime.c index 3e424a01..93b07932 100644 --- a/src/libsodium/sodium/runtime.c +++ b/src/libsodium/sodium/runtime.c @@ -43,7 +43,8 @@ _sodium_runtime_arm_cpu_features(CPUFeatures * const cpu_features) static void _cpuid(unsigned int cpu_info[4U], const unsigned int cpu_info_type) { -#ifdef _MSC_VER +#if defined(_MSC_VER) && \ + (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)) __cpuid((int *) cpu_info, cpu_info_type); #elif defined(HAVE_CPUID) cpu_info[0] = cpu_info[1] = cpu_info[2] = cpu_info[3] = 0;