enable SSE2 intrinsics on GCC 3.3 or later
parent
25a333a832
commit
93d56c76c1
|
|
@ -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
|
||||||
|
|
|
||||||
1482
integer.cpp
1482
integer.cpp
File diff suppressed because it is too large
Load Diff
32
integer.h
32
integer.h
|
|
@ -10,21 +10,28 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#ifdef _M_IX86
|
#ifdef _M_IX86
|
||||||
# if (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 500)) || (defined(__ICL) && (__ICL >= 500))
|
#if (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 500)) || (defined(__ICL) && (__ICL >= 500))
|
||||||
# define SSE2_INTRINSICS_AVAILABLE
|
#define SSE2_INTRINSICS_AVAILABLE
|
||||||
# elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
// _mm_free seems to be the only way to tell if the Processor Pack is installed or not
|
// _mm_free seems to be the only way to tell if the Processor Pack is installed or not
|
||||||
# include <malloc.h>
|
#include <malloc.h>
|
||||||
# if defined(_mm_free)
|
#if defined(_mm_free)
|
||||||
# define SSE2_INTRINSICS_AVAILABLE
|
#define SSE2_INTRINSICS_AVAILABLE
|
||||||
# endif
|
#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
|
#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>;
|
|
||||||
typedef SecBlock<word, AlignedAllocator<word> > SecAlignedWordBlock;
|
|
||||||
|
|
||||||
void CRYPTOPP_DLL DisableSSE2();
|
template class CRYPTOPP_DLL AlignedAllocator<word>;
|
||||||
|
typedef SecBlock<word, AlignedAllocator<word> > SecAlignedWordBlock;
|
||||||
|
|
||||||
#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)).
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue