Skip to content

Commit ba75834

Browse files
committed
Removed VC++ 5.0 and 6.0 workarounds (Issue 342)
1 parent bded4d3 commit ba75834

40 files changed

+191
-342
lines changed

algparam.h

+18-81
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ConstByteArrayParameter
6161
template <class T> ConstByteArrayParameter(const T &string, bool deepCopy = false)
6262
: m_deepCopy(false), m_data(NULL), m_size(0)
6363
{
64-
CRYPTOPP_COMPILE_ASSERT(sizeof(CPP_TYPENAME T::value_type) == 1);
64+
CRYPTOPP_COMPILE_ASSERT(sizeof(typename T::value_type) == 1);
6565
Assign((const byte *)string.data(), string.size(), deepCopy);
6666
}
6767

@@ -235,68 +235,6 @@ GetValueHelperClass<T, T> GetValueHelper(const T *pObject, const char *name, con
235235

236236
// ********************************************************
237237

238-
// VC60 workaround
239-
#if defined(_MSC_VER) && (_MSC_VER < 1300)
240-
template <class R>
241-
R Hack_DefaultValueFromConstReferenceType(const R &)
242-
{
243-
return R();
244-
}
245-
246-
template <class R>
247-
bool Hack_GetValueIntoConstReference(const NameValuePairs &source, const char *name, const R &value)
248-
{
249-
return source.GetValue(name, const_cast<R &>(value));
250-
}
251-
252-
template <class T, class BASE>
253-
class AssignFromHelperClass
254-
{
255-
public:
256-
AssignFromHelperClass(T *pObject, const NameValuePairs &source)
257-
: m_pObject(pObject), m_source(source), m_done(false)
258-
{
259-
if (source.GetThisObject(*pObject))
260-
m_done = true;
261-
else if (typeid(BASE) != typeid(T))
262-
pObject->BASE::AssignFrom(source);
263-
}
264-
265-
template <class R>
266-
AssignFromHelperClass & operator()(const char *name, void (T::*pm)(R)) // VC60 workaround: "const R &" here causes compiler error
267-
{
268-
if (!m_done)
269-
{
270-
R value = Hack_DefaultValueFromConstReferenceType(reinterpret_cast<R>(*(int *)NULL));
271-
if (!Hack_GetValueIntoConstReference(m_source, name, value))
272-
throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name + "'");
273-
(m_pObject->*pm)(value);
274-
}
275-
return *this;
276-
}
277-
278-
template <class R, class S>
279-
AssignFromHelperClass & operator()(const char *name1, const char *name2, void (T::*pm)(R, S)) // VC60 workaround: "const R &" here causes compiler error
280-
{
281-
if (!m_done)
282-
{
283-
R value1 = Hack_DefaultValueFromConstReferenceType(reinterpret_cast<R>(*(int *)NULL));
284-
if (!Hack_GetValueIntoConstReference(m_source, name1, value1))
285-
throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name1 + "'");
286-
S value2 = Hack_DefaultValueFromConstReferenceType(reinterpret_cast<S>(*(int *)NULL));
287-
if (!Hack_GetValueIntoConstReference(m_source, name2, value2))
288-
throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name2 + "'");
289-
(m_pObject->*pm)(value1, value2);
290-
}
291-
return *this;
292-
}
293-
294-
private:
295-
T *m_pObject;
296-
const NameValuePairs &m_source;
297-
bool m_done;
298-
};
299-
#else
300238
template <class T, class BASE>
301239
class AssignFromHelperClass
302240
{
@@ -344,7 +282,6 @@ class AssignFromHelperClass
344282
const NameValuePairs &m_source;
345283
bool m_done;
346284
};
347-
#endif
348285

349286
template <class BASE, class T>
350287
AssignFromHelperClass<T, BASE> AssignFromHelper(T *pObject, const NameValuePairs &source, BASE *dummy=NULL)
@@ -382,22 +319,6 @@ class CRYPTOPP_DLL AlgorithmParametersBase
382319
ParameterNotUsed(const char *name) : Exception(OTHER_ERROR, std::string("AlgorithmParametersBase: parameter \"") + name + "\" not used") {}
383320
};
384321

