# HG changeset patch # User michi_cc # Date 1282587555 0 # Node ID 4fab5de4b8572bc3b42e3e96207f971ab29e9be2 # Parent 2ff5302eebeefb1ce9640dc0c0619317ce10023a (svn r20598) -Codechange: [Win32] Replace the external x64 asm with a built-in Windows function. diff --git a/projects/openttd_vs100.vcxproj b/projects/openttd_vs100.vcxproj --- a/projects/openttd_vs100.vcxproj +++ b/projects/openttd_vs100.vcxproj @@ -47,9 +47,6 @@ true - - - @@ -1090,17 +1087,6 @@ - - true - 1 - true - true - 1 - true - Document - - - @@ -1119,7 +1105,4 @@ - - - diff --git a/projects/openttd_vs100.vcxproj.filters b/projects/openttd_vs100.vcxproj.filters --- a/projects/openttd_vs100.vcxproj.filters +++ b/projects/openttd_vs100.vcxproj.filters @@ -91,10 +91,6 @@ {c76ff9f1-1e62-46d8-8d55-000000000029} - - {d55d5f1f-aa07-4839-80d7-5ae158609e61} - asm - @@ -2472,9 +2468,4 @@ - - - 64-bit Specific Files - - diff --git a/projects/openttd_vs100.vcxproj.filters.in b/projects/openttd_vs100.vcxproj.filters.in --- a/projects/openttd_vs100.vcxproj.filters.in +++ b/projects/openttd_vs100.vcxproj.filters.in @@ -2,10 +2,6 @@ !!FILTERS!! - - {d55d5f1f-aa07-4839-80d7-5ae158609e61} - asm - !!FILES!! @@ -14,9 +10,4 @@ - - - 64-bit Specific Files - - diff --git a/projects/openttd_vs100.vcxproj.in b/projects/openttd_vs100.vcxproj.in --- a/projects/openttd_vs100.vcxproj.in +++ b/projects/openttd_vs100.vcxproj.in @@ -47,9 +47,6 @@ true - - - @@ -301,17 +298,6 @@ !!FILES!! - - true - 1 - true - true - 1 - true - Document - - - @@ -330,7 +316,4 @@ - - - diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj --- a/projects/openttd_vs80.vcproj +++ b/projects/openttd_vs80.vcproj @@ -14,11 +14,6 @@ Name="x64" /> - - - - - - - - - - - - - - - - - - - - - - - diff --git a/projects/openttd_vs80.vcproj.in b/projects/openttd_vs80.vcproj.in --- a/projects/openttd_vs80.vcproj.in +++ b/projects/openttd_vs80.vcproj.in @@ -14,11 +14,6 @@ Name="x64" /> - - - - - - - !!FILES!! - - - - - - - - - - - - - - - - diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj --- a/projects/openttd_vs90.vcproj +++ b/projects/openttd_vs90.vcproj @@ -15,11 +15,6 @@ Name="x64" /> - - - - - - - - - - - - - - - - - - - - - - - diff --git a/projects/openttd_vs90.vcproj.in b/projects/openttd_vs90.vcproj.in --- a/projects/openttd_vs90.vcproj.in +++ b/projects/openttd_vs90.vcproj.in @@ -15,11 +15,6 @@ Name="x64" /> - - - - - - - !!FILES!! - - - - - - - - - - - - - - - - diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp --- a/src/os/windows/crashlog_win.cpp +++ b/src/os/windows/crashlog_win.cpp @@ -10,6 +10,12 @@ /** @file crashlog_win.cpp Implementation of a crashlogger for Windows */ #include "../../stdafx.h" +#if defined(_MSC_VER) && defined(_M_AMD64) +/* Redefine WinNT version to get RtlCaptureContext prototype. */ +#undef _WIN32_WINNT +#undef NTDDI_VERSION +#define _WIN32_WINNT _WIN32_WINNT_WINXP +#endif /* defined(_MSC_VER) && defined(_M_AMD64) */ #include "../../crashlog.h" #include "win32.h" #include "../../core/alloc_func.hpp" @@ -408,10 +414,6 @@ return EXCEPTION_EXECUTE_HANDLER; } -#ifdef _M_AMD64 -extern "C" void *_get_safe_esp(); -#endif - static void CDECL CustomAbort(int signal) { RaiseException(0xE1212012, 0, 0, NULL); @@ -421,7 +423,14 @@ { #if defined(_MSC_VER) #ifdef _M_AMD64 - _safe_esp = _get_safe_esp(); + CONTEXT ctx; + RtlCaptureContext(&ctx); + + /* The stack pointer for AMD64 must always be 16-byte aligned inside a + * function. As we are simulating a function call with the safe ESP value, + * we need to subtract 8 for the imaginary return address otherwise stack + * alignment would be wrong in the called function. */ + _safe_esp = (void *)(ctx.Rsp - 8); #else _asm { mov _safe_esp, esp diff --git a/src/os/windows/masm64.rules b/src/os/windows/masm64.rules deleted file mode 100644 --- a/src/os/windows/masm64.rules +++ /dev/null @@ -1,266 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/os/windows/win64.asm b/src/os/windows/win64.asm deleted file mode 100644 --- a/src/os/windows/win64.asm +++ /dev/null @@ -1,8 +0,0 @@ - .CODE - -PUBLIC _get_safe_esp -_get_safe_esp: - MOV RAX,RSP - RET - - END