diff --git a/src/libsodium/crypto_stream/salsa20/stream_salsa20.c b/src/libsodium/crypto_stream/salsa20/stream_salsa20.c index 97b3a3c2..e7bda88c 100644 --- a/src/libsodium/crypto_stream/salsa20/stream_salsa20.c +++ b/src/libsodium/crypto_stream/salsa20/stream_salsa20.c @@ -1,13 +1,19 @@ +#if defined(HAVE_EMMINTRIN_H) || \ + (defined(_MSC_VER) && \ + (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86))) +# define INCLUDE_SSE2_IMPL +#endif + #include "crypto_stream_salsa20.h" #include "stream_salsa20.h" #include "randombytes.h" #include "runtime.h" #include "ref/stream_salsa20_ref.h" -#ifdef HAVE_EMMINTRIN_H +#ifdef INCLUDE_SSE2_IMPL # include "xmm6int/stream_salsa20_xmm6int.h" #endif -#if defined(HAVE_EMMINTRIN_H) && defined(__x86_64__) +#if defined(INCLUDE_SSE2_IMPL) && defined(__x86_64__) static const crypto_stream_salsa20_implementation *implementation = &crypto_stream_salsa20_xmm6int_implementation; #else @@ -60,13 +66,13 @@ crypto_stream_salsa20_keygen(unsigned char k[crypto_stream_salsa20_KEYBYTES]) int _crypto_stream_salsa20_pick_best_implementation(void) { -#if defined(HAVE_EMMINTRIN_H) && defined(__x86_64__) +#if defined(INCLUDE_SSE2_IMPL) && defined(__x86_64__) implementation = &crypto_stream_salsa20_xmm6int_implementation; #else implementation = &crypto_stream_salsa20_ref_implementation; #endif -#ifdef HAVE_EMMINTRIN_H +#ifdef INCLUDE_SSE2_IMPL if (sodium_runtime_has_sse2()) { implementation = &crypto_stream_salsa20_xmm6int_implementation; } diff --git a/src/libsodium/crypto_stream/salsa20/xmm6int/stream_salsa20_xmm6int.c b/src/libsodium/crypto_stream/salsa20/xmm6int/stream_salsa20_xmm6int.c index 93efdef3..bec46f3e 100644 --- a/src/libsodium/crypto_stream/salsa20/xmm6int/stream_salsa20_xmm6int.c +++ b/src/libsodium/crypto_stream/salsa20/xmm6int/stream_salsa20_xmm6int.c @@ -3,16 +3,13 @@ #include #include -#if defined(HAVE_EMMINTRIN_H) && defined(__x86_64__) - #if defined(HAVE_EMMINTRIN_H) || \ (defined(_MSC_VER) && \ (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86))) -# ifdef __GNUC__ -# pragma GCC target("sse2") -# endif -# include +#ifdef __GNUC__ +# pragma GCC target("sse2") #endif +#include #include "crypto_stream_salsa20.h" #include "private/common.h"