Fix Clang 3.3 and 3.4 compiles (Issue 264)

pull/301/head
Jeffrey Walton 2016-09-21 13:57:37 -04:00
parent 1de8ca5774
commit 6200029faa
6 changed files with 36 additions and 6 deletions

11
sha.cpp
View File

@ -20,6 +20,13 @@
#include "misc.h" #include "misc.h"
#include "cpu.h" #include "cpu.h"
#if defined(CRYPTOPP_DISABLE_SHA_ASM)
# undef CRYPTOPP_X86_ASM_AVAILABLE
# undef CRYPTOPP_X32_ASM_AVAILABLE
# undef CRYPTOPP_X64_ASM_AVAILABLE
# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
#endif
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
// start of Steve Reid's code // start of Steve Reid's code
@ -102,7 +109,7 @@ void SHA256::InitState(HashWordType *state)
memcpy(state, s, sizeof(s)); memcpy(state, s, sizeof(s));
} }
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_SHA_ASM) #if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
CRYPTOPP_ALIGN_DATA(16) extern const word32 SHA256_K[64] CRYPTOPP_SECTION_ALIGN16 = { CRYPTOPP_ALIGN_DATA(16) extern const word32 SHA256_K[64] CRYPTOPP_SECTION_ALIGN16 = {
#else #else
extern const word32 SHA256_K[64] = { extern const word32 SHA256_K[64] = {
@ -127,7 +134,7 @@ extern const word32 SHA256_K[64] = {
#endif // #ifndef CRYPTOPP_GENERATE_X64_MASM #endif // #ifndef CRYPTOPP_GENERATE_X64_MASM
#if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_GENERATE_X64_MASM)) && !defined(CRYPTOPP_DISABLE_SHA_ASM) #if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_GENERATE_X64_MASM))
static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32 *data, size_t len static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32 *data, size_t len
#if defined(_MSC_VER) && (_MSC_VER == 1200) #if defined(_MSC_VER) && (_MSC_VER == 1200)

1
sha.h
View File

@ -11,6 +11,7 @@
#include "iterhash.h" #include "iterhash.h"
// Clang 3.3 integrated assembler crash on Linux // Clang 3.3 integrated assembler crash on Linux
// http://github.com/weidai11/cryptopp/issues/264
#if defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400) #if defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400)
# define CRYPTOPP_DISABLE_SHA_ASM # define CRYPTOPP_DISABLE_SHA_ASM
#endif #endif

View File

@ -7,6 +7,13 @@
#include "misc.h" #include "misc.h"
#include "cpu.h" #include "cpu.h"
#if defined(CRYPTOPP_DISABLE_TIGER_ASM)
# undef CRYPTOPP_X86_ASM_AVAILABLE
# undef CRYPTOPP_X32_ASM_AVAILABLE
# undef CRYPTOPP_X64_ASM_AVAILABLE
# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
#endif
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
void Tiger::InitState(HashWordType *state) void Tiger::InitState(HashWordType *state)

View File

@ -4,6 +4,12 @@
#include "config.h" #include "config.h"
#include "iterhash.h" #include "iterhash.h"
// Clang 3.3 integrated assembler crash on Linux
// http://github.com/weidai11/cryptopp/issues/264
#if defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400)
# define CRYPTOPP_DISABLE_TIGER_ASM
#endif
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
/// <a href="http://www.cryptolounge.org/wiki/Tiger">Tiger</a> /// <a href="http://www.cryptolounge.org/wiki/Tiger">Tiger</a>

View File

@ -9,6 +9,13 @@
#include "argnames.h" #include "argnames.h"
#include "secblock.h" #include "secblock.h"
#if defined(CRYPTOPP_DISABLE_VMAC_ASM)
# undef CRYPTOPP_X86_ASM_AVAILABLE
# undef CRYPTOPP_X32_ASM_AVAILABLE
# undef CRYPTOPP_X64_ASM_AVAILABLE
# undef CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
#endif
#if CRYPTOPP_MSC_VERSION #if CRYPTOPP_MSC_VERSION
# pragma warning(disable: 4731) # pragma warning(disable: 4731)
#endif #endif
@ -154,13 +161,13 @@ void VMAC_Base::HashEndianCorrectedBlock(const word64 *data)
unsigned int VMAC_Base::OptimalDataAlignment() const unsigned int VMAC_Base::OptimalDataAlignment() const
{ {
return return
#if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_VMAC_ASM) #if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
HasSSE2() ? 16 : HasSSE2() ? 16 :
#endif #endif
GetCipher().OptimalDataAlignment(); GetCipher().OptimalDataAlignment();
} }
#if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || (CRYPTOPP_BOOL_X32 && !defined(CRYPTOPP_DISABLE_VMAC_ASM)))) #if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32)
#if CRYPTOPP_MSC_VERSION #if CRYPTOPP_MSC_VERSION
# pragma warning(disable: 4731) // frame pointer register 'ebp' modified by inline assembly code # pragma warning(disable: 4731) // frame pointer register 'ebp' modified by inline assembly code
#endif #endif
@ -798,7 +805,7 @@ void VMAC_Base::VHASH_Update_Template(const word64 *data, size_t blocksRemaining
inline void VMAC_Base::VHASH_Update(const word64 *data, size_t blocksRemainingInWord64) inline void VMAC_Base::VHASH_Update(const word64 *data, size_t blocksRemainingInWord64)
{ {
#if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || (CRYPTOPP_BOOL_X32 && !defined(CRYPTOPP_DISABLE_VMAC_ASM)))) #if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32)
if (HasSSE2()) if (HasSSE2())
{ {
VHASH_Update_SSE2(data, blocksRemainingInWord64, 0); VHASH_Update_SSE2(data, blocksRemainingInWord64, 0);

4
vmac.h
View File

@ -10,7 +10,9 @@
#include "iterhash.h" #include "iterhash.h"
#include "seckey.h" #include "seckey.h"
#if CRYPTOPP_BOOL_X32 // Clang 3.3 integrated assembler crash on Linux
// http://github.com/weidai11/cryptopp/issues/264
#if (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400)) || CRYPTOPP_BOOL_X32
# define CRYPTOPP_DISABLE_VMAC_ASM # define CRYPTOPP_DISABLE_VMAC_ASM
#endif #endif