diff options
| author | JosJuice <josjuice@gmail.com> | 2017-04-14 12:53:32 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2017-05-20 09:35:53 +0200 |
| commit | 4b4cf509f8746a8c4afb73a2a2de165179201db6 (patch) | |
| tree | e85c7ac4504b2b13d165121ffe15884c180dc11f /Source/Core/Common/MemArena.cpp | |
| parent | 89535468eb178af2a0dcfafff7b47bbbc3c0e2e1 (diff) | |
Remove code for only allocating low memory
This is unnecessary when we have position-independent code.
Diffstat (limited to 'Source/Core/Common/MemArena.cpp')
| -rw-r--r-- | Source/Core/Common/MemArena.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/Source/Core/Common/MemArena.cpp b/Source/Core/Common/MemArena.cpp index ce6cc2662e..cff92ce794 100644 --- a/Source/Core/Common/MemArena.cpp +++ b/Source/Core/Common/MemArena.cpp @@ -7,6 +7,7 @@ #include <set> #include <string> +#include "Common/CommonFuncs.h" #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" #include "Common/MemArena.h" @@ -125,19 +126,22 @@ void MemArena::ReleaseView(void* view, size_t size) u8* MemArena::FindMemoryBase() { -#if _ARCH_64 +#if _ARCH_32 + const size_t memory_size = 0x31000000; +#else + const size_t memory_size = 0x400000000; +#endif + #ifdef _WIN32 - // 64 bit - u8* base = (u8*)VirtualAlloc(0, 0x400000000, MEM_RESERVE, PAGE_READWRITE); + u8* base = static_cast<u8*>(VirtualAlloc(nullptr, memory_size, MEM_RESERVE, PAGE_READWRITE)); + if (!base) + { + PanicAlert("Failed to map enough memory space: %s", GetLastErrorMsg().c_str()); + return nullptr; + } VirtualFree(base, 0, MEM_RELEASE); return base; #else - // Very precarious - mmap cannot return an error when trying to map already used pages. - // This makes the Windows approach above unusable on Linux, so we will simply pray... - return reinterpret_cast<u8*>(0x2300000000ULL); -#endif - -#else // 32 bit #ifdef ANDROID // Android 4.3 changed how mmap works. // if we map it private and then munmap it, we can't use the base returned. @@ -146,14 +150,13 @@ u8* MemArena::FindMemoryBase() #else const int flags = MAP_ANON | MAP_PRIVATE; #endif - const u32 MemSize = 0x31000000; - void* base = mmap(0, MemSize, PROT_NONE, flags, -1, 0); + void* base = mmap(nullptr, memory_size, PROT_NONE, flags, -1, 0); if (base == MAP_FAILED) { - PanicAlert("Failed to map 1 GB of memory space: %s", strerror(errno)); - return 0; + PanicAlert("Failed to map enough memory space: %s", GetLastErrorMsg().c_str()); + return nullptr; } - munmap(base, MemSize); + munmap(base, memory_size); return static_cast<u8*>(base); #endif } |
