diff options
-rw-r--r-- | config.h | 45 | ||||
-rw-r--r-- | hrtimer.cpp | 8 | ||||
-rw-r--r-- | integer.h | 23 | ||||
-rw-r--r-- | network.cpp | 2 | ||||
-rw-r--r-- | rijndael.cpp | 4 |
5 files changed, 42 insertions, 40 deletions
@@ -154,6 +154,8 @@ typedef unsigned int word32; const unsigned int WORD_SIZE = sizeof(word); const unsigned int WORD_BITS = WORD_SIZE * 8; +NAMESPACE_END + #if defined(_MSC_VER) // || defined(__BORLANDC__) intrinsics don't work on BCB 2006 #define INTEL_INTRINSICS #define FAST_ROTATE @@ -171,18 +173,26 @@ const unsigned int WORD_BITS = WORD_SIZE * 8; #define CRYPTOPP_L1_CACHE_LINE_SIZE 32 #endif +#if defined(_MSC_VER) + #if _MSC_VER == 1200 + #include <malloc.h> + #endif + #if _MSC_VER > 1200 || defined(_mm_free) + #define CRYPTOPP_MSVC6PP_OR_LATER // VC 6 processor pack or later + #endif +#endif + #ifndef CRYPTOPP_L1_CACHE_ALIGN - #if defined(_MSC_VER) + #if defined(CRYPTOPP_MSVC6PP_OR_LATER) #define CRYPTOPP_L1_CACHE_ALIGN(x) __declspec(align(CRYPTOPP_L1_CACHE_LINE_SIZE)) x #elif defined(__GNUC__) #define CRYPTOPP_L1_CACHE_ALIGN(x) x __attribute__((aligned(CRYPTOPP_L1_CACHE_LINE_SIZE))) #else + #define CRYPTOPP_L1_CACHE_ALIGN_NOT_AVAILABLE #define CRYPTOPP_L1_CACHE_ALIGN(x) x #endif #endif -NAMESPACE_END - // VC60 workaround: it doesn't allow typename in some places #if defined(_MSC_VER) && (_MSC_VER < 1300) #define CPP_TYPENAME @@ -190,6 +200,13 @@ NAMESPACE_END #define CPP_TYPENAME typename #endif +// VC60 workaround: can't cast unsigned __int64 to float or double +#if defined(_MSC_VER) && !defined(CRYPTOPP_MSVC6PP_OR_LATER) +#define CRYPTOPP_VC6_INT64 (__int64) +#else +#define CRYPTOPP_VC6_INT64 +#endif + #ifdef _MSC_VER #define CRYPTOPP_NO_VTABLE __declspec(novtable) #else @@ -239,17 +256,27 @@ NAMESPACE_END #endif // how to declare class constants -#if defined(_MSC_VER) && _MSC_VER < 1300 +#if defined(_MSC_VER) && _MSC_VER <= 1300 # define CRYPTOPP_CONSTANT(x) enum {x}; #else # define CRYPTOPP_CONSTANT(x) static const int x; #endif -// how to allocate 16-byte aligned memory (for SSE2) -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) -# define CRYPTOPP_MALLOC_ALIGNMENT_IS_16 -#elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__) -# define CRYPTOPP_MEMALIGN_AVAILABLE +#ifdef CRYPTOPP_X86ASM_AVAILABLE + #if defined(CRYPTOPP_MSVC6PP_OR_LATER) || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 500)) || (defined(__ICL) && (__ICL >= 500)) + #define SSE2_INTRINSICS_AVAILABLE + #define CRYPTOPP_MM_MALLOC_AVAILABLE + #endif + // SSE2 intrinsics work in GCC 3.3 or later + #if defined(__SSE2__) && (__GNUC__ > 3 || __GNUC_MINOR__ > 2) + #define SSE2_INTRINSICS_AVAILABLE + // how to allocate 16-byte aligned memory (for SSE2) + #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) + #define CRYPTOPP_MALLOC_ALIGNMENT_IS_16 + #elif defined(__linux__) || defined(__sun__) || defined(__CYGWIN__) + #define CRYPTOPP_MEMALIGN_AVAILABLE + #endif + #endif #endif // ***************** determine availability of OS features ******************** diff --git a/hrtimer.cpp b/hrtimer.cpp index 6fe9b568..71149baf 100644 --- a/hrtimer.cpp +++ b/hrtimer.cpp @@ -23,13 +23,7 @@ double TimerBase::ConvertTo(TimerWord t, Unit unit) static unsigned long unitsPerSecondTable[] = {1, 1000, 1000*1000, 1000*1000*1000}; assert(unit < sizeof(unitsPerSecondTable) / sizeof(unitsPerSecondTable[0])); -#if defined(_MSC_VER) && (_MSC_VER < 1300) - // MSVC 6 workaround - return (double)(__int64)t * unitsPerSecondTable[unit] / (__int64)TicksPerSecond(); -#else - return (double)t * unitsPerSecondTable[unit] / TicksPerSecond(); -#endif - + return (double)CRYPTOPP_VC6_INT64 t * unitsPerSecondTable[unit] / CRYPTOPP_VC6_INT64 TicksPerSecond(); } void TimerBase::StartTimer() @@ -9,29 +9,6 @@ #include <iosfwd> #include <algorithm> -#ifdef CRYPTOPP_X86ASM_AVAILABLE - -#ifdef _M_IX86 - #if (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 500)) || (defined(__ICL) && (__ICL >= 500)) - #define SSE2_INTRINSICS_AVAILABLE - #define CRYPTOPP_MM_MALLOC_AVAILABLE - #elif defined(_MSC_VER) - // _mm_free seems to be the only way to tell if the Processor Pack is installed or not - #include <malloc.h> - #if defined(_mm_free) - #define SSE2_INTRINSICS_AVAILABLE - #define CRYPTOPP_MM_MALLOC_AVAILABLE - #endif - #endif -#endif - -// SSE2 intrinsics work in GCC 3.3 or later -#if defined(__SSE2__) && (__GNUC__ > 3 || __GNUC_MINOR__ > 2) - #define SSE2_INTRINSICS_AVAILABLE -#endif - -#endif - NAMESPACE_BEGIN(CryptoPP) #if defined(SSE2_INTRINSICS_AVAILABLE) diff --git a/network.cpp b/network.cpp index ead3a1c4..9b7198d1 100644 --- a/network.cpp +++ b/network.cpp @@ -395,7 +395,7 @@ float NetworkSink::ComputeCurrentSpeed() float NetworkSink::GetMaxObservedSpeed() const { lword m = GetMaxBytesPerSecond(); - return m ? STDMIN(m_maxObservedSpeed, float(m)) : m_maxObservedSpeed; + return m ? STDMIN(m_maxObservedSpeed, float(CRYPTOPP_VC6_INT64 m)) : m_maxObservedSpeed; } unsigned int NetworkSink::GetMaxWaitObjectCount() const diff --git a/rijndael.cpp b/rijndael.cpp index fb79e255..2a1a19ef 100644 --- a/rijndael.cpp +++ b/rijndael.cpp @@ -52,6 +52,10 @@ being unloaded from L1 cache, until that round is finished. #include "rijndael.h" #include "misc.h" +#ifdef CRYPTOPP_L1_CACHE_ALIGN_NOT_AVAILABLE +#pragma message("Don't know how to align data on L1 cache boundary. Defense against AES timing attack may be affected.") +#endif + NAMESPACE_BEGIN(CryptoPP) void Rijndael::Base::UncheckedSetKey(const byte *userKey, unsigned int keylen, const NameValuePairs &) |