83 lines
3.1 KiB
Plaintext
83 lines
3.1 KiB
Plaintext
$OpenBSD: patch-misc_h,v 1.3 2012/02/29 12:46:30 dcoppa Exp $
|
|
--- misc.h.orig Fri Aug 6 18:46:18 2010
|
|
+++ misc.h Wed Feb 29 10:09:08 2012
|
|
@@ -141,7 +141,7 @@ const T & Singleton<T, F, instance>::Ref(CRYPTOPP_NOIN
|
|
|
|
// ************** misc functions ***************
|
|
|
|
-#if (!__STDC_WANT_SECURE_LIB__)
|
|
+#if (!defined(__STDC_WANT_SECURE_LIB__) || !__STDC_WANT_SECURE_LIB__)
|
|
inline void memcpy_s(void *dest, size_t sizeInBytes, const void *src, size_t count)
|
|
{
|
|
if (count > sizeInBytes)
|
|
@@ -156,7 +156,7 @@ inline void memmove_s(void *dest, size_t sizeInBytes,
|
|
memmove(dest, src, count);
|
|
}
|
|
|
|
-#if __BORLANDC__ >= 0x620
|
|
+#if defined(__BORLANDC__) && __BORLANDC__ >= 0x620
|
|
// C++Builder 2010 workaround: can't use std::memcpy_s because it doesn't allow 0 lengths
|
|
#define memcpy_s CryptoPP::memcpy_s
|
|
#define memmove_s CryptoPP::memmove_s
|
|
@@ -367,7 +367,7 @@ inline unsigned int GetAlignmentOf(T *dummy=NULL) // V
|
|
return 1;
|
|
#endif
|
|
|
|
-#if (_MSC_VER >= 1300)
|
|
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
|
return __alignof(T);
|
|
#elif defined(__GNUC__)
|
|
return __alignof__(T);
|
|
@@ -483,7 +483,7 @@ void SecureWipeBuffer(T *buf, size_t n)
|
|
*(--p) = 0;
|
|
}
|
|
|
|
-#if (_MSC_VER >= 1400 || defined(__GNUC__)) && (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86)
|
|
+#if (defined(_MSC_VER) && _MSC_VER >= 1400 || defined(__GNUC__)) && (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86)
|
|
|
|
template<> inline void SecureWipeBuffer(byte *buf, size_t n)
|
|
{
|
|
@@ -580,13 +580,13 @@ CRYPTOPP_DLL void CRYPTOPP_API UnalignedDeallocate(voi
|
|
template <class T> inline T rotlFixed(T x, unsigned int y)
|
|
{
|
|
assert(y < sizeof(T)*8);
|
|
- return T((x<<y) | (x>>(sizeof(T)*8-y)));
|
|
+ return y ? T((x<<y) | (x>>(sizeof(T)*8-y))) : x;
|
|
}
|
|
|
|
template <class T> inline T rotrFixed(T x, unsigned int y)
|
|
{
|
|
assert(y < sizeof(T)*8);
|
|
- return T((x>>y) | (x<<(sizeof(T)*8-y)));
|
|
+ return y ? T((x>>y) | (x<<(sizeof(T)*8-y))) : x;
|
|
}
|
|
|
|
template <class T> inline T rotlVariable(T x, unsigned int y)
|
|
@@ -651,7 +651,7 @@ template<> inline word32 rotrMod<word32>(word32 x, uns
|
|
|
|
#endif // #ifdef _MSC_VER
|
|
|
|
-#if _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
|
|
+#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
|
|
// Intel C++ Compiler 10.0 calls a function instead of using the rotate instruction when using these instructions
|
|
|
|
template<> inline word64 rotlFixed<word64>(word64 x, unsigned int y)
|
|
@@ -690,7 +690,7 @@ template<> inline word64 rotrMod<word64>(word64 x, uns
|
|
|
|
#endif // #if _MSC_VER >= 1310
|
|
|
|
-#if _MSC_VER >= 1400 && !defined(__INTEL_COMPILER)
|
|
+#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(__INTEL_COMPILER)
|
|
// Intel C++ Compiler 10.0 gives undefined externals with these
|
|
|
|
template<> inline word16 rotlFixed<word16>(word16 x, unsigned int y)
|
|
@@ -837,7 +837,7 @@ inline word32 ByteReverse(word32 value)
|
|
return bswap_32(value);
|
|
#elif defined(__MWERKS__) && TARGET_CPU_PPC
|
|
return (word32)__lwbrx(&value,0);
|
|
-#elif _MSC_VER >= 1400 || (_MSC_VER >= 1300 && !defined(_DLL))
|
|
+#elif (defined(_MSC_VER) && _MSC_VER >= 1400) || (defined (_MSC_VER) && _MSC_VER >= 1300 && !defined(_DLL))
|
|
return _byteswap_ulong(value);
|
|
#elif CRYPTOPP_FAST_ROTATE(32)
|
|
// 5 instructions with rotate instruction, 9 without
|