From ac366022f40382d39fcaaff6d66f038886c76414 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Thu, 7 Aug 2008 19:20:51 +0000 Subject: [PATCH] Fix linux build and a crash. hrm, how did it work before... git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@146 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/Common.cpp | 2 +- Source/Core/Common/Src/Common.h | 2 +- Source/Core/Common/Src/StringUtil.cpp | 2 +- Source/Core/Common/Src/x64Emitter.cpp | 10 +++++++--- Source/Core/VideoCommon/Src/XFMemory.h | 3 ++- Source/Plugins/Plugin_VideoOGL/Src/Globals.h | 3 ++- Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp | 2 +- Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.h | 1 + 8 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Source/Core/Common/Src/Common.cpp b/Source/Core/Common/Src/Common.cpp index 0cce42c703..704a3d846d 100644 --- a/Source/Core/Common/Src/Common.cpp +++ b/Source/Core/Common/Src/Common.cpp @@ -22,7 +22,7 @@ namespace { -PanicAlertHandler panic_handler = 0; + static PanicAlertHandler panic_handler = 0; } void RegisterPanicAlertHandler(PanicAlertHandler handler) diff --git a/Source/Core/Common/Src/Common.h b/Source/Core/Common/Src/Common.h index 771caec106..ddee157b53 100644 --- a/Source/Core/Common/Src/Common.h +++ b/Source/Core/Common/Src/Common.h @@ -46,7 +46,7 @@ extern "C" { #define MAX_PATH 260 #define WEAK_SYMBOL __attribute__((weak)) #define stricmp strcasecmp -#define Crash() {__builtin_trap();} +#define Crash() {asm ("int $3");} // #ifdef 64bit // #define _M_IX86 // #else diff --git a/Source/Core/Common/Src/StringUtil.cpp b/Source/Core/Common/Src/StringUtil.cpp index 882a811077..03bdff88d5 100644 --- a/Source/Core/Common/Src/StringUtil.cpp +++ b/Source/Core/Common/Src/StringUtil.cpp @@ -162,7 +162,7 @@ void StringFromFormatV(std::string* out, const char* format, va_list args) while (writtenCount < 0) { - delete[] buf; + delete [] buf; buf = new char[newSize + 1]; writtenCount = vsnprintf(buf, newSize, format, args); newSize *= 2; diff --git a/Source/Core/Common/Src/x64Emitter.cpp b/Source/Core/Common/Src/x64Emitter.cpp index 7915c2e05a..bd2042a7ce 100644 --- a/Source/Core/Common/Src/x64Emitter.cpp +++ b/Source/Core/Common/Src/x64Emitter.cpp @@ -23,6 +23,8 @@ namespace Gen { static u8 *code; static bool mode32 = false; + static bool enableBranchHints = false; + void SetCodePtr(u8 *ptr) { @@ -350,8 +352,6 @@ namespace Gen return branch; } - static bool enableBranchHints = false; - // These are to be used with Jcc only. // Found in intel manual 2A // These do not really make a difference for any current X86 CPU, @@ -1221,10 +1221,12 @@ namespace Gen #ifdef _M_IX86 // Don't really need to do anything #elif defined(_M_X64) +#if _WIN32 int stacksize = ((maxCallParams+1)&~1)*8 + 8; // Set up a stack frame so that we can call functions // TODO: use maxCallParams SUB(64, R(RSP), Imm8(stacksize)); +#endif #else #error Arch not supported #endif @@ -1234,15 +1236,17 @@ namespace Gen #ifdef _M_IX86 RET(); #elif defined(_M_X64) +#ifdef _WIN32 int stacksize = ((maxCallParams+1)&~1)*8 + 8; ADD(64, R(RSP), Imm8(stacksize)); +#endif RET(); #else #error Arch not supported #endif } - } + } // namespace // helper routines for setting pointers diff --git a/Source/Core/VideoCommon/Src/XFMemory.h b/Source/Core/VideoCommon/Src/XFMemory.h index 49b3e6fdc3..caea564080 100644 --- a/Source/Core/VideoCommon/Src/XFMemory.h +++ b/Source/Core/VideoCommon/Src/XFMemory.h @@ -198,4 +198,5 @@ struct Viewport extern XFRegisters xfregs; extern u32 xfmem[XFMEM_SIZE]; -#endif \ No newline at end of file +#endif + diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h index 629dcfc188..b66241c49a 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h @@ -99,13 +99,14 @@ struct RECT #endif // several macros +// PLEASE DO NOT USE THE FOLLOWING SAFE* +// They only encourage sloppy coding, and hides bugs. #ifndef SAFE_DELETE_ARRAY #define SAFE_DELETE_ARRAY(x) if( (x) != NULL ) { delete[] (x); (x) = NULL; } #endif #ifndef SAFE_RELEASE #define SAFE_RELEASE(x) if( (x) != NULL ) { (x)->Release(); (x) = NULL; } #endif - #define SAFE_RELEASE_CGPROG(x) { if( (x) != NULL ) { cgDestroyProgram(x); x = NULL; } } #define SAFE_RELEASE_PROG(x) { if( (x) != 0 ) { glDeleteProgramsARB(1, &(x)); x = 0; } } #define SAFE_RELEASE_TEX(x) { if( (x) != 0 ) { glDeleteTextures(1, &(x)); x = 0; } } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp index 98cd90cce7..85b18f8fb0 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp @@ -80,7 +80,7 @@ void TextureMngr::TCacheEntry::SetTextureParameters(TexMode0& newmode) void TextureMngr::TCacheEntry::Destroy() { - SAFE_RELEASE_TEX((GLuint)texture); + SAFE_RELEASE_TEX(texture); } void TextureMngr::Init() diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.h b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.h index 54c57d4122..f9788d060e 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.h @@ -85,3 +85,4 @@ public: }; #endif +