From a7e8b67c7c96d7e76b495ce2bed9f5f423870522 Mon Sep 17 00:00:00 2001 From: michi_cc Date: Mon, 23 Aug 2010 18:19:15 +0000 Subject: [PATCH] (svn r20598) -Codechange: [Win32] Replace the external x64 asm with a built-in Windows function. --- projects/openttd_vs100.vcxproj | 17 -- projects/openttd_vs100.vcxproj.filters | 9 - projects/openttd_vs100.vcxproj.filters.in | 9 - projects/openttd_vs100.vcxproj.in | 17 -- projects/openttd_vs80.vcproj | 60 ----- projects/openttd_vs80.vcproj.in | 60 ----- projects/openttd_vs90.vcproj | 60 ----- projects/openttd_vs90.vcproj.in | 60 ----- src/os/windows/crashlog_win.cpp | 19 +- src/os/windows/masm64.rules | 266 ---------------------- src/os/windows/win64.asm | 8 - 11 files changed, 14 insertions(+), 571 deletions(-) delete mode 100644 src/os/windows/masm64.rules delete mode 100644 src/os/windows/win64.asm diff --git a/projects/openttd_vs100.vcxproj b/projects/openttd_vs100.vcxproj index 83513534a0..7a9bc24389 100644 --- a/projects/openttd_vs100.vcxproj +++ b/projects/openttd_vs100.vcxproj @@ -47,9 +47,6 @@ true - - - @@ -1089,17 +1086,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 index d9b231c38b..35e15d8cf3 100644 --- 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 index 832a1e6b99..cda491072c 100644 --- 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 index 352dd6afab..d4b510128f 100644 --- a/projects/openttd_vs100.vcxproj.in +++ b/projects/openttd_vs100.vcxproj.in @@ -47,9 +47,6 @@ true - - - @@ -300,17 +297,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 index 93b08d5dd2..6a30e22d62 100644 --- a/projects/openttd_vs80.vcproj +++ b/projects/openttd_vs80.vcproj @@ -14,11 +14,6 @@ Name="x64" /> - - - - @@ -150,9 +142,6 @@ - @@ -249,9 +238,6 @@ - @@ -363,9 +349,6 @@ - @@ -3732,49 +3715,6 @@ > - - - - - - - - - - - - - - - - diff --git a/projects/openttd_vs80.vcproj.in b/projects/openttd_vs80.vcproj.in index 8870bfda1c..227ab0735b 100644 --- a/projects/openttd_vs80.vcproj.in +++ b/projects/openttd_vs80.vcproj.in @@ -14,11 +14,6 @@ Name="x64" /> - - - - @@ -150,9 +142,6 @@ - @@ -249,9 +238,6 @@ - @@ -363,9 +349,6 @@ - @@ -453,49 +436,6 @@ !!FILES!! - - - - - - - - - - - - - - - - diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj index 4bc2370f5b..c5abe750c0 100644 --- a/projects/openttd_vs90.vcproj +++ b/projects/openttd_vs90.vcproj @@ -15,11 +15,6 @@ Name="x64" /> - - - - @@ -149,9 +141,6 @@ - @@ -247,9 +236,6 @@ - @@ -360,9 +346,6 @@ - @@ -3729,49 +3712,6 @@ > - - - - - - - - - - - - - - - - diff --git a/projects/openttd_vs90.vcproj.in b/projects/openttd_vs90.vcproj.in index ef1447a879..e5d4da7c2c 100644 --- a/projects/openttd_vs90.vcproj.in +++ b/projects/openttd_vs90.vcproj.in @@ -15,11 +15,6 @@ Name="x64" /> - - - - @@ -149,9 +141,6 @@ - @@ -247,9 +236,6 @@ - @@ -360,9 +346,6 @@ - @@ -450,49 +433,6 @@ !!FILES!! - - - - - - - - - - - - - - - - diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp index 4bdb984f81..11791528bc 100644 --- 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 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep) 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 @@ static void CDECL CustomAbort(int signal) { #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 index 62e6e0f8b8..0000000000 --- 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 index d95bc38980..0000000000 --- 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