From 0e11b8777ffeeb68e4e40d51b9d8ac46046058d6 Mon Sep 17 00:00:00 2001 From: Andrew Nelless Date: Wed, 13 Dec 2017 16:18:22 +0000 Subject: [PATCH] Remove scary memcpy hack --- src/lib/synwinhk/synwinhk.cpp | 70 ----------------------------------- 1 file changed, 70 deletions(-) diff --git a/src/lib/synwinhk/synwinhk.cpp b/src/lib/synwinhk/synwinhk.cpp index 178420e2..089f6777 100644 --- a/src/lib/synwinhk/synwinhk.cpp +++ b/src/lib/synwinhk/synwinhk.cpp @@ -27,9 +27,6 @@ #else #define assert(_X_) __noop() #endif -// VS2005 is a bit more smart than VC6 and optimize simple copy loop to -// intrinsic memcpy. -#pragma function(memcpy) // // debugging compile flag. when not zero the server doesn't grab @@ -627,79 +624,12 @@ DllMain(HINSTANCE instance, DWORD reason, LPVOID) extern "C" { -// VS2005 hack to not link with the CRT -#if _MSC_VER >= 1400 BOOL WINAPI _DllMainCRTStartup( HINSTANCE instance, DWORD reason, LPVOID lpreserved) { return DllMain(instance, reason, lpreserved); } -// VS2005 is a bit more bright than VC6 and optimize simple copy loop to -// intrinsic memcpy. -void * __cdecl memcpy(void * _Dst, const void * _Src, size_t _MaxCount) -{ - void * _DstBackup = _Dst; - switch (_MaxCount & 3) { - case 3: - ((char*)_Dst)[0] = ((char*)_Src)[0]; - ++(char*&)_Dst; - ++(char*&)_Src; - --_MaxCount; - case 2: - ((char*)_Dst)[0] = ((char*)_Src)[0]; - ++(char*&)_Dst; - ++(char*&)_Src; - --_MaxCount; - case 1: - ((char*)_Dst)[0] = ((char*)_Src)[0]; - ++(char*&)_Dst; - ++(char*&)_Src; - --_MaxCount; - break; - case 0: - break; - - default: - __assume(0); - break; - } - - // I think it's faster on intel to deference than modify the pointer. - const size_t max = _MaxCount / sizeof(UINT_PTR); - for (size_t i = 0; i < max; ++i) { - ((UINT_PTR*)_Dst)[i] = ((UINT_PTR*)_Src)[i]; - } - - (UINT_PTR*&)_Dst += max; - (UINT_PTR*&)_Src += max; - - switch (_MaxCount & 3) { - case 3: - ((char*)_Dst)[0] = ((char*)_Src)[0]; - ++(char*&)_Dst; - ++(char*&)_Src; - case 2: - ((char*)_Dst)[0] = ((char*)_Src)[0]; - ++(char*&)_Dst; - ++(char*&)_Src; - case 1: - ((char*)_Dst)[0] = ((char*)_Src)[0]; - ++(char*&)_Dst; - ++(char*&)_Src; - break; - case 0: - break; - - default: - __assume(0); - break; - } - - return _DstBackup; -} -#endif - int init(DWORD threadID, BOOL isPrimary) {