diff --git a/crc.cpp b/crc.cpp index e1b51bb9..ccc3fe62 100644 --- a/crc.cpp +++ b/crc.cpp @@ -14,7 +14,7 @@ NAMESPACE_BEGIN(CryptoPP) #endif #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 -#if (CRYPTOPP_GCC_VERSION >= 40300 || __INTEL_COMPILER >= 1000 || __SUNPRO_CC >= 0x5110 || CRYPTOPP_LLVM_CLANG_VERSION >= 20300 || CRYPTOPP_APPLE_CLANG_VERSION >= 40000) && !defined(__SSE4_2__) +#if (CRYPTOPP_GCC_VERSION >= 40300 || __INTEL_COMPILER >= 1000 || __SUNPRO_CC >= 0x5110 || CRYPTOPP_LLVM_CLANG_VERSION >= 20300 || CRYPTOPP_APPLE_CLANG_VERSION >= 40000) && !defined(__SSE4_2__) && !defined(_MSC_VER) GCC_INLINE unsigned int GCC_INLINE_ATTRIB MM_CRC32_U8(unsigned int crc, unsigned char val) { diff --git a/dll.cpp b/dll.cpp index bc406de2..372ed712 100644 --- a/dll.cpp +++ b/dll.cpp @@ -121,7 +121,7 @@ static void SetNewAndDeleteFunctionPointers() return; } - OutputDebugString("Crypto++ DLL was not able to obtain new and delete function pointers.\n"); + OutputDebugStringA("Crypto++ DLL was not able to obtain new and delete function pointers.\n"); throw 0; } diff --git a/fipstest.cpp b/fipstest.cpp index a7419821..132c6510 100644 --- a/fipstest.cpp +++ b/fipstest.cpp @@ -328,21 +328,21 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule { std::ostringstream oss; oss << "Crypto++ DLL loaded at base address 0x" << std::hex << h << ".\n"; - OutputDebugString(oss.str().c_str()); + OutputDebugStringA(oss.str().c_str()); } else { std::ostringstream oss; oss << "Crypto++ DLL integrity check may fail. Expected module base address is 0x"; oss << std::hex << g_BaseAddressOfMAC << ", but module loaded at 0x" << h << ".\n"; - OutputDebugString(oss.str().c_str()); + OutputDebugStringA(oss.str().c_str()); } #endif if (!moduleStream) { #ifdef CRYPTOPP_WIN32_AVAILABLE - OutputDebugString("Crypto++ DLL integrity check failed. Cannot open file for reading."); + OutputDebugStringA("Crypto++ DLL integrity check failed. Cannot open file for reading."); #endif return false; } @@ -400,7 +400,7 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule } } -#if defined(_MSC_VER) && _MSC_VER >= 1400 +#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(_M_ARM) // first byte of _CRT_DEBUGGER_HOOK gets modified in memory by the debugger invisibly, so read it from file if (IsDebuggerPresent()) { @@ -436,7 +436,7 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule // hash from disk instead if (!VerifyBufsEqual(expectedModuleMac, actualMac, macSize)) { - OutputDebugString("Crypto++ DLL in-memory integrity check failed. This may be caused by debug breakpoints or DLL relocation.\n"); + OutputDebugStringA("Crypto++ DLL in-memory integrity check failed. This may be caused by debug breakpoints or DLL relocation.\n"); moduleStream.clear(); moduleStream.seekg(0); verifier.Initialize(MakeParameters(Name::OutputBuffer(), ByteArrayParameter(actualMac, (unsigned int)actualMac.size()))); @@ -455,7 +455,7 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule #ifdef CRYPTOPP_WIN32_AVAILABLE std::string hexMac; HexEncoder(new StringSink(hexMac)).PutMessageEnd(actualMac, actualMac.size()); - OutputDebugString((("Crypto++ DLL integrity check failed. Actual MAC is: " + hexMac) + ".\n").c_str()); + OutputDebugStringA((("Crypto++ DLL integrity check failed. Actual MAC is: " + hexMac) + ".\n").c_str()); #endif return false; } diff --git a/integer.cpp b/integer.cpp index 13a58a4e..cb38ca29 100644 --- a/integer.cpp +++ b/integer.cpp @@ -41,8 +41,10 @@ #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE # pragma GCC diagnostic ignored "-Wunused" +#if !defined(__clang__) # pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif +#endif // Issue 340 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE diff --git a/iterhash.cpp b/iterhash.cpp index eedd5172..bf287164 100644 --- a/iterhash.cpp +++ b/iterhash.cpp @@ -152,7 +152,7 @@ template void IteratedHashBase::TruncatedFinal(by this->Restart(); // reinit for next use } -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__clang__) template class IteratedHashBase; template class IteratedHashBase; diff --git a/iterhash.h b/iterhash.h index 5ab38825..d51e155b 100644 --- a/iterhash.h +++ b/iterhash.h @@ -179,7 +179,7 @@ protected: FixedSizeAlignedSecBlock m_state; }; -#ifndef __GNUC__ +#if !defined(__GNUC__) && !defined(__clang__) CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase; CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase; diff --git a/network.cpp b/network.cpp index 9195e22b..c7873d0e 100644 --- a/network.cpp +++ b/network.cpp @@ -287,7 +287,7 @@ size_t NetworkSource::DoPump(lword &byteCount, bool blockingOutput, unsigned lon unsigned int recvResult = receiver.GetReceiveResult(); #if CRYPTOPP_TRACE_NETWORK - OutputDebugString((IntToString((unsigned int)this) + ": Received " + IntToString(recvResult) + " bytes\n").c_str()); + OutputDebugStringA((IntToString((unsigned int)this) + ": Received " + IntToString(recvResult) + " bytes\n").c_str()); #endif m_dataEnd += recvResult; m_waitingForResult = false; @@ -315,13 +315,13 @@ ReceiveNoWait: // call Receive repeatedly as long as data is immediately available, // because some receivers tend to return data in small pieces #if CRYPTOPP_TRACE_NETWORK - OutputDebugString((IntToString((unsigned int)this) + ": Receiving " + IntToString(m_buf.size()-m_dataEnd) + " bytes\n").c_str()); + OutputDebugStringA((IntToString((unsigned int)this) + ": Receiving " + IntToString(m_buf.size()-m_dataEnd) + " bytes\n").c_str()); #endif while (receiver.Receive(m_buf+m_dataEnd, m_buf.size()-m_dataEnd)) { unsigned int recvResult = receiver.GetReceiveResult(); #if CRYPTOPP_TRACE_NETWORK - OutputDebugString((IntToString((unsigned int)this) + ": Received " + IntToString(recvResult) + " bytes\n").c_str()); + OutputDebugStringA((IntToString((unsigned int)this) + ": Received " + IntToString(recvResult) + " bytes\n").c_str()); #endif m_dataEnd += recvResult; if (receiver.EofReceived() || m_dataEnd > m_buf.size() /2) @@ -391,7 +391,7 @@ float NetworkSink::ComputeCurrentSpeed() m_maxObservedSpeed = STDMAX(m_currentSpeed, m_maxObservedSpeed * 0.98f); m_byteCountSinceLastTimerReset = 0; m_speedTimer.StartTimer(); -// OutputDebugString(("max speed: " + IntToString((int)m_maxObservedSpeed) + " current speed: " + IntToString((int)m_currentSpeed) + "\n").c_str()); +// OutputDebugStringA(("max speed: " + IntToString((int)m_maxObservedSpeed) + " current speed: " + IntToString((int)m_currentSpeed) + "\n").c_str()); } return m_currentSpeed; } @@ -497,7 +497,7 @@ lword NetworkSink::DoFlush(unsigned long maxTime, size_t targetSize) unsigned int sendResult = sender.GetSendResult(); #if CRYPTOPP_TRACE_NETWORK - OutputDebugString((IntToString((unsigned int)this) + ": Sent " + IntToString(sendResult) + " bytes\n").c_str()); + OutputDebugStringA((IntToString((unsigned int)this) + ": Sent " + IntToString(sendResult) + " bytes\n").c_str()); #endif m_buffer.Skip(sendResult); totalFlushSize += sendResult; @@ -515,7 +515,7 @@ lword NetworkSink::DoFlush(unsigned long maxTime, size_t targetSize) const byte *block = m_buffer.Spy(contiguousSize); #if CRYPTOPP_TRACE_NETWORK - OutputDebugString((IntToString((unsigned int)this) + ": Sending " + IntToString(contiguousSize) + " bytes\n").c_str()); + OutputDebugStringA((IntToString((unsigned int)this) + ": Sending " + IntToString(contiguousSize) + " bytes\n").c_str()); #endif sender.Send(block, contiguousSize); m_needSendResult = true; diff --git a/wait.cpp b/wait.cpp index c6a74d94..3356a0d0 100644 --- a/wait.cpp +++ b/wait.cpp @@ -373,7 +373,7 @@ bool WaitObjectContainer::Wait(unsigned long milliseconds) if (milliseconds > 0) { unsigned long timeAfterWait = t.ElapsedTime(); - OutputDebugString(("Handles " + IntToString(m_handles.size()) + ", Woke up by " + IntToString(result-WAIT_OBJECT_0) + ", Busied for " + IntToString(timeBeforeWait-lastTime) + " us, Waited for " + IntToString(timeAfterWait-timeBeforeWait) + " us, max " + IntToString(milliseconds) + "ms\n").c_str()); + OutputDebugStringA(("Handles " + IntToString(m_handles.size()) + ", Woke up by " + IntToString(result-WAIT_OBJECT_0) + ", Busied for " + IntToString(timeBeforeWait-lastTime) + " us, Waited for " + IntToString(timeAfterWait-timeBeforeWait) + " us, max " + IntToString(milliseconds) + "ms\n").c_str()); lastTime = timeAfterWait; } #endif