summaryrefslogtreecommitdiff
path: root/src/common/mem_arena.cpp
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-05-07 18:17:33 -0300
committerGravatar Yuri Kunde Schlesner2015-05-07 18:22:36 -0300
commitfae5933ad614ca8c2559f499ebe16b518594cca3 (patch)
tree352d4e078789f31408c8f8658ba84cc03c08cbcf /src/common/mem_arena.cpp
parentMerge pull request #721 from yuriks/more-cleanups (diff)
downloadyuzu-fae5933ad614ca8c2559f499ebe16b518594cca3.tar.gz
yuzu-fae5933ad614ca8c2559f499ebe16b518594cca3.tar.xz
yuzu-fae5933ad614ca8c2559f499ebe16b518594cca3.zip
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.
Diffstat (limited to 'src/common/mem_arena.cpp')
-rw-r--r--src/common/mem_arena.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/common/mem_arena.cpp b/src/common/mem_arena.cpp
index f233d4a3a..689fdb92b 100644
--- a/src/common/mem_arena.cpp
+++ b/src/common/mem_arena.cpp
@@ -20,6 +20,7 @@
20#include "common/logging/log.h" 20#include "common/logging/log.h"
21#include "common/mem_arena.h" 21#include "common/mem_arena.h"
22#include "common/memory_util.h" 22#include "common/memory_util.h"
23#include "common/platform.h"
23#include "common/string_util.h" 24#include "common/string_util.h"
24 25
25#ifndef _WIN32 26#ifndef _WIN32
@@ -198,7 +199,7 @@ void MemArena::ReleaseView(void* view, size_t size)
198 199
199u8* MemArena::Find4GBBase() 200u8* MemArena::Find4GBBase()
200{ 201{
201#ifdef _M_X64 202#if EMU_ARCH_BITS == 64
202#ifdef _WIN32 203#ifdef _WIN32
203 // 64 bit 204 // 64 bit
204 u8* base = (u8*)VirtualAlloc(0, 0xE1000000, MEM_RESERVE, PAGE_READWRITE); 205 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
269 if (!*view.out_ptr_low) 270 if (!*view.out_ptr_low)
270 goto bail; 271 goto bail;
271 } 272 }
272#ifdef _M_X64 273#if EMU_ARCH_BITS == 64
273 *view.out_ptr = (u8*)arena->CreateView( 274 *view.out_ptr = (u8*)arena->CreateView(
274 position, view.size, base + view.virtual_address); 275 position, view.size, base + view.virtual_address);
275#else 276#else
@@ -305,7 +306,7 @@ bail:
305 } 306 }
306 if (*views[j].out_ptr) 307 if (*views[j].out_ptr)
307 { 308 {
308#ifdef _M_X64 309#if EMU_ARCH_BITS == 64
309 arena->ReleaseView(*views[j].out_ptr, views[j].size); 310 arena->ReleaseView(*views[j].out_ptr, views[j].size);
310#else 311#else
311 if (!(views[j].flags & MV_MIRROR_PREVIOUS)) 312 if (!(views[j].flags & MV_MIRROR_PREVIOUS))
@@ -336,7 +337,7 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
336 arena->GrabLowMemSpace(total_mem); 337 arena->GrabLowMemSpace(total_mem);
337 338
338 // Now, create views in high memory where there's plenty of space. 339 // Now, create views in high memory where there's plenty of space.
339#ifdef _M_X64 340#if EMU_ARCH_BITS == 64
340 u8 *base = MemArena::Find4GBBase(); 341 u8 *base = MemArena::Find4GBBase();
341 // This really shouldn't fail - in 64-bit, there will always be enough 342 // This really shouldn't fail - in 64-bit, there will always be enough
342 // address space. 343 // address space.