enable SSE2 intrinsics on GCC 3.3 or later

pull/2/head
weidai 2003-07-31 01:54:53 +00:00
parent 25a333a832
commit 93d56c76c1
3 changed files with 738 additions and 782 deletions

View File

@ -9,6 +9,12 @@ CXXFLAGS = -g
ARFLAGS = -cr # ar needs the dash on OpenBSD
RANLIB = ranlib
UNAME = $(shell uname)
ISX86 = $(shell uname -m | grep -c "i.86")
GCC33ORLATER = $(shell gcc -v 2>&1 | grep -c "gcc version \(3.[3-9]\|[4-9]\)")
ifeq ($(ISX86) $(GCC33ORLATER),1 1)
CXXFLAGS += -msse2
endif
ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist
CXXFLAGS += -mbnu210

File diff suppressed because it is too large Load Diff

View File

@ -10,21 +10,28 @@
#include <algorithm>
#ifdef _M_IX86
# if (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 500)) || (defined(__ICL) && (__ICL >= 500))
# define SSE2_INTRINSICS_AVAILABLE
# elif defined(_MSC_VER)
#if (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 500)) || (defined(__ICL) && (__ICL >= 500))
#define SSE2_INTRINSICS_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
# endif
# endif
#include <malloc.h>
#if defined(_mm_free)
#define SSE2_INTRINSICS_AVAILABLE
#endif
#endif
#endif
// SSE2 intrinsics work in GCC 3.3 or later
#if defined(__SSE2__) && (__GNUC_MAJOR__ > 3 || __GNUC_MINOR__ > 2)
#define SSE2_INTRINSICS_AVAILABLE
#endif
NAMESPACE_BEGIN(CryptoPP)
#if defined(SSE2_INTRINSICS_AVAILABLE) || defined(_MSC_VER)
// Defined this class for MSVC even if processor pack is not installed,
// so that the library can be compiled with processor pack, and calling app
// compiled without it.
template <class T>
class AlignedAllocator : public AllocatorBase<T>
{
@ -38,15 +45,16 @@ NAMESPACE_BEGIN(CryptoPP)
return StandardReallocate(*this, p, oldSize, newSize, preserve);
}
};
template class CRYPTOPP_DLL AlignedAllocator<word>;
typedef SecBlock<word, AlignedAllocator<word> > SecAlignedWordBlock;
void CRYPTOPP_DLL DisableSSE2();
template class CRYPTOPP_DLL AlignedAllocator<word>;
typedef SecBlock<word, AlignedAllocator<word> > SecAlignedWordBlock;
#else
typedef SecWordBlock SecAlignedWordBlock;
#endif
void CRYPTOPP_DLL DisableSSE2();
//! multiple precision integer and basic arithmetics
/*! This class can represent positive and negative integers
with absolute value less than (256**sizeof(word)) ** (256**sizeof(int)).