From 6b8d872e5e2dd68a5229ec55f5261dae34ff9bdb Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 18 Jul 2017 01:06:11 -0700 Subject: Protect SSE4 code behind a compile-time flag --- src/Makefile.am | 5 ++++- src/crypto/sha256.cpp | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 35bfeb466c..f7abab482e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -263,11 +263,14 @@ crypto_libbitcoin_crypto_a_SOURCES = \ crypto/sha1.cpp \ crypto/sha1.h \ crypto/sha256.cpp \ - crypto/sha256_sse4.cpp \ crypto/sha256.h \ crypto/sha512.cpp \ crypto/sha512.h +if EXPERIMENTAL_ASM +crypto_libbitcoin_crypto_a_SOURCES += crypto/sha256_sse4.cpp +endif + # consensus: shared between all executables that validate any consensus rules. libbitcoin_consensus_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) libbitcoin_consensus_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) diff --git a/src/crypto/sha256.cpp b/src/crypto/sha256.cpp index 25f4eabd4c..15d6db90c2 100644 --- a/src/crypto/sha256.cpp +++ b/src/crypto/sha256.cpp @@ -10,12 +10,14 @@ #include #if defined(__x86_64__) || defined(__amd64__) +#if defined(EXPERIMENTAL_ASM) #include namespace sha256_sse4 { void Transform(uint32_t* s, const unsigned char* chunk, size_t blocks); } #endif +#endif // Internal implementation code. namespace @@ -176,7 +178,7 @@ TransformType Transform = sha256::Transform; std::string SHA256AutoDetect() { -#if defined(__x86_64__) || defined(__amd64__) +#if defined(EXPERIMENTAL_ASM) && (defined(__x86_64__) || defined(__amd64__)) uint32_t eax, ebx, ecx, edx; if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) && (ecx >> 19) & 1) { Transform = sha256_sse4::Transform; -- cgit v1.2.3