Fix compilation under clang-cl.

pull/397/head
RaptorFactor 2017-03-25 23:31:45 -07:00
parent 095740c1fe
commit 30033fde77
3 changed files with 34 additions and 8 deletions

View File

@ -209,12 +209,6 @@ typedef unsigned int word32;
typedef word64 lword; typedef word64 lword;
const lword LWORD_MAX = W64LIT(0xffffffffffffffff); const lword LWORD_MAX = W64LIT(0xffffffffffffffff);
// Clang pretends to be VC++, too.
// See http://github.com/weidai11/cryptopp/issues/147
#if defined(_MSC_VER) && defined(__clang__)
# error: "Unsupported configuration"
#endif
#ifdef __GNUC__ #ifdef __GNUC__
#define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif #endif
@ -327,7 +321,7 @@ NAMESPACE_END
#define CRYPTOPP_FASTCALL #define CRYPTOPP_FASTCALL
#endif #endif
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(__clang__)
#define CRYPTOPP_NO_VTABLE __declspec(novtable) #define CRYPTOPP_NO_VTABLE __declspec(novtable)
#else #else
#define CRYPTOPP_NO_VTABLE #define CRYPTOPP_NO_VTABLE

View File

@ -195,7 +195,7 @@ static word AtomicInverseModPower2(word A)
#define HighWord(a) a##1 #define HighWord(a) a##1
#ifdef _MSC_VER #ifdef _MSC_VER
#define MultiplyWordsLoHi(p0, p1, a, b) p0 = _umul128(a, b, &p1); #define MultiplyWordsLoHi(p0, p1, a, b) p0 = _umul128(a, b, &p1);
#ifndef __INTEL_COMPILER #if !defined(__INTEL_COMPILER) && !defined(__clang__)
#define Double3Words(c, d) d##1 = __shiftleft128(d##0, d##1, 1); d##0 = __shiftleft128(c, d##0, 1); c *= 2; #define Double3Words(c, d) d##1 = __shiftleft128(d##0, d##1, 1); d##0 = __shiftleft128(c, d##0, 1); c *= 2;
#endif #endif
#elif defined(__DECCXX) #elif defined(__DECCXX)

View File

@ -152,6 +152,14 @@ inline void RDRAND32(void* output)
: "=a" (*reinterpret_cast<word32*>(output)) : "=a" (*reinterpret_cast<word32*>(output))
: : "cc" : : "cc"
); );
#elif defined(CRYPTOPP_MSC_VERSION) && defined(CRYPTOPP_LLVM_CLANG_VERSION)
__asm__ __volatile__
(
".byte 0x0f, 0xc7, 0xf0;\n"
".byte 0x73, 0xfb;\n"
: "=a" (*reinterpret_cast<word32*>(output))
: : "cc"
);
#elif defined(ALL_RDRAND_INTRIN_AVAILABLE) #elif defined(ALL_RDRAND_INTRIN_AVAILABLE)
while(!_rdrand32_step(reinterpret_cast<word32*>(output))) {} while(!_rdrand32_step(reinterpret_cast<word32*>(output))) {}
#else #else
@ -191,6 +199,14 @@ inline void RDRAND64(void* output)
: "=a" (*reinterpret_cast<word64*>(output)) : "=a" (*reinterpret_cast<word64*>(output))
: : "cc" : : "cc"
); );
#elif defined(CRYPTOPP_MSC_VERSION) && defined(CRYPTOPP_LLVM_CLANG_VERSION)
__asm__ __volatile__
(
".byte 0x48, 0x0f, 0xc7, 0xf0;\n"
".byte 0x73, 0xfa;\n"
: "=a" (*reinterpret_cast<word64*>(output))
: : "cc"
);
#elif defined(ALL_RDRAND_INTRIN_AVAILABLE) #elif defined(ALL_RDRAND_INTRIN_AVAILABLE)
while(!_rdrand64_step(reinterpret_cast<unsigned long long*>(output))) {} while(!_rdrand64_step(reinterpret_cast<unsigned long long*>(output))) {}
#else #else
@ -296,6 +312,14 @@ inline void RDSEED32(void* output)
: "=a" (*reinterpret_cast<word32*>(output)) : "=a" (*reinterpret_cast<word32*>(output))
: : "cc" : : "cc"
); );
#elif defined(CRYPTOPP_MSC_VERSION) && defined(CRYPTOPP_LLVM_CLANG_VERSION)
__asm__ __volatile__
(
".byte 0x0f, 0xc7, 0xf8;\n"
".byte 0x73, 0xfb;\n"
: "=a" (*reinterpret_cast<word32*>(output))
: : "cc"
);
#elif defined(ALL_RDSEED_INTRIN_AVAILABLE) #elif defined(ALL_RDSEED_INTRIN_AVAILABLE)
while(!_rdseed32_step(reinterpret_cast<word32*>(output))) {} while(!_rdseed32_step(reinterpret_cast<word32*>(output))) {}
#else #else
@ -335,6 +359,14 @@ inline void RDSEED64(void* output)
: "=a" (*reinterpret_cast<word64*>(output)) : "=a" (*reinterpret_cast<word64*>(output))
: : "cc" : : "cc"
); );
#elif defined(CRYPTOPP_MSC_VERSION) && defined(CRYPTOPP_LLVM_CLANG_VERSION)
__asm__ __volatile__
(
".byte 0x48, 0x0f, 0xc7, 0xf8;\n"
".byte 0x73, 0xfa;\n"
: "=a" (*reinterpret_cast<word64*>(output))
: : "cc"
);
#elif defined(ALL_RDSEED_INTRIN_AVAILABLE) #elif defined(ALL_RDSEED_INTRIN_AVAILABLE)
while(!_rdseed64_step(reinterpret_cast<unsigned long long*>(output))) {} while(!_rdseed64_step(reinterpret_cast<unsigned long long*>(output))) {}
#else #else