Skip to content

Commit

Permalink
fix VC60 compile, project file line-endings, Apple GCC 4.2 compile
Browse files Browse the repository at this point in the history
  • Loading branch information
weidai11 committed Mar 3, 2009
1 parent b249126 commit a47f065
Show file tree
Hide file tree
Showing 19 changed files with 17,802 additions and 17,716 deletions.
8 changes: 1 addition & 7 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,13 @@ endif

ifeq ($(ISX86),1)

GCC34_OR_LATER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(GCC\) (3.[4-9]|[4-9])")
GCC42_OR_LATER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(GCC\) (4.[2-9]|[5-9])")
INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)")
GAS210_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2.[1-9][0-9]|[3-9])")

ifneq ($(GCC34_OR_LATER) $(INTEL_COMPILER),0 0)
ifneq ($(GCC42_OR_LATER),0)
ifneq ($(UNAME),Darwin)
CXXFLAGS += -march=native -mtune=native
else
# -msse2 is in GCC 3.3, but it causes internal compiler error on salsa.cpp,
# so don't use it unless we're at GCC 3.4 or later
# actually, we're not using SSE2 intrinsics anymore, and -msse2 causes invalid instructions on non-SSE2 CPUs
# CXXFLAGS += -msse2
endif
endif

Expand Down
14 changes: 14 additions & 0 deletions algparam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ bool CombinedNameValuePairs::GetVoidValue(const char *name, const std::type_info
return m_pairs1.GetVoidValue(name, valueType, pValue) || m_pairs2.GetVoidValue(name, valueType, pValue);
}

void AlgorithmParametersBase::operator=(const AlgorithmParametersBase& rhs)
{
assert(false);
}

bool AlgorithmParametersBase::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
{
if (strcmp(name, "ValueNames") == 0)
Expand Down Expand Up @@ -66,6 +71,15 @@ AlgorithmParameters::~AlgorithmParameters()
Next().~member_ptr<AlgorithmParametersBase>();
}

AlgorithmParameters & AlgorithmParameters::operator=(const AlgorithmParameters &x)
{
if (this == &x)
return *this;
this->~AlgorithmParameters();
new (this) AlgorithmParameters(x);
return *this;
}

bool AlgorithmParameters::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
{
if (m_constructed)
Expand Down
3 changes: 3 additions & 0 deletions algparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class CRYPTOPP_DLL AlgorithmParametersBase

protected:
friend class AlgorithmParameters;
void operator=(const AlgorithmParametersBase& rhs); // assignment not allowed, declare this for VC60

virtual void AssignValue(const char *name, const std::type_info &valueType, void *pValue) const =0;
virtual void MoveInto(void *p) const =0; // not really const
Expand Down Expand Up @@ -338,6 +339,8 @@ class CRYPTOPP_DLL AlgorithmParameters : public NameValuePairs

~AlgorithmParameters();

AlgorithmParameters & operator=(const AlgorithmParameters &x);

template <class T>
AlgorithmParameters & operator()(const char *name, const T &value, bool throwIfNotUsed)
{
Expand Down
15 changes: 8 additions & 7 deletions bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ void BenchMarkKeyless(const char *name, double timeTotal, T *x=NULL)
}

//VC60 workaround: compiler bug triggered without the extra dummy parameters
// on VC60 also needs to be named differently from BenchMarkByName
template <class T_FactoryOutput, class T_Interface>
void BenchMarkByName(const char *factoryName, size_t keyLength = 0, const char *displayName=NULL, const NameValuePairs &params = g_nullNameValuePairs, T_FactoryOutput *x=NULL, T_Interface *y=NULL)
void BenchMarkByName2(const char *factoryName, size_t keyLength = 0, const char *displayName=NULL, const NameValuePairs &params = g_nullNameValuePairs, T_FactoryOutput *x=NULL, T_Interface *y=NULL)
{
std::string name = factoryName;
if (displayName)
Expand All @@ -227,7 +228,7 @@ void BenchMarkByName(const char *factoryName, size_t keyLength = 0, const char *
template <class T_FactoryOutput>
void BenchMarkByName(const char *factoryName, size_t keyLength = 0, const char *displayName=NULL, const NameValuePairs &params = g_nullNameValuePairs, T_FactoryOutput *x=NULL)
{
BenchMarkByName<T_FactoryOutput, T_FactoryOutput>(factoryName, keyLength, displayName, params, x, x);
BenchMarkByName2<T_FactoryOutput, T_FactoryOutput>(factoryName, keyLength, displayName, params, x, x);
}

template <class T>
Expand Down Expand Up @@ -266,13 +267,13 @@ void BenchmarkAll(double t, double hertz)
cout << "<THEAD><TR><TH>Algorithm<TH>MiB/Second" << cpb << "<TH>Microseconds to<br>Setup Key and IV" << cpk << endl;

cout << "\n<TBODY style=\"background: yellow\">";
BenchMarkByName<AuthenticatedSymmetricCipher, StreamTransformation>("AES/GCM", 0, "AES/GCM (2K tables)", MakeParameters(Name::TableSize(), 2048));
BenchMarkByName<AuthenticatedSymmetricCipher, StreamTransformation>("AES/GCM", 0, "AES/GCM (64K tables)", MakeParameters(Name::TableSize(), 64*1024));
BenchMarkByName<AuthenticatedSymmetricCipher, StreamTransformation>("AES/CCM");
BenchMarkByName2<AuthenticatedSymmetricCipher, StreamTransformation>("AES/GCM", 0, "AES/GCM (2K tables)", MakeParameters(Name::TableSize(), 2048));
BenchMarkByName2<AuthenticatedSymmetricCipher, StreamTransformation>("AES/GCM", 0, "AES/GCM (64K tables)", MakeParameters(Name::TableSize(), 64*1024));
BenchMarkByName2<AuthenticatedSymmetricCipher, StreamTransformation>("AES/CCM");

cout << "\n<TBODY style=\"background: white\">";
BenchMarkByName<AuthenticatedSymmetricCipher, MessageAuthenticationCode>("AES/GCM", 0, "GMAC(AES) (2K tables)", MakeParameters(Name::TableSize(), 2048));
BenchMarkByName<AuthenticatedSymmetricCipher, MessageAuthenticationCode>("AES/GCM", 0, "GMAC(AES) (64K tables)", MakeParameters(Name::TableSize(), 64*1024));
BenchMarkByName2<AuthenticatedSymmetricCipher, MessageAuthenticationCode>("AES/GCM", 0, "GMAC(AES) (2K tables)", MakeParameters(Name::TableSize(), 2048));
BenchMarkByName2<AuthenticatedSymmetricCipher, MessageAuthenticationCode>("AES/GCM", 0, "GMAC(AES) (64K tables)", MakeParameters(Name::TableSize(), 64*1024));
BenchMarkByName<MessageAuthenticationCode>("VMAC(AES)-64");
BenchMarkByName<MessageAuthenticationCode>("VMAC(AES)-128");
BenchMarkByName<MessageAuthenticationCode>("HMAC(SHA-1)");
Expand Down
Loading

0 comments on commit a47f065

Please sign in to comment.