From 1f6612067123230c017acf4703dc2ea5c6634b3a Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Wed, 17 Sep 2008 08:08:22 +0000 Subject: [PATCH] 32-bit Linux fix: check result of mmap(): if it fails, it returns MAP_FAILED, which is not equal to 0. Also print error message associated with errno. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@554 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/MemArena.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Core/Common/Src/MemArena.cpp b/Source/Core/Common/Src/MemArena.cpp index d2edd76703..6232d156c3 100644 --- a/Source/Core/Common/Src/MemArena.cpp +++ b/Source/Core/Common/Src/MemArena.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #endif #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) @@ -131,6 +133,10 @@ u8* MemArena::Find4GBBase() return base; #else void* base = mmap(0, 0x31000000, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, 0, 0); + if (base == MAP_FAILED) { + PanicAlert("Failed to map 1 GB of memory space: %s", strerror(errno)); + return 0; + } munmap(base, 0x31000000); return static_cast(base); #endif