fixes for GCC 4.3.2 (reports from Chris Morgan and DiegoT)

pull/2/head
weidai 2008-11-21 03:05:32 +00:00
parent 244f99c027
commit 3f30574ced
4 changed files with 20 additions and 10 deletions

View File

@ -547,8 +547,8 @@ int Baseline_Add(size_t N, word *C, const word *A, const word *B)
AS2( mov %0, 0)
AS2( adc %0, %0)
".att_syntax;"
: "=&r" (result)
: "c" (N), "r" (C+N), "r" (A+N), "r" (B+N)
: "=&r" (result), "+c" (N)
: "r" (C+N), "r" (A+N), "r" (B+N)
: "memory", "cc"
);
return (int)result;
@ -579,8 +579,8 @@ int Baseline_Sub(size_t N, word *C, const word *A, const word *B)
AS2( mov %0, 0)
AS2( adc %0, %0)
".att_syntax;"
: "=&r" (result)
: "c" (N), "r" (C+N), "r" (A+N), "r" (B+N)
: "=&r" (result), "+c" (N)
: "r" (C+N), "r" (A+N), "r" (B+N)
: "memory", "cc"
);
return (int)result;

12
misc.h
View File

@ -166,6 +166,16 @@ inline void memmove_s(void *dest, size_t sizeInBytes, const void *src, size_t co
}
#endif
inline void * memset_z(void *ptr, int value, size_t num)
{
// avoid extranous warning on GCC 4.3.2 Ubuntu 8.10
#if CRYPTOPP_GCC_VERSION >= 30001
if (__builtin_constant_p(num) && num==0)
return ptr;
#endif
return memset(ptr, value, num);
}
// can't use std::min or std::max in MSVC60 or Cygwin 1.1.0
template <class T> inline const T& STDMIN(const T& a, const T& b)
{
@ -797,7 +807,7 @@ inline void GetUserKey(ByteOrder order, T *out, size_t outlen, const byte *in, s
const size_t U = sizeof(T);
assert(inlen <= outlen*U);
memcpy(out, in, inlen);
memset((byte *)out+inlen, 0, outlen*U-inlen);
memset_z((byte *)out+inlen, 0, outlen*U-inlen);
ConditionalByteReverse(order, out, out, RoundUpToMultipleOf(inlen, U));
}

View File

@ -308,12 +308,12 @@ class CipherModeFinalTemplate_ExternalCipher : public BASE
public:
CipherModeFinalTemplate_ExternalCipher() {}
CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher)
{SetCipher(cipher);}
{this->SetCipher(cipher);}
CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher, const byte *iv, int feedbackSize = 0)
{SetCipherWithIV(cipher, iv, feedbackSize);}
{this->SetCipherWithIV(cipher, iv, feedbackSize);}
std::string AlgorithmName() const
{return m_cipher->AlgorithmName() + "/" + BASE::StaticAlgorithmName();}
{return this->m_cipher->AlgorithmName() + "/" + BASE::StaticAlgorithmName();}
};
CRYPTOPP_DLL_TEMPLATE_CLASS CFB_CipherTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >;

View File

@ -130,7 +130,7 @@ public:
void deallocate(void *p, size_type n)
{
memset(p, 0, n*sizeof(T));
memset_z(p, 0, n*sizeof(T));
if (T_Align16 && n*sizeof(T) >= 16)
{
@ -288,7 +288,7 @@ public:
{
m_ptr = m_alloc.allocate(len, NULL);
if (t == NULL)
memset(m_ptr, 0, len*sizeof(T));
memset_z(m_ptr, 0, len*sizeof(T));
else
memcpy(m_ptr, t, len*sizeof(T));
}