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 ARFLAGS = -cr # ar needs the dash on OpenBSD
RANLIB = ranlib RANLIB = ranlib
UNAME = $(shell uname) 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 ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist
CXXFLAGS += -mbnu210 CXXFLAGS += -mbnu210

File diff suppressed because it is too large Load Diff

View File

@ -21,10 +21,17 @@
#endif #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) NAMESPACE_BEGIN(CryptoPP)
#if defined(SSE2_INTRINSICS_AVAILABLE) || defined(_MSC_VER) #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> template <class T>
class AlignedAllocator : public AllocatorBase<T> class AlignedAllocator : public AllocatorBase<T>
{ {
@ -38,15 +45,16 @@ NAMESPACE_BEGIN(CryptoPP)
return StandardReallocate(*this, p, oldSize, newSize, preserve); return StandardReallocate(*this, p, oldSize, newSize, preserve);
} }
}; };
template class CRYPTOPP_DLL AlignedAllocator<word>; template class CRYPTOPP_DLL AlignedAllocator<word>;
typedef SecBlock<word, AlignedAllocator<word> > SecAlignedWordBlock; typedef SecBlock<word, AlignedAllocator<word> > SecAlignedWordBlock;
void CRYPTOPP_DLL DisableSSE2();
#else #else
typedef SecWordBlock SecAlignedWordBlock; typedef SecWordBlock SecAlignedWordBlock;
#endif #endif
void CRYPTOPP_DLL DisableSSE2();
//! multiple precision integer and basic arithmetics //! multiple precision integer and basic arithmetics
/*! This class can represent positive and negative integers /*! This class can represent positive and negative integers
with absolute value less than (256**sizeof(word)) ** (256**sizeof(int)). with absolute value less than (256**sizeof(word)) ** (256**sizeof(int)).