diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2008-11-21 03:05:32 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2008-11-21 03:05:32 +0000 |
commit | 260b002fc017c4bf24ec72c4739d11babe9e1a99 (patch) | |
tree | 1b3cabd0bc88d30dc744786c7212761df853a716 | |
parent | fed5890194f50d587a9dc57f20d89e3369af125a (diff) | |
download | cryptopp-260b002fc017c4bf24ec72c4739d11babe9e1a99.tar.gz |
fixes for GCC 4.3.2 (reports from Chris Morgan and DiegoT)
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@422 57ff6487-cd31-0410-9ec3-f628ee90f5f0
-rw-r--r-- | integer.cpp | 8 | ||||
-rw-r--r-- | misc.h | 12 | ||||
-rw-r--r-- | modes.h | 6 | ||||
-rw-r--r-- | secblock.h | 4 |
4 files changed, 20 insertions, 10 deletions
diff --git a/integer.cpp b/integer.cpp index 56dab61..e5aa95e 100644 --- a/integer.cpp +++ b/integer.cpp @@ -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; @@ -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)); } @@ -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> >; @@ -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)); } |