385-
// this is actually a move, not a copy
386-
AlgorithmParametersBase(const AlgorithmParametersBase &x)
387-
: m_name(x.m_name), m_throwIfNotUsed(x.m_throwIfNotUsed), m_used(x.m_used)
388-
{
389-
m_next.reset(const_cast<AlgorithmParametersBase &>(x).m_next.release());
390-
x.m_used = true;
391-
}
392-
393-
//! \brief Construct a AlgorithmParametersBase
394-
//! \param name the parameter name
395-
//! \param throwIfNotUsed flags indicating whether an exception should be thrown
396-
//! \details If throwIfNotUsed is true, then a ParameterNotUsed exception
397-
//! will be thrown in the destructor if the parameter is not not retrieved.
398-
AlgorithmParametersBase(const char *name, bool throwIfNotUsed)
399-
: m_name(name), m_throwIfNotUsed(throwIfNotUsed), m_used(false) {}
400-
401322
virtual ~AlgorithmParametersBase() CRYPTOPP_THROW
402323
{
403324
#ifdef CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
@@ -416,11 +337,27 @@ class CRYPTOPP_DLL AlgorithmParametersBase
416337
#endif
417338
}
418339

340+
// this is actually a move, not a copy
341+
AlgorithmParametersBase(const AlgorithmParametersBase &x)
342+
: m_name(x.m_name), m_throwIfNotUsed(x.m_throwIfNotUsed), m_used(x.m_used)
343+
{
344+
m_next.reset(const_cast<AlgorithmParametersBase &>(x).m_next.release());
345+
x.m_used = true;
346+
}
347+
348+
//! \brief Construct a AlgorithmParametersBase
349+
//! \param name the parameter name
350+
//! \param throwIfNotUsed flags indicating whether an exception should be thrown
351+
//! \details If throwIfNotUsed is true, then a ParameterNotUsed exception
352+
//! will be thrown in the destructor if the parameter is not not retrieved.
353+
AlgorithmParametersBase(const char *name, bool throwIfNotUsed)
354+
: m_name(name), m_throwIfNotUsed(throwIfNotUsed), m_used(false) {}
355+
419356
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
420357

421358
protected:
422359
friend class AlgorithmParameters;
423-
void operator=(const AlgorithmParametersBase& rhs); // assignment not allowed, declare this for VC60
360+
void operator=(const AlgorithmParametersBase& rhs); // assignment not allowed, declare this for VC60
424361

425362
virtual void AssignValue(const char *name, const std::type_info &valueType, void *pValue) const =0;
426363
virtual void MoveInto(void *p) const =0; // not really const

bench1.cpp

+7-13
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,10 @@ void BenchMarkKeying(SimpleKeyingInterface &c, size_t keyLength, const NameValue
206206
OutputResultKeying(iterations, timeTaken);
207207
}
208208

