From 936bfbd86770db16ffbea632b77727c4a6b529a5 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Fri, 22 Aug 2008 10:38:53 +0000 Subject: [PATCH] Implemented Find4GBBase() on 32-bit non-Windows platforms. I am not sure the pointer acquired is any good though. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@266 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/MemArena.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Source/Core/Common/Src/MemArena.cpp b/Source/Core/Common/Src/MemArena.cpp index 6753ebb851..e6728a3ee0 100644 --- a/Source/Core/Common/Src/MemArena.cpp +++ b/Source/Core/Common/Src/MemArena.cpp @@ -15,6 +15,9 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ +#include "Common.h" +#include "MemArena.h" + #ifdef _WIN32 #include #else @@ -24,9 +27,10 @@ #include #endif -#include "Common.h" -#include "MemArena.h" - +#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) +#define MAP_ANONYMOUS MAP_ANON +#endif + const char* ram_temp_file = "/tmp/gc_mem.tmp"; @@ -118,12 +122,17 @@ u64 MemArena::Find4GBBase() #else // 32 bit +#ifdef _WIN32 // The highest thing in any 1GB section of memory space is the locked cache. We only need to fit it. u8* base = (u8*)VirtualAlloc(0, 0x31000000, MEM_RESERVE, PAGE_READWRITE); if (base) { VirtualFree(base, 0, MEM_RELEASE); - } + } return((u64)base); +#else + void* base = mmap(0, 0x31000000, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, 0, 0); + munmap(base, 0x31000000); + return reinterpret_cast(base); +#endif #endif - }