From fae5933ad614ca8c2559f499ebe16b518594cca3 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Thu, 7 May 2015 18:17:33 -0300 Subject: Common: Add proper macros to test for architecture pointer size The old system of just defining macros available in some other platform was susceptible to silently using the wrong code if you forgot to include a particular header. This fixes a crash on non-Windows platforms introduced by e1fbac3ca13d37d2625c11d30cfdece4327b446b. --- src/common/mem_arena.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/common/mem_arena.cpp') diff --git a/src/common/mem_arena.cpp b/src/common/mem_arena.cpp index f233d4a3..689fdb92 100644 --- a/src/common/mem_arena.cpp +++ b/src/common/mem_arena.cpp @@ -20,6 +20,7 @@ #include "common/logging/log.h" #include "common/mem_arena.h" #include "common/memory_util.h" +#include "common/platform.h" #include "common/string_util.h" #ifndef _WIN32 @@ -198,7 +199,7 @@ void MemArena::ReleaseView(void* view, size_t size) u8* MemArena::Find4GBBase() { -#ifdef _M_X64 +#if EMU_ARCH_BITS == 64 #ifdef _WIN32 // 64 bit u8* base = (u8*)VirtualAlloc(0, 0xE1000000, MEM_RESERVE, PAGE_READWRITE); @@ -269,7 +270,7 @@ static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32 if (!*view.out_ptr_low) goto bail; } -#ifdef _M_X64 +#if EMU_ARCH_BITS == 64 *view.out_ptr = (u8*)arena->CreateView( position, view.size, base + view.virtual_address); #else @@ -305,7 +306,7 @@ bail: } if (*views[j].out_ptr) { -#ifdef _M_X64 +#if EMU_ARCH_BITS == 64 arena->ReleaseView(*views[j].out_ptr, views[j].size); #else if (!(views[j].flags & MV_MIRROR_PREVIOUS)) @@ -336,7 +337,7 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena arena->GrabLowMemSpace(total_mem); // Now, create views in high memory where there's plenty of space. -#ifdef _M_X64 +#if EMU_ARCH_BITS == 64 u8 *base = MemArena::Find4GBBase(); // This really shouldn't fail - in 64-bit, there will always be enough // address space. -- cgit v1.2.3