diff --git a/algparam.h b/algparam.h index f904c4f9..d4d5aa6d 100644 --- a/algparam.h +++ b/algparam.h @@ -393,7 +393,7 @@ public: } } -#if defined(DEBUG_NEW) && (_MSC_VER >= 1300) +#if defined(DEBUG_NEW) && (CRYPTOPP_MSC_VERSION >= 1300) # pragma push_macro("new") # undef new #endif @@ -404,7 +404,7 @@ public: CRYPTOPP_UNUSED(p); // silence warning } -#if defined(DEBUG_NEW) && (_MSC_VER >= 1300) +#if defined(DEBUG_NEW) && (CRYPTOPP_MSC_VERSION >= 1300) # pragma pop_macro("new") #endif diff --git a/arm_simd.h b/arm_simd.h index 595c67bb..b746da70 100644 --- a/arm_simd.h +++ b/arm_simd.h @@ -29,7 +29,7 @@ /// \since Crypto++ 8.6 inline uint32_t CRC32B (uint32_t crc, uint8_t val) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) return __crc32b(crc, val); #else __asm__ ("crc32b %w0, %w0, %w1 \n\t" @@ -45,7 +45,7 @@ inline uint32_t CRC32B (uint32_t crc, uint8_t val) /// \since Crypto++ 8.6 inline uint32_t CRC32W (uint32_t crc, uint32_t val) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) return __crc32w(crc, val); #else __asm__ ("crc32w %w0, %w0, %w1 \n\t" @@ -61,7 +61,7 @@ inline uint32_t CRC32W (uint32_t crc, uint32_t val) /// \since Crypto++ 8.6 inline uint32_t CRC32Wx4 (uint32_t crc, const uint32_t vals[4]) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) return __crc32w(__crc32w(__crc32w(__crc32w( crc, vals[0]), vals[1]), vals[2]), vals[3]); #else @@ -85,7 +85,7 @@ inline uint32_t CRC32Wx4 (uint32_t crc, const uint32_t vals[4]) /// \since Crypto++ 8.6 inline uint32_t CRC32CB (uint32_t crc, uint8_t val) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) return __crc32cb(crc, val); #else __asm__ ("crc32cb %w0, %w0, %w1 \n\t" @@ -101,7 +101,7 @@ inline uint32_t CRC32CB (uint32_t crc, uint8_t val) /// \since Crypto++ 8.6 inline uint32_t CRC32CW (uint32_t crc, uint32_t val) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) return __crc32cw(crc, val); #else __asm__ ("crc32cw %w0, %w0, %w1 \n\t" @@ -117,7 +117,7 @@ inline uint32_t CRC32CW (uint32_t crc, uint32_t val) /// \since Crypto++ 8.6 inline uint32_t CRC32CWx4 (uint32_t crc, const uint32_t vals[4]) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) return __crc32cw(__crc32cw(__crc32cw(__crc32cw( crc, vals[0]), vals[1]), vals[2]), vals[3]); #else @@ -151,7 +151,7 @@ inline uint32_t CRC32CWx4 (uint32_t crc, const uint32_t vals[4]) /// \since Crypto++ 8.0 inline uint64x2_t PMULL_00(const uint64x2_t a, const uint64x2_t b) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) const __n64 x = { vgetq_lane_u64(a, 0) }; const __n64 y = { vgetq_lane_u64(b, 0) }; return vmull_p64(x, y); @@ -181,7 +181,7 @@ inline uint64x2_t PMULL_00(const uint64x2_t a, const uint64x2_t b) /// \since Crypto++ 8.0 inline uint64x2_t PMULL_01(const uint64x2_t a, const uint64x2_t b) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) const __n64 x = { vgetq_lane_u64(a, 0) }; const __n64 y = { vgetq_lane_u64(b, 1) }; return vmull_p64(x, y); @@ -211,7 +211,7 @@ inline uint64x2_t PMULL_01(const uint64x2_t a, const uint64x2_t b) /// \since Crypto++ 8.0 inline uint64x2_t PMULL_10(const uint64x2_t a, const uint64x2_t b) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) const __n64 x = { vgetq_lane_u64(a, 1) }; const __n64 y = { vgetq_lane_u64(b, 0) }; return vmull_p64(x, y); @@ -241,7 +241,7 @@ inline uint64x2_t PMULL_10(const uint64x2_t a, const uint64x2_t b) /// \since Crypto++ 8.0 inline uint64x2_t PMULL_11(const uint64x2_t a, const uint64x2_t b) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) const __n64 x = { vgetq_lane_u64(a, 1) }; const __n64 y = { vgetq_lane_u64(b, 1) }; return vmull_p64(x, y); @@ -266,7 +266,7 @@ inline uint64x2_t PMULL_11(const uint64x2_t a, const uint64x2_t b) /// \since Crypto++ 8.0 inline uint64x2_t PMULL(const uint64x2_t a, const uint64x2_t b) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) const __n64 x = { vgetq_lane_u64(a, 0) }; const __n64 y = { vgetq_lane_u64(b, 0) }; return vmull_p64(x, y); @@ -291,7 +291,7 @@ inline uint64x2_t PMULL(const uint64x2_t a, const uint64x2_t b) /// \since Crypto++ 8.0 inline uint64x2_t PMULL_HIGH(const uint64x2_t a, const uint64x2_t b) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) const __n64 x = { vgetq_lane_u64(a, 1) }; const __n64 y = { vgetq_lane_u64(b, 1) }; return vmull_p64(x, y); @@ -320,7 +320,7 @@ template inline uint64x2_t VEXT_U8(uint64x2_t a, uint64x2_t b) { // https://github.com/weidai11/cryptopp/issues/366 -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) return vreinterpretq_u64_u8(vextq_u8( vreinterpretq_u8_u64(a), vreinterpretq_u8_u64(b), C)); #else @@ -349,7 +349,7 @@ inline uint64x2_t VEXT_U8(uint64x2_t a, uint64x2_t b) /// \since Crypto++ 8.6 inline uint64x2_t VEOR3(uint64x2_t a, uint64x2_t b, uint64x2_t c) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) return veor3q_u64(a, b, c); #else uint64x2_t r; @@ -370,7 +370,7 @@ inline uint64x2_t VEOR3(uint64x2_t a, uint64x2_t b, uint64x2_t c) /// \since Crypto++ 8.6 inline uint64x2_t VXAR(uint64x2_t a, uint64x2_t b, const int c) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) return vxarq_u64(a, b, c); #else uint64x2_t r; @@ -392,7 +392,7 @@ inline uint64x2_t VXAR(uint64x2_t a, uint64x2_t b, const int c) template inline uint64x2_t VXAR(uint64x2_t a, uint64x2_t b) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) return vxarq_u64(a, b, C); #else uint64x2_t r; @@ -412,7 +412,7 @@ inline uint64x2_t VXAR(uint64x2_t a, uint64x2_t b) /// \since Crypto++ 8.6 inline uint64x2_t VRAX1(uint64x2_t a, uint64x2_t b) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) return vrax1q_u64(a, b); #else uint64x2_t r; diff --git a/chacha_avx.cpp b/chacha_avx.cpp index bcb0f21f..f6b0226a 100644 --- a/chacha_avx.cpp +++ b/chacha_avx.cpp @@ -41,7 +41,7 @@ extern const char CHACHA_AVX_FNAME[] = __FILE__; // https://github.com/weidai11/cryptopp/issues/735. The // 649 issue affects AES but it is the same here. The 735 // issue is ChaCha AVX2 cut-in where it surfaced again. -#if (_MSC_VER >= 1910) && (_MSC_VER <= 1916) +#if (CRYPTOPP_MSC_VERSION >= 1910) && (CRYPTOPP_MSC_VERSION <= 1916) # ifndef CRYPTOPP_DEBUG # pragma optimize("", off) # pragma optimize("ts", on) diff --git a/config_align.h b/config_align.h index 6a6e9e04..00312682 100644 --- a/config_align.h +++ b/config_align.h @@ -41,7 +41,7 @@ // How to allocate 16-byte aligned memory (for SSE2) // posix_memalign see https://forum.kde.org/viewtopic.php?p=66274 -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) #define CRYPTOPP_MM_MALLOC_AVAILABLE #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__) #define CRYPTOPP_MEMALIGN_AVAILABLE @@ -59,7 +59,7 @@ // CRYPTOPP_ALIGN_DATA may not be reliable on AIX. #if defined(CRYPTOPP_CXX11_ALIGNAS) #define CRYPTOPP_ALIGN_DATA(x) alignas(x) -#elif defined(_MSC_VER) +#elif defined(CRYPTOPP_MSC_VERSION) #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x)) #elif defined(__GNUC__) || defined(__clang__) || (__SUNPRO_CC >= 0x5100) #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x))) diff --git a/config_asm.h b/config_asm.h index 3f7f2306..a25579bc 100644 --- a/config_asm.h +++ b/config_asm.h @@ -100,12 +100,12 @@ #endif // 32-bit SunCC does not enable SSE2 by default. -#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(_MSC_VER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__) || (__SUNPRO_CC >= 0x5100)) +#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSC_VERSION) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__) || (__SUNPRO_CC >= 0x5100)) #define CRYPTOPP_SSE2_INTRIN_AVAILABLE 1 #endif #if !defined(CRYPTOPP_DISABLE_SSSE3) -# if defined(__SSSE3__) || (_MSC_VER >= 1500) || \ +# if defined(__SSSE3__) || (CRYPTOPP_MSC_VERSION >= 1500) || \ (CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1000) || (__SUNPRO_CC >= 0x5110) || \ (CRYPTOPP_LLVM_CLANG_VERSION >= 20300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000) #define CRYPTOPP_SSSE3_AVAILABLE 1 @@ -312,7 +312,7 @@ #endif // Buggy Microsoft compiler, https://github.com/weidai11/cryptopp/issues/1096 -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) # undef CRYPTOPP_ARM_SHA1_AVAILABLE # undef CRYPTOPP_ARM_SHA2_AVAILABLE #endif diff --git a/config_cpu.h b/config_cpu.h index 3eeaf234..0dcae40f 100644 --- a/config_cpu.h +++ b/config_cpu.h @@ -202,7 +202,7 @@ /// \details CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY is defined when neither /// _MSC_VER nor __BORLANDC__ are defined. #define CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY ... -#elif defined(_MSC_VER) || defined(__BORLANDC__) +#elif defined(CRYPTOPP_MSC_VERSION) || defined(__BORLANDC__) #define CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY 1 #else #define CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY 1 diff --git a/config_cxx.h b/config_cxx.h index 16b41947..bc8435aa 100644 --- a/config_cxx.h +++ b/config_cxx.h @@ -39,7 +39,7 @@ // You may need to force include a C++ header on Android when using STLPort // to ensure _STLPORT_VERSION is defined -#if (defined(_MSC_VER) && _MSC_VER <= 1300) || \ +#if (defined(CRYPTOPP_MSC_VERSION) && CRYPTOPP_MSC_VERSION <= 1300) || \ defined(__MWERKS__) || \ (defined(_STLPORT_VERSION) && ((_STLPORT_VERSION < 0x450) || defined(_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT)) || \ (__cplusplus >= 202002L)) @@ -58,7 +58,7 @@ #endif // C++11 macro version, https://stackoverflow.com/q/7223991/608639 -#if ((_MSC_VER >= 1600) || (__cplusplus >= 201103L)) && !defined(_STLPORT_VERSION) +#if ((CRYPTOPP_MSC_VERSION >= 1600) || (__cplusplus >= 201103L)) && !defined(_STLPORT_VERSION) # define CRYPTOPP_CXX11 1 #endif @@ -76,14 +76,14 @@ // C++14 macro version, https://stackoverflow.com/q/26089319/608639 #if defined(CRYPTOPP_CXX11) && !defined(CRYPTOPP_NO_CXX14) -# if ((_MSC_VER >= 1900) || (__cplusplus >= 201402L)) && !defined(_STLPORT_VERSION) +# if ((CRYPTOPP_MSC_VERSION >= 1900) || (__cplusplus >= 201402L)) && !defined(_STLPORT_VERSION) # define CRYPTOPP_CXX14 1 # endif #endif // C++17 macro version, https://stackoverflow.com/q/38456127/608639 #if defined(CRYPTOPP_CXX14) && !defined(CRYPTOPP_NO_CXX17) -# if ((_MSC_VER >= 1900) || (__cplusplus >= 201703L)) && !defined(_STLPORT_VERSION) +# if ((CRYPTOPP_MSC_VERSION >= 1900) || (__cplusplus >= 201703L)) && !defined(_STLPORT_VERSION) # define CRYPTOPP_CXX17 1 # endif #endif diff --git a/config_int.h b/config_int.h index a10fc0b4..130c2170 100644 --- a/config_int.h +++ b/config_int.h @@ -145,7 +145,7 @@ typedef signed int sword32; /// where the cpu is slow even with a 64-bit cpu. #define CRYPTOPP_BOOL_SLOW_WORD64 ... -#elif defined(_MSC_VER) || defined(__BORLANDC__) +#elif defined(CRYPTOPP_MSC_VERSION) || defined(__BORLANDC__) typedef signed __int64 sword64; typedef unsigned __int64 word64; #define SW64LIT(x) x##i64 @@ -215,7 +215,7 @@ CRYPTOPP_CONST_OR_CONSTEXPR lword LWORD_MAX = W64LIT(0xffffffffffffffff); #else // define hword, word, and dword. these are used for multiprecision integer arithmetic // Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx - #if (defined(_MSC_VER) && (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1000) && (defined(_M_X64) || defined(_M_IA64))) || (defined(__DECCXX) && defined(__alpha__)) || (defined(__INTEL_COMPILER) && defined(__x86_64__)) || (defined(__SUNPRO_CC) && defined(__x86_64__)) + #if (defined(CRYPTOPP_MSC_VERSION) && (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1000) && (defined(_M_X64) || defined(_M_IA64))) || (defined(__DECCXX) && defined(__alpha__)) || (defined(__INTEL_COMPILER) && defined(__x86_64__)) || (defined(__SUNPRO_CC) && defined(__x86_64__)) typedef word32 hword; typedef word64 word; #else diff --git a/config_misc.h b/config_misc.h index cf398b16..5809c21c 100644 --- a/config_misc.h +++ b/config_misc.h @@ -130,7 +130,7 @@ #endif // how to disable inlining -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) # define CRYPTOPP_NOINLINE_DOTDOTDOT # define CRYPTOPP_NOINLINE __declspec(noinline) #elif defined(__xlc__) || defined(__xlC__) || defined(__ibmxl__) @@ -169,14 +169,14 @@ #endif // Warnings -#ifdef _MSC_VER +#ifdef CRYPTOPP_MSC_VERSION // 4127: conditional expression is constant // 4512: assignment operator not generated // 4661: no suitable definition provided for explicit template instantiation request // 4910: '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation # pragma warning(disable: 4127 4512 4661 4910) - // _MSC_VER 1920 is VS2019 -# if _MSC_VER >= 1920 + // CRYPTOPP_MSC_VERSION 1920 is VS2019 +# if CRYPTOPP_MSC_VERSION >= 1920 // 5054: operator '|': deprecated between enumerations of different types # pragma warning(disable: 5054) # endif diff --git a/config_os.h b/config_os.h index 107e4452..ed8e52c6 100644 --- a/config_os.h +++ b/config_os.h @@ -29,8 +29,7 @@ // https://www.cryptopp.com/wiki/Release_Process#Self_Tests // The problems with Clang pretending to be other compilers is // discussed at http://github.com/weidai11/cryptopp/issues/147. -#if (defined(_MSC_VER) && defined(__clang__) && \ - !(defined( __clang_analyzer__)) && !defined(__INTEL_LLVM_COMPILER)) +#if (defined(_MSC_VER) && defined(__clang__)) # error: "Unsupported configuration" #endif @@ -50,14 +49,14 @@ #endif // Microsoft compilers -#if defined(_MSC_VER) || defined(__fastcall) +#if defined(CRYPTOPP_MSC_VERSION) || defined(__fastcall) #define CRYPTOPP_FASTCALL __fastcall #else #define CRYPTOPP_FASTCALL #endif // Microsoft compilers -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) #define CRYPTOPP_NO_VTABLE __declspec(novtable) #else #define CRYPTOPP_NO_VTABLE diff --git a/config_ver.h b/config_ver.h index e233e9da..87658441 100644 --- a/config_ver.h +++ b/config_ver.h @@ -66,23 +66,23 @@ // code paths that it cannot compile. Unset Clang to save the grief. // Also see http://github.com/weidai11/cryptopp/issues/147. -#if defined(__GNUC__) +#if defined(__GNUC__) && !defined(__clang__) # undef CRYPTOPP_APPLE_CLANG_VERSION # undef CRYPTOPP_LLVM_CLANG_VERSION # define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #endif -#if defined(__xlc__) || defined(__xlC__) +#if defined(__xlc__) || defined(__xlC__) && !defined(__clang__) # undef CRYPTOPP_LLVM_CLANG_VERSION # define CRYPTOPP_XLC_VERSION ((__xlC__ / 256) * 10000 + (__xlC__ % 256) * 100) #endif -#ifdef __INTEL_COMPILER +#if defined(__INTEL_COMPILER) && !defined(__clang__) # undef CRYPTOPP_LLVM_CLANG_VERSION # define CRYPTOPP_INTEL_VERSION (__INTEL_COMPILER) #endif -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) # undef CRYPTOPP_LLVM_CLANG_VERSION # define CRYPTOPP_MSC_VERSION (_MSC_VER) #endif diff --git a/cpu.cpp b/cpu.cpp index eafac604..0542855d 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -16,7 +16,7 @@ // For _xgetbv on Microsoft 32-bit and 64-bit Intel platforms // https://github.com/weidai11/cryptopp/issues/972 -#if _MSC_VER >= 1600 && (defined(_M_IX86) || defined(_M_X64)) +#if (CRYPTOPP_MSC_VERSION >= 1600) && (defined(_M_IX86) || defined(_M_X64)) # include #endif @@ -80,7 +80,7 @@ unsigned long int getauxval(unsigned long int) { return 0; } // Visual Studio 2008 and below are missing _xgetbv and _cpuidex. // The 32-bit versions use inline ASM below. The 64-bit versions are in x64dll.asm. -#if defined(_MSC_VER) && defined(_M_X64) +#if defined(CRYPTOPP_MSC_VERSION) && defined(_M_X64) extern "C" unsigned long long __fastcall XGETBV64(unsigned int); extern "C" unsigned long long __fastcall CPUID64(unsigned int, unsigned int, unsigned int*); #endif @@ -389,17 +389,17 @@ word64 XGetBV(word32 num) { // Visual Studio 2010 SP1 and above, 32 and 64-bit // https://github.com/weidai11/cryptopp/issues/972 -#if defined(_MSC_VER) && (_MSC_FULL_VER >= 160040219) +#if defined(CRYPTOPP_MSC_VERSION) && (_MSC_FULL_VER >= 160040219) return _xgetbv(num); // Visual Studio 2008 and below, 64-bit -#elif defined(_MSC_VER) && defined(_M_X64) +#elif defined(CRYPTOPP_MSC_VERSION) && defined(_M_X64) return XGETBV64(num); // Visual Studio 2008 and below, 32-bit -#elif defined(_MSC_VER) && defined(_M_IX86) +#elif defined(CRYPTOPP_MSC_VERSION) && defined(_M_IX86) word32 a=0, d=0; __asm { @@ -450,19 +450,19 @@ word64 XGetBV(word32 num) bool CpuId(word32 func, word32 subfunc, word32 output[4]) { // Visual Studio 2010 and above, 32 and 64-bit -#if defined(_MSC_VER) && (_MSC_VER >= 1600) +#if defined(CRYPTOPP_MSC_VERSION) && ((CRYPTOPP_MSC_VERSION >= 1600)) __cpuidex((int *)output, func, subfunc); return true; // Visual Studio 2008 and below, 64-bit -#elif defined(_MSC_VER) && defined(_M_X64) +#elif defined(CRYPTOPP_MSC_VERSION) && defined(_M_X64) CPUID64(func, subfunc, output); return true; // Visual Studio 2008 and below, 32-bit -#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__BORLANDC__) +#elif (defined(CRYPTOPP_MSC_VERSION) && defined(_M_IX86)) || defined(__BORLANDC__) __try { diff --git a/cpu.h b/cpu.h index 23660b16..f59267d8 100644 --- a/cpu.h +++ b/cpu.h @@ -46,7 +46,7 @@ #define INTEL_NOPREFIX ".intel_syntax;" #define ATT_PREFIX ".att_syntax;" #define ATT_NOPREFIX ".att_syntax;" -#elif defined(__GNUC__) +#elif defined(CRYPTOPP_GCC_VERSION) #define NEW_LINE #define INTEL_PREFIX ".intel_syntax prefix;" #define INTEL_NOPREFIX ".intel_syntax noprefix;" @@ -909,7 +909,7 @@ inline int GetCacheLineSize() #define ASJ(x, y, z) x label##y*newline* #define ASC(x, y) x label##y*newline* #define AS_HEX(y) 0##y##h -#elif defined(_MSC_VER) || defined(__BORLANDC__) +#elif defined(CRYPTOPP_MSC_VERSION) || defined(__BORLANDC__) #define AS1(x) __asm {x} #define AS2(x, y) __asm {x, y} #define AS3(x, y, z) __asm {x, y, z} diff --git a/datatest.cpp b/datatest.cpp index caadf5a4..c020eaa4 100644 --- a/datatest.cpp +++ b/datatest.cpp @@ -32,7 +32,7 @@ # pragma warning(disable: 4505 4355) #endif -#ifdef _MSC_VER +#ifdef CRYPTOPP_MSC_VERSION # define STRTOUL64 _strtoui64 #else # define STRTOUL64 strtoull diff --git a/des.cpp b/des.cpp index 2e9fb507..6ec5ada1 100644 --- a/des.cpp +++ b/des.cpp @@ -283,7 +283,7 @@ namespace { /* Set key (initialize key schedule array) */ void RawDES::RawSetKey(CipherDir dir, const byte *key) { -#if (_MSC_VER >= 1600) || (__cplusplus >= 201103L) +#if (CRYPTOPP_MSC_VERSION >= 1600) || (__cplusplus >= 201103L) # define REGISTER /* Define to nothing for C++11 and above */ #else # define REGISTER register diff --git a/donna.h b/donna.h index 2f336538..6153bd45 100644 --- a/donna.h +++ b/donna.h @@ -26,6 +26,7 @@ #ifndef CRYPTOPP_DONNA_H #define CRYPTOPP_DONNA_H +#include "config.h" #include "cryptlib.h" #include "stdcpp.h" @@ -140,7 +141,7 @@ ed25519_sign_open(std::istream& stream, const byte publicKey[32], const byte sig // error "The operand ___LCM cannot be assigned to". #if defined(CRYPTOPP_WORD128_AVAILABLE) || \ - (defined(_MSC_VER) && defined(_M_X64)) + (defined(CRYPTOPP_MSC_VERSION) && defined(_M_X64)) # define CRYPTOPP_CURVE25519_64BIT 1 #else # define CRYPTOPP_CURVE25519_32BIT 1 @@ -162,7 +163,7 @@ ed25519_sign_open(std::istream& stream, const byte publicKey[32], const byte sig // * x64, no SSE2, 0.081 // * x64, SSE2, 0.071 -#if (CRYPTOPP_SSE2_INTRIN_AVAILABLE) && defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_SSE2_INTRIN_AVAILABLE) # define CRYPTOPP_CURVE25519_SSE2 1 #endif diff --git a/donna_64.h b/donna_64.h index d98ad640..75296e1d 100644 --- a/donna_64.h +++ b/donna_64.h @@ -14,7 +14,7 @@ #include "config.h" -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) # include # pragma intrinsic(_umul128) # pragma intrinsic(__shiftright128) @@ -52,7 +52,7 @@ using CryptoPP::word128; # define shr128(out,in,shift) out = (word64)(in >> (shift)); # define shl128(out,in,shift) out = (word64)((in << shift) >> 64); -#elif defined(_MSC_VER) +#elif defined(CRYPTOPP_MSC_VERSION) struct word128 { word64 lo, hi; }; # define mul64x64_128(out,a,b) out.lo = _umul128(a,b,&out.hi); # define shr128_pair(out,hi,lo,shift) out = __shiftright128(lo, hi, shift); diff --git a/files.cpp b/files.cpp index 16b66480..a24289f7 100644 --- a/files.cpp +++ b/files.cpp @@ -57,7 +57,7 @@ void FileStore::StoreInitialize(const NameValuePairs ¶meters) m_file.release(); const char *fileName = NULLPTR; -#if defined(CRYPTOPP_UNIX_AVAILABLE) || _MSC_VER >= 1400 +#if defined(CRYPTOPP_UNIX_AVAILABLE) || CRYPTOPP_MSC_VERSION >= 1400 const wchar_t *fileNameWide = NULLPTR; if (!parameters.GetValue(Name::InputFileNameWide(), fileNameWide)) #endif @@ -74,7 +74,7 @@ void FileStore::StoreInitialize(const NameValuePairs ¶meters) if (fileNameWide) fileName = (narrowed = StringNarrow(fileNameWide)).c_str(); #endif -#if _MSC_VER >= 1400 +#if CRYPTOPP_MSC_VERSION >= 1400 if (fileNameWide) { m_file->open(fileNameWide, std::ios::in | binary); @@ -224,7 +224,7 @@ void FileSink::IsolatedInitialize(const NameValuePairs ¶meters) m_file.release(); const char *fileName = NULLPTR; -#if defined(CRYPTOPP_UNIX_AVAILABLE) || _MSC_VER >= 1400 +#if defined(CRYPTOPP_UNIX_AVAILABLE) || CRYPTOPP_MSC_VERSION >= 1400 const wchar_t *fileNameWide = NULLPTR; if (!parameters.GetValue(Name::OutputFileNameWide(), fileNameWide)) #endif diff --git a/files.h b/files.h index 8ff5dc85..0e8f8a5d 100644 --- a/files.h +++ b/files.h @@ -46,7 +46,7 @@ public: FileStore(const char *filename) : m_stream(NULLPTR), m_space(NULLPTR), m_len(0), m_waiting(0) {StoreInitialize(MakeParameters(Name::InputFileName(), filename ? filename : ""));} -#if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) || _MSC_VER >= 1400 +#if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) || (CRYPTOPP_MSC_VERSION >= 1400) /// \brief Construct a FileStore /// \param filename the Unicode name of the file to open /// \details On non-Windows OS, this function assumes that setlocale() has been called. @@ -109,7 +109,7 @@ public: FileSource(const char *filename, bool pumpAll, BufferedTransformation *attachment = NULLPTR, bool binary=true) : SourceTemplate(attachment) {SourceInitialize(pumpAll, MakeParameters(Name::InputFileName(), filename)(Name::InputBinaryMode(), binary));} -#if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) || _MSC_VER >= 1400 +#if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) || (CRYPTOPP_MSC_VERSION >= 1400) /// \brief Construct a FileSource /// \param filename the Unicode name of the file to open /// \param pumpAll flag indicating if source data should be pumped to its attached transformation @@ -155,7 +155,7 @@ public: FileSink(const char *filename, bool binary=true) {IsolatedInitialize(MakeParameters(Name::OutputFileName(), filename)(Name::OutputBinaryMode(), binary));} -#if defined(CRYPTOPP_UNIX_AVAILABLE) || _MSC_VER >= 1400 +#if defined(CRYPTOPP_UNIX_AVAILABLE) || (CRYPTOPP_MSC_VERSION >= 1400) /// \brief Construct a FileSink /// \param filename the Unicode name of the file to open /// \details On non-Windows OS, this function assumes that setlocale() has been called. diff --git a/fipstest.cpp b/fipstest.cpp index 0155112c..a5b5aa0a 100644 --- a/fipstest.cpp +++ b/fipstest.cpp @@ -29,13 +29,13 @@ #include -#if defined(_MSC_VER) && _MSC_VER >= 1400 +#if defined(CRYPTOPP_MSC_VERSION) && CRYPTOPP_MSC_VERSION >= 1400 # ifdef _M_IX86 # define _CRT_DEBUGGER_HOOK _crt_debugger_hook # else # define _CRT_DEBUGGER_HOOK __crt_debugger_hook # endif -# if _MSC_VER < 1900 +# if CRYPTOPP_MSC_VERSION < 1900 extern "C" {_CRTIMP void __cdecl _CRT_DEBUGGER_HOOK(int);} # else extern "C" {void __cdecl _CRT_DEBUGGER_HOOK(int); } @@ -299,7 +299,7 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule char moduleFilenameBuf[FIPS_MODULE_MAX_PATH] = ""; if (moduleFilename == NULLPTR) { -#if (_MSC_VER >= 1400 && !defined(_STLPORT_VERSION)) // ifstream doesn't support wide filename on other compilers +#if (CRYPTOPP_MSC_VERSION >= 1400 && !defined(_STLPORT_VERSION)) // ifstream doesn't support wide filename on other compilers wchar_t wideModuleFilename[FIPS_MODULE_MAX_PATH]; if (GetModuleFileNameW(s_hModule, wideModuleFilename, FIPS_MODULE_MAX_PATH) > 0) { @@ -403,7 +403,7 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule // Visual Studio 2019 is MSC_VER == 1920 // https://dev.to/yumetodo/list-of-mscver-and-mscfullver-8nds -#if (_MSC_VER >= 1400 && _MSC_VER < 1920) && (defined(_M_IX86) || defined(_M_X64)) +#if (CRYPTOPP_MSC_VERSION >= 1400 && CRYPTOPP_MSC_VERSION < 1920) && (defined(_M_IX86) || defined(_M_X64)) // first byte of _CRT_DEBUGGER_HOOK gets modified in memory by the debugger invisibly, so read it from file if (IsDebuggerPresent()) { diff --git a/gcm.cpp b/gcm.cpp index 5433b35b..6a56f48d 100644 --- a/gcm.cpp +++ b/gcm.cpp @@ -13,7 +13,7 @@ #ifndef CRYPTOPP_GENERATE_X64_MASM // Visual Studio .Net 2003 compiler crash -#if defined(_MSC_VER) && (_MSC_VER < 1400) +#if defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION < 1400) # pragma optimize("", off) #endif @@ -35,7 +35,7 @@ NAMESPACE_BEGIN(CryptoPP) #if defined(CRYPTOPP_DISABLE_MIXED_ASM) // 'movd eax, xmm0' only. REG_WORD() macro not used. Clang path. # define USE_MOVD_REG32 1 -#elif defined(__GNUC__) || defined(_MSC_VER) +#elif defined(__GNUC__) || defined(CRYPTOPP_MSC_VERSION) // 'movd eax, xmm0' or 'movd rax, xmm0'. REG_WORD() macro supplies REG32 or REG64. # define USE_MOVD_REG32_OR_REG64 1 #else @@ -146,7 +146,7 @@ void GCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const else tableSize = (GetTablesOption() == GCM_64K_Tables) ? 64*1024 : 2*1024; - //#if defined(_MSC_VER) && (_MSC_VER < 1400) + //#if defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION < 1400) // VC 2003 workaround: compiler generates bad code for 64K tables //tableSize = 2*1024; //#endif diff --git a/ida.cpp b/ida.cpp index 30d7381b..597d7598 100644 --- a/ida.cpp +++ b/ida.cpp @@ -11,7 +11,7 @@ NAMESPACE_BEGIN(CryptoPP) -#if (defined(_MSC_VER) && (_MSC_VER < 1400)) && !defined(__MWERKS__) +#if (defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION < 1400)) && !defined(__MWERKS__) // VC60 and VC7 workaround: built-in reverse_iterator has two template parameters, Dinkumware only has one typedef std::reverse_bidirectional_iterator RevIt; #elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) diff --git a/integer.cpp b/integer.cpp index 5d9043f0..bf95ac79 100644 --- a/integer.cpp +++ b/integer.cpp @@ -75,7 +75,7 @@ #include -#if (_MSC_VER >= 1400) && !defined(_M_ARM) +#if (CRYPTOPP_MSC_VERSION >= 1400) && !defined(_M_ARM) #include #endif @@ -207,7 +207,7 @@ static word AtomicInverseModPower2(word A) #define Add2WordsBy1(a, b, c) a##0 = b##0 + c; a##1 = b##1 + (a##0 < c); #define LowWord(a) a##0 #define HighWord(a) a##1 - #ifdef _MSC_VER + #ifdef CRYPTOPP_MSC_VERSION #define MultiplyWordsLoHi(p0, p1, a, b) p0 = _umul128(a, b, &p1); #ifndef __INTEL_COMPILER #define Double3Words(c, d) d##1 = __shiftleft128(d##0, d##1, 1); d##0 = __shiftleft128(c, d##0, 1); c *= 2; @@ -249,7 +249,7 @@ static word AtomicInverseModPower2(word A) #define GetBorrow(u) u##1 #else #define Declare2Words(x) dword x; - #if _MSC_VER >= 1400 && !defined(__INTEL_COMPILER) && (defined(_M_IX86) || defined(_M_X64) || defined(_M_IA64)) + #if CRYPTOPP_MSC_VERSION >= 1400 && !defined(__INTEL_COMPILER) && (defined(_M_IX86) || defined(_M_X64) || defined(_M_IA64)) #define MultiplyWords(p, a, b) p = __emulu(a, b); #else #define MultiplyWords(p, a, b) p = (dword)a*b; @@ -3056,7 +3056,7 @@ Integer::Integer(const byte *encodedInteger, size_t byteCount, Signedness s, Byt else { SecByteBlock block(byteCount); -#if (_MSC_VER >= 1500) +#if (CRYPTOPP_MSC_VERSION >= 1500) std::reverse_copy(encodedInteger, encodedInteger+byteCount, stdext::make_checked_array_iterator(block.begin(), block.size())); #else diff --git a/keccak_simd.cpp b/keccak_simd.cpp index b2cf62ee..16e1610d 100644 --- a/keccak_simd.cpp +++ b/keccak_simd.cpp @@ -67,7 +67,7 @@ rho56[2] = {W64LIT(0x0007060504030201), W64LIT(0x080F0E0D0C0B0A09)}; // Damn Visual Studio is missing too many intrinsics... inline __m128i SPLAT64(const word64 a) { -#if defined(_MSC_VER) +#if defined(CRYPTOPP_MSC_VERSION) double x; std::memcpy(&x, &a, 8); return _mm_castpd_si128(_mm_loaddup_pd(&x)); #else diff --git a/misc.h b/misc.h index 8d00b133..f6e5b076 100644 --- a/misc.h +++ b/misc.h @@ -32,8 +32,8 @@ # pragma GCC diagnostic ignored "-Wunused-function" #endif -#ifdef _MSC_VER - #if _MSC_VER >= 1400 +#ifdef CRYPTOPP_MSC_VERSION + #if CRYPTOPP_MSC_VERSION >= 1400 // VC2005 workaround: disable declarations that conflict with winnt.h #define _interlockedbittestandset CRYPTOPP_DISABLED_INTRINSIC_1 #define _interlockedbittestandreset CRYPTOPP_DISABLED_INTRINSIC_2 @@ -45,7 +45,7 @@ #undef _interlockedbittestandset64 #undef _interlockedbittestandreset64 #define CRYPTOPP_FAST_ROTATE(x) 1 - #elif _MSC_VER >= 1300 + #elif CRYPTOPP_MSC_VERSION >= 1300 #define CRYPTOPP_FAST_ROTATE(x) ((x) == 32 | (x) == 64) #else #define CRYPTOPP_FAST_ROTATE(x) ((x) == 32) @@ -194,7 +194,7 @@ struct CompileAssert #else // VS2005 added _countof #ifndef COUNTOF -# if defined(_MSC_VER) && (_MSC_VER >= 1400) +# if defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION >= 1400) # define COUNTOF(x) _countof(x) # else # define COUNTOF(x) (sizeof(x)/sizeof(x[0])) @@ -273,7 +273,7 @@ struct NewObject #else #if defined(CRYPTOPP_CXX11_ATOMIC) # define MEMORY_BARRIER() std::atomic_thread_fence(std::memory_order_acq_rel) -#elif (_MSC_VER >= 1400) +#elif (CRYPTOPP_MSC_VERSION >= 1400) # pragma intrinsic(_ReadWriteBarrier) # define MEMORY_BARRIER() _ReadWriteBarrier() #elif defined(__INTEL_COMPILER) @@ -1079,7 +1079,7 @@ inline unsigned int TrailingZeros(word32 v) return (unsigned int)_tzcnt_u32(v); #elif defined(__GNUC__) && (CRYPTOPP_GCC_VERSION >= 30400) return (unsigned int)__builtin_ctz(v); -#elif defined(_MSC_VER) && (_MSC_VER >= 1400) +#elif defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION >= 1400) unsigned long result; _BitScanForward(&result, v); return static_cast(result); @@ -1110,7 +1110,7 @@ inline unsigned int TrailingZeros(word64 v) return (unsigned int)_tzcnt_u64(v); #elif defined(__GNUC__) && (CRYPTOPP_GCC_VERSION >= 30400) return (unsigned int)__builtin_ctzll(v); -#elif defined(_MSC_VER) && (_MSC_VER >= 1400) && (defined(_M_X64) || defined(_M_IA64)) +#elif defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION >= 1400) && (defined(_M_X64) || defined(_M_IA64)) unsigned long result; _BitScanForward64(&result, v); return static_cast(result); @@ -1410,7 +1410,7 @@ inline unsigned int GetAlignmentOf() { #if defined(CRYPTOPP_CXX11_ALIGNOF) return alignof(T); -#elif (_MSC_VER >= 1300) +#elif (CRYPTOPP_MSC_VERSION >= 1300) return __alignof(T); #elif defined(__GNUC__) return __alignof__(T); @@ -1591,7 +1591,7 @@ void SecureWipeBuffer(T *buf, size_t n) } #if !defined(CRYPTOPP_DISABLE_ASM) && \ - (_MSC_VER >= 1400 || defined(__GNUC__)) && \ + (CRYPTOPP_MSC_VERSION >= 1400 || defined(__GNUC__)) && \ (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86) /// \brief Sets each byte of an array to 0 @@ -1660,7 +1660,7 @@ template<> inline void SecureWipeBuffer(word64 *buf, size_t n) #endif // CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 -#if !defined(CRYPTOPP_DISABLE_ASM) && (_MSC_VER >= 1700) && defined(_M_ARM) +#if !defined(CRYPTOPP_DISABLE_ASM) && (CRYPTOPP_MSC_VERSION >= 1700) && defined(_M_ARM) template<> inline void SecureWipeBuffer(byte *buf, size_t n) { char *p = reinterpret_cast(buf+n); @@ -1914,7 +1914,7 @@ template inline T rotrMod(T x, unsigned int y) return T((x>>(y&MASK))|(x<<(-y&MASK))); } -#ifdef _MSC_VER +#ifdef CRYPTOPP_MSC_VERSION /// \brief Performs a left rotate /// \tparam T the word type @@ -2006,9 +2006,9 @@ template<> inline word32 rotrMod(word32 x, unsigned int y) return _lrotr(x, static_cast(y)); } -#endif // #ifdef _MSC_VER +#endif // #ifdef CRYPTOPP_MSC_VERSION -#if (_MSC_VER >= 1400) || (defined(_MSC_VER) && !defined(_DLL)) +#if (CRYPTOPP_MSC_VERSION >= 1400) || (defined(CRYPTOPP_MSC_VERSION) && !defined(_DLL)) // Intel C++ Compiler 10.0 calls a function instead of using the rotate instruction when using these instructions /// \brief Performs a left rotate @@ -2101,9 +2101,9 @@ template<> inline word64 rotrMod(word64 x, unsigned int y) return y ? _rotr64(x, static_cast(y)) : x; } -#endif // #if _MSC_VER >= 1310 +#endif // #if CRYPTOPP_MSC_VERSION >= 1310 -#if _MSC_VER >= 1400 && !defined(__INTEL_COMPILER) +#if CRYPTOPP_MSC_VERSION >= 1400 && !defined(__INTEL_COMPILER) // Intel C++ Compiler 10.0 gives undefined externals with these template<> inline word16 rotlFixed(word16 x, unsigned int y) { @@ -2169,7 +2169,7 @@ template<> inline byte rotrMod(byte x, unsigned int y) return _rotr8(x, static_cast(y)); } -#endif // #if _MSC_VER >= 1400 +#endif // #if CRYPTOPP_MSC_VERSION >= 1400 #if (defined(__MWERKS__) && TARGET_CPU_PPC) @@ -2241,7 +2241,7 @@ inline word16 ByteReverse(word16 value) { #if defined(CRYPTOPP_BYTESWAP_AVAILABLE) return bswap_16(value); -#elif (_MSC_VER >= 1400) || (defined(_MSC_VER) && !defined(_DLL)) +#elif (CRYPTOPP_MSC_VERSION >= 1400) || (defined(CRYPTOPP_MSC_VERSION) && !defined(_DLL)) return _byteswap_ushort(value); #else return rotlFixed(value, 8U); @@ -2265,7 +2265,7 @@ inline word32 ByteReverse(word32 value) return value; #elif defined(__MWERKS__) && TARGET_CPU_PPC return (word32)__lwbrx(&value,0); -#elif (_MSC_VER >= 1400) || (defined(_MSC_VER) && !defined(_DLL)) +#elif (CRYPTOPP_MSC_VERSION >= 1400) || (defined(CRYPTOPP_MSC_VERSION) && !defined(_DLL)) return _byteswap_ulong(value); #elif CRYPTOPP_FAST_ROTATE(32) && !defined(__xlC__) // 5 instructions with rotate instruction, 9 without @@ -2288,7 +2288,7 @@ inline word64 ByteReverse(word64 value) #elif defined(__GNUC__) && defined(CRYPTOPP_X86_ASM_AVAILABLE) && defined(__x86_64__) __asm__ ("bswap %0" : "=r" (value) : "0" (value)); return value; -#elif (_MSC_VER >= 1400) || (defined(_MSC_VER) && !defined(_DLL)) +#elif (CRYPTOPP_MSC_VERSION >= 1400) || (defined(CRYPTOPP_MSC_VERSION) && !defined(_DLL)) return _byteswap_uint64(value); #elif CRYPTOPP_BOOL_SLOW_WORD64 return (word64(ByteReverse(word32(value))) << 32) | ByteReverse(word32(value>>32)); diff --git a/osrng.h b/osrng.h index f8b098b7..555a7a44 100644 --- a/osrng.h +++ b/osrng.h @@ -69,11 +69,11 @@ private: ProviderHandle m_hProvider; }; -#if defined(_MSC_VER) && defined(USE_MS_CRYPTOAPI) +#if defined(CRYPTOPP_MSC_VERSION) && defined(USE_MS_CRYPTOAPI) # pragma comment(lib, "advapi32.lib") #endif -#if defined(_MSC_VER) && defined(USE_MS_CNGAPI) +#if defined(CRYPTOPP_MSC_VERSION) && defined(USE_MS_CNGAPI) # pragma comment(lib, "bcrypt.lib") #endif diff --git a/padlkrng.cpp b/padlkrng.cpp index 2c776c53..f430f81c 100644 --- a/padlkrng.cpp +++ b/padlkrng.cpp @@ -64,7 +64,7 @@ void PadlockRNG::GenerateBlock(byte *output, size_t size) std::memcpy(output, m_buffer, rem); size -= rem; output += rem; } -#elif defined(CRYPTOPP_X86_ASM_AVAILABLE) && defined(_MSC_VER) && defined(_M_IX86) +#elif defined(CRYPTOPP_X86_ASM_AVAILABLE) && defined(CRYPTOPP_MSC_VERSION) && defined(_M_IX86) while (size) { word32 result, divisor = m_divisor; diff --git a/rijndael.cpp b/rijndael.cpp index 4f783e0f..3d6665e8 100644 --- a/rijndael.cpp +++ b/rijndael.cpp @@ -90,7 +90,7 @@ being unloaded from L1 cache, until that round is finished. // VS2017 and global optimization bug. Also see // https://github.com/weidai11/cryptopp/issues/649 -#if (_MSC_VER >= 1910) && (_MSC_VER <= 1916) +#if (CRYPTOPP_MSC_VERSION >= 1910) && (CRYPTOPP_MSC_VERSION <= 1916) # ifndef CRYPTOPP_DEBUG # pragma optimize("", off) # pragma optimize("ts", on) @@ -422,7 +422,7 @@ void Rijndael::Base::UncheckedSetKey(const byte *userKey, unsigned int keyLen, c m_key.New(4*(m_rounds+1)); word32 *rk = m_key; -#if (CRYPTOPP_AESNI_AVAILABLE && CRYPTOPP_SSE41_AVAILABLE && (!defined(_MSC_VER) || _MSC_VER >= 1600 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32)) +#if (CRYPTOPP_AESNI_AVAILABLE && CRYPTOPP_SSE41_AVAILABLE && (!defined(CRYPTOPP_MSC_VERSION) || CRYPTOPP_MSC_VERSION >= 1600 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32)) // MSVC 2008 SP1 generates bad code for _mm_extract_epi32() when compiling for X64 if (HasAESNI() && HasSSE41()) { @@ -1204,7 +1204,7 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks_SSE2(vo #endif AS_POP_IF86(bp) AS_POP_IF86(bx) -#if defined(_MSC_VER) && CRYPTOPP_BOOL_X86 +#if defined(CRYPTOPP_MSC_VERSION) && CRYPTOPP_BOOL_X86 AS_POP_IF86(di) AS_POP_IF86(si) AS1(ret) diff --git a/secblock.h b/secblock.h index 64d77690..5ab920f9 100644 --- a/secblock.h +++ b/secblock.h @@ -11,7 +11,7 @@ #include "misc.h" #include "stdcpp.h" -#if CRYPTOPP_MSC_VERSION +#if defined(CRYPTOPP_MSC_VERSION) # pragma warning(push) # pragma warning(disable: 4231 4275 4700) # if (CRYPTOPP_MSC_VERSION >= 1400) @@ -56,7 +56,7 @@ public: /// \since Crypto++ 6.0 #if defined(CRYPTOPP_DOXYGEN_PROCESSING) static const size_type ELEMS_MAX = ...; -#elif defined(_MSC_VER) && (_MSC_VER <= 1400) +#elif defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION <= 1400) static const size_type ELEMS_MAX = (~(size_type)0)/sizeof(T); #elif defined(CRYPTOPP_CXX11_STRONG_ENUM) enum : size_type {ELEMS_MAX = SIZE_MAX/sizeof(T)}; @@ -270,7 +270,7 @@ public: /// \details VS.NET STL enforces the policy of "All STL-compliant allocators /// have to provide a template class member called rebind". template struct rebind { typedef AllocatorWithCleanup other; }; -#if _MSC_VER >= 1500 +#if (CRYPTOPP_MSC_VERSION >= 1500) AllocatorWithCleanup() {} template AllocatorWithCleanup(const AllocatorWithCleanup &) {} #endif @@ -749,7 +749,7 @@ public: /// \since Crypto++ 6.0 #if defined(CRYPTOPP_DOXYGEN_PROCESSING) static const size_type ELEMS_MAX = ...; -#elif defined(_MSC_VER) && (_MSC_VER <= 1400) +#elif defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION <= 1400) static const size_type ELEMS_MAX = (~(size_type)0)/sizeof(T); #elif defined(CRYPTOPP_CXX11_STRONG_ENUM) enum : size_type {ELEMS_MAX = A::ELEMS_MAX}; @@ -1303,7 +1303,7 @@ __stl_alloc_rebind(CryptoPP::AllocatorWithCleanup<_Tp1>& __a, const _Tp2*) NAMESPACE_END -#if CRYPTOPP_MSC_VERSION +#if defined(CRYPTOPP_MSC_VERSION) # pragma warning(pop) #endif diff --git a/sha.cpp b/sha.cpp index f36c0486..057bb9ad 100644 --- a/sha.cpp +++ b/sha.cpp @@ -655,7 +655,7 @@ void CRYPTOPP_FASTCALL SHA256_HashMultipleBlocks_SSE2(word32 *state, const word3 AS2( mov edi, [len]) AS2( lea WORD_REG(si), [SHA256_K+48*4]) #endif - #if !defined(_MSC_VER) || (_MSC_VER < 1400) + #if !defined(CRYPTOPP_MSC_VERSION) || (CRYPTOPP_MSC_VERSION < 1400) AS_PUSH_IF86(bx) #endif @@ -807,7 +807,7 @@ INTEL_NOPREFIX AS_POP_IF86(sp) AS_POP_IF86(bp) - #if !defined(_MSC_VER) || (_MSC_VER < 1400) + #if !defined(CRYPTOPP_MSC_VERSION) || (CRYPTOPP_MSC_VERSION < 1400) AS_POP_IF86(bx) #endif diff --git a/simon128_simd.cpp b/simon128_simd.cpp index 4503dd90..8c0b2e31 100644 --- a/simon128_simd.cpp +++ b/simon128_simd.cpp @@ -63,7 +63,7 @@ using CryptoPP::vec_swap; // SunCC #if (CRYPTOPP_ARM_NEON_AVAILABLE) // Missing from Microsoft's ARM A-32 implementation -#if defined(_MSC_VER) && !defined(_M_ARM64) +#if defined(CRYPTOPP_MSC_VERSION) && !defined(_M_ARM64) inline uint64x2_t vld1q_dup_u64(const uint64_t* ptr) { return vmovq_n_u64(*ptr); diff --git a/sosemanuk.cpp b/sosemanuk.cpp index 82cf8c92..5a015995 100644 --- a/sosemanuk.cpp +++ b/sosemanuk.cpp @@ -406,7 +406,7 @@ void SosemanukPolicy::OperateKeystream(KeystreamOperation operation, byte *outpu AS2( mov SSE2_output, WORD_REG(di)) AS2( mov SSE2_input, WORD_REG(dx)) AS2( mov SSE2_state, WORD_REG(ax)) -#ifndef _MSC_VER +#ifndef CRYPTOPP_MSC_VERSION AS2( mov SSE2_pMulTables, WORD_REG(si)) #endif AS2( lea WORD_REG(cx), [4*WORD_REG(cx)+WORD_REG(cx)]) @@ -469,7 +469,7 @@ void SosemanukPolicy::OperateKeystream(KeystreamOperation operation, byte *outpu AS2( mov SSE2_wordsLeft2, WORD_REG(si)) AS2( lea WORD_REG(si), [WORD_REG(di)+WORD_REG(si)]) // use to end first inner loop AS2( mov SSE2_diEnd, WORD_REG(si)) -#ifdef _MSC_VER +#ifdef CRYPTOPP_MSC_VERSION AS2( lea WORD_REG(si), s_sosemanukMulTables) #else AS2( mov WORD_REG(si), SSE2_pMulTables) diff --git a/speck128_simd.cpp b/speck128_simd.cpp index 0130aca8..a30d79e5 100644 --- a/speck128_simd.cpp +++ b/speck128_simd.cpp @@ -62,7 +62,7 @@ using CryptoPP::word64; #if (CRYPTOPP_ARM_NEON_AVAILABLE) // Missing from Microsoft's ARM A-32 implementation -#if defined(_MSC_VER) && !defined(_M_ARM64) +#if defined(CRYPTOPP_MSC_VERSION) && !defined(_M_ARM64) inline uint64x2_t vld1q_dup_u64(const uint64_t* ptr) { return vmovq_n_u64(*ptr); diff --git a/stdcpp.h b/stdcpp.h index 8bda2904..2b593d34 100644 --- a/stdcpp.h +++ b/stdcpp.h @@ -6,7 +6,7 @@ #ifndef CRYPTOPP_STDCPP_H #define CRYPTOPP_STDCPP_H -#if _MSC_VER >= 1500 +#if (CRYPTOPP_MSC_VERSION >= 1500) #define _DO_NOT_DECLARE_INTERLOCKED_INTRINSICS_IN_MEMORY #include #endif @@ -26,7 +26,7 @@ #include // http://connect.microsoft.com/VisualStudio/feedback/details/1600701/type-info-does-not-compile-with-has-exceptions-0 -#if defined(_MSC_VER) && (_MSC_VER < 1900) && defined(_HAS_EXCEPTIONS) && (_HAS_EXCEPTIONS == 0) +#if defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION < 1900) && defined(_HAS_EXCEPTIONS) && (_HAS_EXCEPTIONS == 0) namespace std { using ::type_info; } @@ -43,7 +43,7 @@ namespace std { #endif // make_unchecked_array_iterator -#if _MSC_VER >= 1600 +#if (CRYPTOPP_MSC_VERSION >= 1600) #include #endif @@ -68,7 +68,7 @@ namespace std { // program that includes without making users // do something special. "Epic fail" comes to mind. // Also see https://github.com/weidai11/cryptopp/issues/781 -#ifndef _MSC_VER +#ifndef CRYPTOPP_MSC_VERSION # include #endif @@ -77,8 +77,8 @@ namespace std { # if (__SUNPRO_CC >= 0x5100) # include # endif -#elif defined(_MSC_VER) -# if (_MSC_VER >= 1700) +#elif defined(CRYPTOPP_MSC_VERSION) +# if (CRYPTOPP_MSC_VERSION >= 1700) # include # else # include diff --git a/test.cpp b/test.cpp index 9564b611..b435fdac 100644 --- a/test.cpp +++ b/test.cpp @@ -57,7 +57,7 @@ #define UNIX_PATH_FAMILY 1 #endif -#if (_MSC_VER >= 1000) +#if (CRYPTOPP_MSC_VERSION >= 1000) #include // for the debug heap #endif @@ -510,7 +510,7 @@ void SetArgvPathHint(const char* argv0, std::string& pathHint) #if defined(AT_EXECFN) if (getauxval(AT_EXECFN)) pathHint = getauxval(AT_EXECFN); -#elif defined(_MSC_VER) && (_MSC_VER > 1310) +#elif defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION > 1310) char* pgmptr = NULLPTR; errno_t err = _get_pgmptr(&pgmptr); if (err == 0 && pgmptr != NULLPTR) diff --git a/validat3.cpp b/validat3.cpp index b153de1b..8674ea2b 100644 --- a/validat3.cpp +++ b/validat3.cpp @@ -27,7 +27,7 @@ #include // Aggressive stack checking with VS2005 SP1 and above. -#if (_MSC_VER >= 1500) +#if (CRYPTOPP_MSC_VERSION >= 1500) # pragma strict_gs_check (on) #endif @@ -224,7 +224,7 @@ bool TestSettings() word32 w; const byte s[] = "\x01\x02\x03\x04"; -#if (_MSC_VER >= 1400) +#if (CRYPTOPP_MSC_VERSION >= 1400) memcpy_s(&w, 4, s, 4); #else std::copy(s, s+4, reinterpret_cast(&w)); diff --git a/vmac.cpp b/vmac.cpp index 9f930b44..2439fc7b 100644 --- a/vmac.cpp +++ b/vmac.cpp @@ -9,7 +9,7 @@ #include "argnames.h" #include "secblock.h" -#if defined(_MSC_VER) && !CRYPTOPP_BOOL_SLOW_WORD64 +#if defined(CRYPTOPP_MSC_VERSION) && !CRYPTOPP_BOOL_SLOW_WORD64 #include #endif @@ -455,7 +455,7 @@ void VMAC_Base::VHASH_Update_SSE2(const word64 *data, size_t blocksRemainingInWo #define AccumulateNH(a, b, c) a += word128(b)*(c) #define Multiply128(r, i1, i2) r = word128(word64(i1)) * word64(i2) #else - #if _MSC_VER >= 1400 && !defined(__INTEL_COMPILER) && (defined(_M_IX86) || defined(_M_X64) || defined(_M_IA64)) + #if CRYPTOPP_MSC_VERSION >= 1400 && !defined(__INTEL_COMPILER) && (defined(_M_IX86) || defined(_M_X64) || defined(_M_IA64)) #define MUL32(a, b) __emulu(word32(a), word32(b)) #else #define MUL32(a, b) ((word64)((word32)(a)) * (word32)(b)) @@ -465,7 +465,7 @@ void VMAC_Base::VHASH_Update_SSE2(const word64 *data, size_t blocksRemainingInWo #define MUL64(rh,rl,i1,i2) asm ("mulq %3" : "=a"(rl), "=d"(rh) : "a"(i1), "g"(i2) : "cc"); #define AccumulateNH(a, b, c) asm ("mulq %3; addq %%rax, %0; adcq %%rdx, %1" : "+r"(a##0), "+r"(a##1) : "a"(b), "g"(c) : "%rdx", "cc"); #define ADD128(rh,rl,ih,il) asm ("addq %3, %1; adcq %2, %0" : "+r"(rh),"+r"(rl) : "r"(ih),"r"(il) : "cc"); - #elif defined(_MSC_VER) && !CRYPTOPP_BOOL_SLOW_WORD64 + #elif defined(CRYPTOPP_MSC_VERSION) && !CRYPTOPP_BOOL_SLOW_WORD64 #define DeclareNH(a) word64 a##0=0, a##1=0 #define MUL64(rh,rl,i1,i2) (rl) = _umul128(i1,i2,&(rh)); #define AccumulateNH(a, b, c) {\ diff --git a/zdeflate.cpp b/zdeflate.cpp index d681959d..b3514b55 100644 --- a/zdeflate.cpp +++ b/zdeflate.cpp @@ -12,7 +12,7 @@ NAMESPACE_BEGIN(CryptoPP) -#if (defined(_MSC_VER) && (_MSC_VER < 1400)) && !defined(__MWERKS__) +#if (defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION < 1400)) && !defined(__MWERKS__) // VC60 and VC7 workaround: built-in std::reverse_iterator has two template parameters, Dinkumware only has one typedef std::reverse_bidirectional_iterator RevIt; #elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) @@ -413,12 +413,12 @@ unsigned int Deflator::LongestMatch(unsigned int &bestMatch) const { CRYPTOPP_ASSERT(scan[2] == match[2]); unsigned int len = (unsigned int)( -#if defined(_STDEXT_BEGIN) && !(defined(_MSC_VER) && (_MSC_VER < 1400 || _MSC_VER >= 1600)) && !defined(_STLPORT_VERSION) +#if defined(_STDEXT_BEGIN) && !(defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION < 1400 || CRYPTOPP_MSC_VERSION >= 1600)) && !defined(_STLPORT_VERSION) stdext::unchecked_mismatch #else std::mismatch #endif -#if _MSC_VER >= 1600 +#if CRYPTOPP_MSC_VERSION >= 1600 (stdext::make_unchecked_array_iterator(scan)+3, stdext::make_unchecked_array_iterator(scanEnd), stdext::make_unchecked_array_iterator(match)+3).first - stdext::make_unchecked_array_iterator(scan)); #else (scan+3, scanEnd, match+3).first - scan);