209-
//VC60 workaround: compiler bug triggered without the extra dummy parameters
210-
// on VC60 also needs to be named differently from BenchMarkByName
211209
template <class T_FactoryOutput, class T_Interface>
212-
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)
210+
void BenchMarkByName2(const char *factoryName, size_t keyLength = 0, const char *displayName=NULL, const NameValuePairs &params = g_nullNameValuePairs)
213211
{
214-
CRYPTOPP_UNUSED(x), CRYPTOPP_UNUSED(y), CRYPTOPP_UNUSED(params);
215-
212+
CRYPTOPP_UNUSED(params);
216213
std::string name(factoryName ? factoryName : "");
217214
member_ptr<T_FactoryOutput> obj(ObjectFactoryRegistry<T_FactoryOutput>::Registry().CreateObject(name.c_str()));
218215

@@ -229,20 +226,17 @@ void BenchMarkByName2(const char *factoryName, size_t keyLength = 0, const char
229226
BenchMarkKeying(*obj, keyLength, CombinedNameValuePairs(params, MakeParameters(Name::IV(), ConstByteArrayParameter(defaultKey, obj->IVSize()), false)));
230227
}
231228

232-
//VC60 workaround: compiler bug triggered without the extra dummy parameters
233229
template <class T_FactoryOutput>
234-
void BenchMarkByName(const char *factoryName, size_t keyLength = 0, const char *displayName=NULL, const NameValuePairs &params = g_nullNameValuePairs, T_FactoryOutput *x=NULL)
230+
void BenchMarkByName(const char *factoryName, size_t keyLength = 0, const char *displayName=NULL, const NameValuePairs &params = g_nullNameValuePairs)
235231
{
236-
CRYPTOPP_UNUSED(x), CRYPTOPP_UNUSED(params);
237-
238-
BenchMarkByName2<T_FactoryOutput, T_FactoryOutput>(factoryName, keyLength, displayName, params, x, x);
232+
CRYPTOPP_UNUSED(params);
233+
BenchMarkByName2<T_FactoryOutput, T_FactoryOutput>(factoryName, keyLength, displayName, params);
239234
}
240235

241236
template <class T>
242-
void BenchMarkByNameKeyLess(const char *factoryName, const char *displayName=NULL, const NameValuePairs &params = g_nullNameValuePairs, T *x=NULL)
237+
void BenchMarkByNameKeyLess(const char *factoryName, const char *displayName=NULL, const NameValuePairs &params = g_nullNameValuePairs)
243238
{
244-
CRYPTOPP_UNUSED(x), CRYPTOPP_UNUSED(params);
245-
239+
CRYPTOPP_UNUSED(params);
246240
std::string name = factoryName;
247241
if (displayName)
248242
name = displayName;

bench2.cpp

+3-12
Original file line numberDiff line numberDiff line change
@@ -237,38 +237,29 @@ void BenchMarkAgreement(const char *name, AuthenticatedKeyAgreementDomainWithRol
237237
}
238238
#endif
239239

240-
//VC60 workaround: compiler bug triggered without the extra dummy parameters
241240
template <class SCHEME>
242-
void BenchMarkCrypto(const char *filename, const char *name, double timeTotal, SCHEME *x=NULL)
241+
void BenchMarkCrypto(const char *filename, const char *name, double timeTotal)
243242
{
244-
CRYPTOPP_UNUSED(x);
245-
246243
FileSource f(filename, true, new HexDecoder());
247244
typename SCHEME::Decryptor priv(f);
248245
typename SCHEME::Encryptor pub(priv);
249246
BenchMarkEncryption(name, pub, timeTotal);
250247
BenchMarkDecryption(name, priv, pub, timeTotal);
251248
}
252249

253-
//VC60 workaround: compiler bug triggered without the extra dummy parameters
254250
template <class SCHEME>
255-
void BenchMarkSignature(const char *filename, const char *name, double timeTotal, SCHEME *x=NULL)
251+
void BenchMarkSignature(const char *filename, const char *name, double timeTotal)
256252
{
257-
CRYPTOPP_UNUSED(x);
258-
259253
FileSource f(filename, true, new HexDecoder());
260254
typename SCHEME::Signer priv(f);
261255
typename SCHEME::Verifier pub(priv);
262256
BenchMarkSigning(name, priv, timeTotal);
263257
BenchMarkVerification(name, priv, pub, timeTotal);
264258
}
265259

266-
//VC60 workaround: compiler bug triggered without the extra dummy parameters
267260
template <class D>
268-
void BenchMarkKeyAgreement(const char *filename, const char *name, double timeTotal, D *x=NULL)
261+
void BenchMarkKeyAgreement(const char *filename, const char *name, double timeTotal)
269262
{
270-
CRYPTOPP_UNUSED(x);
271-
272263
FileSource f(filename, true, new HexDecoder());
273264
D d(f);
274265
BenchMarkKeyGen(name, d, timeTotal);

blake2.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ NAMESPACE_BEGIN(CryptoPP)
2525

2626
// Sun Studio 12.3 and earlier lack SSE2's _mm_set_epi64x. Win32 lacks _mm_set_epi64x (Win64 supplies it except for VS2008).
2727
// Also see http://stackoverflow.com/a/38547909/608639
28-
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && ((__SUNPRO_CC >= 0x5100 && __SUNPRO_CC < 0x5130) || (_MSC_VER >= 1200 && _MSC_VER < 1600) || (defined(_M_IX86) && _MSC_VER >= 1600))
28+
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && ((__SUNPRO_CC >= 0x5100 && __SUNPRO_CC < 0x5130) || (defined(_MSC_VER) && _MSC_VER < 1600) || (defined(_M_IX86) && _MSC_VER >= 1600))
2929
inline __m128i _mm_set_epi64x(const word64 a, const word64 b)
3030
{
3131
const word64 t[2] = {b,a}; __m128i r;

config.h

+5-30
Original file line numberDiff line numberDiff line change
@@ -329,19 +329,8 @@ NAMESPACE_END
329329
#endif
330330
#endif
331331

332-
#if defined(_MSC_VER)
333-
#if _MSC_VER == 1200
334-
#include <malloc.h>
335-
#endif
336-
#if _MSC_VER > 1200 || defined(_mm_free)
337-
#define CRYPTOPP_MSVC6PP_OR_LATER // VC 6 processor pack or later
338-
#else
339-
#define CRYPTOPP_MSVC6_NO_PP // VC 6 without processor pack
340-
#endif
341-
#endif
342-
343332
#ifndef CRYPTOPP_ALIGN_DATA
344-
#if defined(CRYPTOPP_MSVC6PP_OR_LATER)
333+
#if defined(_MSC_VER)
345334
#define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
346335
#elif defined(__GNUC__)
347336
#define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))
@@ -374,20 +363,6 @@ NAMESPACE_END
374363
#define CRYPTOPP_FASTCALL
375364
#endif
376365

377-
// VC60 workaround: it doesn't allow typename in some places
378-
#if defined(_MSC_VER) && (_MSC_VER < 1300)
379-
#define CPP_TYPENAME
380-
#else
381-
#define CPP_TYPENAME typename
382-
#endif
383-
384-
// VC60 workaround: can't cast unsigned __int64 to float or double
385-
#if defined(_MSC_VER) && !defined(CRYPTOPP_MSVC6PP_OR_LATER)
386-
#define CRYPTOPP_VC6_INT64 (__int64)
387-
#else
388-
#define CRYPTOPP_VC6_INT64
389-
#endif
390-
391366
#ifdef _MSC_VER
392367
#define CRYPTOPP_NO_VTABLE __declspec(novtable)
393368
#else
@@ -455,7 +430,7 @@ NAMESPACE_END
455430
// C++Builder 2010 does not allow "call label" where label is defined within inline assembly
456431
#define CRYPTOPP_X86_ASM_AVAILABLE
457432

458-
#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__))
433+
#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(_MSC_VER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__))
459434
#define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1
460435
#else
461436
#define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
@@ -476,7 +451,7 @@ NAMESPACE_END
476451
#define CRYPTOPP_X64_ASM_AVAILABLE
477452
#endif
478453

479-
#if !defined(CRYPTOPP_DISABLE_ASM) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__)) && !defined(_M_ARM)
454+
#if !defined(CRYPTOPP_DISABLE_ASM) && (defined(_MSC_VER) || defined(__SSE2__)) && !defined(_M_ARM)
480455
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
481456
#else
482457
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
@@ -536,7 +511,7 @@ NAMESPACE_END
536511
#endif
537512

538513
// how to allocate 16-byte aligned memory (for SSE2)
539-
#if defined(CRYPTOPP_MSVC6PP_OR_LATER)
514+
#if defined(_MSC_VER)
540515
#define CRYPTOPP_MM_MALLOC_AVAILABLE
541516
#elif defined(__APPLE__)
542517
#define CRYPTOPP_APPLE_MALLOC_AVAILABLE
@@ -552,7 +527,7 @@ NAMESPACE_END
552527
// http://developer.apple.com/library/mac/documentation/Performance/Conceptual/ManagingMemory/Articles/MemoryAlloc.html
553528

554529
// how to disable inlining
555-
#if defined(_MSC_VER) && _MSC_VER >= 1300
530+
#if defined(_MSC_VER)
556531
# define CRYPTOPP_NOINLINE_DOTDOTDOT
557532
# define CRYPTOPP_NOINLINE __declspec(noinline)
558533
#elif defined(__GNUC__)

cryptlib.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ enum CipherDir {
111111
const unsigned long INFINITE_TIME = ULONG_MAX;
112112

113113
// VC60 workaround: using enums as template parameters causes problems
114-
//! \brief Converts a typename to an enumerated value
114+
//! \brief Converts an enumeration to a type suitable for use as a template parameter
115115
template <typename ENUM_TYPE, int VALUE>
116116
struct EnumToType
117117
{

default.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,10 @@ DefaultEncryptor::DefaultEncryptor(const byte *passphrase, size_t passphraseLeng
8989
{
9090
}
9191

92-
9392
void DefaultEncryptor::FirstPut(const byte *)
9493
{
95-
// VC60 workaround: __LINE__ expansion bug
96-
CRYPTOPP_COMPILE_ASSERT_INSTANCE(SALTLENGTH <= DefaultHashModule::DIGESTSIZE, 1);
97-
CRYPTOPP_COMPILE_ASSERT_INSTANCE(BLOCKSIZE <= DefaultHashModule::DIGESTSIZE, 2);
94+
CRYPTOPP_COMPILE_ASSERT(SALTLENGTH <= DefaultHashModule::DIGESTSIZE);
95+
CRYPTOPP_COMPILE_ASSERT(BLOCKSIZE <= DefaultHashModule::DIGESTSIZE);
9896

9997
SecByteBlock salt(DefaultHashModule::DIGESTSIZE), keyCheck(DefaultHashModule::DIGESTSIZE);
10098
DefaultHashModule hash;

dessp.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88

99
NAMESPACE_BEGIN(CryptoPP)
1010

11-
// VC60 workaround: gives a C4786 warning without this function
12-
// when runtime lib is set to multithread debug DLL
13-
// even though warning 4786 is disabled!
14-
void DES_VC60Workaround()
15-
{
16-
}
17-
1811
const word32 RawDES::Spbox[8][64] = {
1912
{
2013
0x01010400,0x00000000,0x00010000,0x01010404, 0x01010004,0x00010404,0x00000004,0x00010000,

dh.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ NAMESPACE_BEGIN(CryptoPP)
2121
//! for generating key pairs and deriving agreed values.
2222
//! \sa DL_SimpleKeyAgreementDomainBase
2323
//! \since Crypto++ 1.0
24-
template <class GROUP_PARAMETERS, class COFACTOR_OPTION = CPP_TYPENAME GROUP_PARAMETERS::DefaultCofactorOption>
24+
template <class GROUP_PARAMETERS, class COFACTOR_OPTION = typename GROUP_PARAMETERS::DefaultCofactorOption>
2525
class DH_Domain : public DL_SimpleKeyAgreementDomainBase<typename GROUP_PARAMETERS::Element>
2626
{
2727
typedef DL_SimpleKeyAgreementDomainBase<typename GROUP_PARAMETERS::Element> Base;

dll.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ NAMESPACE_END
5656

5757
USING_NAMESPACE(CryptoPP)
5858

59-
#if !(defined(_MSC_VER) && (_MSC_VER < 1300))
6059
using std::set_new_handler;
61-
#endif
6260

6361
static PNew s_pNew = NULL;
6462
static PDelete s_pDelete = NULL;
@@ -161,4 +159,4 @@ void operator delete [] (void * p)
161159
operator delete (p);
162160
}
163161

164-
#endif // #ifdef CRYPTOPP_EXPORTS
162+
#endif // CRYPTOPP_EXPORTS

dll.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,10 @@
6262

6363
NAMESPACE_BEGIN(CryptoPP)
6464

65-
#if !(defined(_MSC_VER) && (_MSC_VER < 1300))
66-
using std::new_handler;
67-
#endif
68-
6965
typedef void * (CRYPTOPP_API * PNew)(size_t);
7066
typedef void (CRYPTOPP_API * PDelete)(void *);
7167
typedef void (CRYPTOPP_API * PGetNewAndDelete)(PNew &, PDelete &);
72-
typedef new_handler (CRYPTOPP_API * PSetNewHandler)(new_handler);
68+
typedef std::new_handler (CRYPTOPP_API * PSetNewHandler)(std::new_handler);
7369
typedef void (CRYPTOPP_API * PSetNewAndDelete)(PNew, PDelete, PSetNewHandler);
7470

7571
NAMESPACE_END

0 commit comments

Comments
 (0)