diff --git a/config.h b/config.h index cfa3a9b6..f2d0651d 100644 --- a/config.h +++ b/config.h @@ -209,12 +209,6 @@ typedef unsigned int word32; typedef word64 lword; 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__ #define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #endif @@ -327,7 +321,7 @@ NAMESPACE_END #define CRYPTOPP_FASTCALL #endif -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #define CRYPTOPP_NO_VTABLE __declspec(novtable) #else #define CRYPTOPP_NO_VTABLE diff --git a/integer.cpp b/integer.cpp index 700e8902..ceb06ed5 100644 --- a/integer.cpp +++ b/integer.cpp @@ -195,7 +195,7 @@ static word AtomicInverseModPower2(word A) #define HighWord(a) a##1 #ifdef _MSC_VER #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; #endif #elif defined(__DECCXX) diff --git a/rdrand.cpp b/rdrand.cpp index 75889f1d..ed6b56bc 100644 --- a/rdrand.cpp +++ b/rdrand.cpp @@ -152,6 +152,14 @@ inline void RDRAND32(void* output) : "=a" (*reinterpret_cast(output)) : : "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(output)) + : : "cc" + ); #elif defined(ALL_RDRAND_INTRIN_AVAILABLE) while(!_rdrand32_step(reinterpret_cast(output))) {} #else @@ -191,6 +199,14 @@ inline void RDRAND64(void* output) : "=a" (*reinterpret_cast(output)) : : "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(output)) + : : "cc" + ); #elif defined(ALL_RDRAND_INTRIN_AVAILABLE) while(!_rdrand64_step(reinterpret_cast(output))) {} #else @@ -296,6 +312,14 @@ inline void RDSEED32(void* output) : "=a" (*reinterpret_cast(output)) : : "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(output)) + : : "cc" + ); #elif defined(ALL_RDSEED_INTRIN_AVAILABLE) while(!_rdseed32_step(reinterpret_cast(output))) {} #else @@ -335,6 +359,14 @@ inline void RDSEED64(void* output) : "=a" (*reinterpret_cast(output)) : : "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(output)) + : : "cc" + ); #elif defined(ALL_RDSEED_INTRIN_AVAILABLE) while(!_rdseed64_step(reinterpret_cast(output))) {} #else