From 6b411c63c9b084e99a3711da10f93225ff93cc85 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Mon, 5 Jan 2015 16:30:02 +0000 Subject: Common: Remove dead platform #ifdefs to make the code more readable. Symbian, Xbox, Blackberry and iOS got removed. FreeBSD and Android kept due to them potentially being able to run Citra in the future. The iOS specific part also got removed from PPSSPP in order to fix a bug there. --- src/common/mem_arena.cpp | 84 ++---------------------------------------------- 1 file changed, 2 insertions(+), 82 deletions(-) (limited to 'src/common/mem_arena.cpp') diff --git a/src/common/mem_arena.cpp b/src/common/mem_arena.cpp index 9904d2472..a20361d6f 100644 --- a/src/common/mem_arena.cpp +++ b/src/common/mem_arena.cpp @@ -29,10 +29,6 @@ #endif #endif -#ifdef IOS -void* globalbase = nullptr; -#endif - #ifdef ANDROID // Hopefully this ABI will never change... @@ -95,7 +91,7 @@ int ashmem_unpin_region(int fd, size_t offset, size_t len) #endif // Android -#if defined(_WIN32) && !defined(_XBOX) +#if defined(_WIN32) SYSTEM_INFO sysInfo; #endif @@ -103,11 +99,7 @@ SYSTEM_INFO sysInfo; // Windows mappings need to be on 64K boundaries, due to Alpha legacy. #ifdef _WIN32 size_t roundup(size_t x) { -#ifndef _XBOX int gran = sysInfo.dwAllocationGranularity ? sysInfo.dwAllocationGranularity : 0x10000; -#else - int gran = 0x10000; // 64k in 360 -#endif return (x + gran - 1) & ~(gran - 1); } #else @@ -120,10 +112,8 @@ size_t roundup(size_t x) { void MemArena::GrabLowMemSpace(size_t size) { #ifdef _WIN32 -#ifndef _XBOX hMemoryMapping = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, (DWORD)(size), nullptr); GetSystemInfo(&sysInfo); -#endif #elif defined(ANDROID) // Use ashmem so we don't have to allocate a file on disk! fd = ashmem_create_region("PPSSPP_RAM", size); @@ -163,9 +153,6 @@ void MemArena::ReleaseSpace() #ifdef _WIN32 CloseHandle(hMemoryMapping); hMemoryMapping = 0; -#elif defined(__SYMBIAN32__) - memmap->Close(); - delete memmap; #else close(fd); #endif @@ -175,22 +162,13 @@ void MemArena::ReleaseSpace() void *MemArena::CreateView(s64 offset, size_t size, void *base) { #ifdef _WIN32 -#ifdef _XBOX - size = roundup(size); - // use 64kb pages - void * ptr = VirtualAlloc(nullptr, size, MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE); - return ptr; -#else size = roundup(size); void *ptr = MapViewOfFileEx(hMemoryMapping, FILE_MAP_ALL_ACCESS, 0, (DWORD)((u64)offset), size, base); return ptr; -#endif #else void *retval = mmap(base, size, PROT_READ | PROT_WRITE, MAP_SHARED | // Do not sync memory to underlying file. Linux has this by default. -#ifdef BLACKBERRY - MAP_NOSYNCFILE | -#elif defined(__FreeBSD__) +#ifdef __FreeBSD__ MAP_NOSYNC | #endif ((base == nullptr) ? 0 : MAP_FIXED), fd, offset); @@ -208,17 +186,12 @@ void *MemArena::CreateView(s64 offset, size_t size, void *base) void MemArena::ReleaseView(void* view, size_t size) { #ifdef _WIN32 -#ifndef _XBOX UnmapViewOfFile(view); -#endif -#elif defined(__SYMBIAN32__) - memmap->Decommit(((int)view - (int)memmap->Base()) & 0x3FFFFFFF, size); #else munmap(view, size); #endif } -#ifndef __SYMBIAN32__ u8* MemArena::Find4GBBase() { #ifdef _M_X64 @@ -241,20 +214,6 @@ u8* MemArena::Find4GBBase() VirtualFree(base, 0, MEM_RELEASE); } return base; -#else -#ifdef IOS - void* base = nullptr; - if (globalbase == nullptr){ - base = mmap(0, 0x08000000, PROT_READ | PROT_WRITE, - MAP_ANON | MAP_SHARED, -1, 0); - if (base == MAP_FAILED) { - PanicAlert("Failed to map 128 MB of memory space: %s", strerror(errno)); - return 0; - } - munmap(base, 0x08000000); - globalbase = base; - } - else{ base = globalbase; } #else void* base = mmap(0, 0x10000000, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0); @@ -263,12 +222,10 @@ u8* MemArena::Find4GBBase() return 0; } munmap(base, 0x10000000); -#endif return static_cast(base); #endif #endif } -#endif // yeah, this could also be done in like two bitwise ops... @@ -284,10 +241,6 @@ static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32 size_t position = 0; size_t last_position = 0; -#if defined(_XBOX) - void *ptr; -#endif - // Zero all the pointers to be sure. for (int i = 0; i < num_views; i++) { @@ -308,18 +261,6 @@ static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32 position = last_position; } else { -#ifdef __SYMBIAN32__ - *(view.out_ptr_low) = (u8*)((int)arena->memmap->Base() + view.virtual_address); - arena->memmap->Commit(view.virtual_address & 0x3FFFFFFF, view.size); - } - *(view.out_ptr) = (u8*)((int)arena->memmap->Base() + view.virtual_address & 0x3FFFFFFF); -#elif defined(_XBOX) - *(view.out_ptr_low) = (u8*)(base + view.virtual_address); - //arena->memmap->Commit(view.virtual_address & 0x3FFFFFFF, view.size); - ptr = VirtualAlloc(base + (view.virtual_address & 0x3FFFFFFF), view.size, MEM_COMMIT, PAGE_READWRITE); - } - *(view.out_ptr) = (u8*)base + (view.virtual_address & 0x3FFFFFFF); -#else *(view.out_ptr_low) = (u8*)arena->CreateView(position, view.size); if (!*view.out_ptr_low) goto bail; @@ -340,7 +281,6 @@ static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32 } #endif -#endif last_position = position; position += roundup(view.size); } @@ -389,9 +329,7 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena total_mem += roundup(views[i].size); } // Grab some pagefile backed memory out of the void ... -#ifndef __SYMBIAN32__ arena->GrabLowMemSpace(total_mem); -#endif // Now, create views in high memory where there's plenty of space. #ifdef _M_X64 @@ -403,15 +341,6 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena PanicAlert("MemoryMap_Setup: Failed finding a memory base."); return 0; } -#elif defined(_XBOX) - // Reserve 256MB - u8 *base = (u8*)VirtualAlloc(0, 0x10000000, MEM_RESERVE | MEM_LARGE_PAGES, PAGE_READWRITE); - if (!Memory_TryBase(base, views, num_views, flags, arena)) - { - PanicAlert("MemoryMap_Setup: Failed finding a memory base."); - exit(0); - return 0; - } #elif defined(_WIN32) // Try a whole range of possible bases. Return once we got a valid one. u32 max_base_addr = 0x7FFF0000 - 0x10000000; @@ -428,15 +357,6 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena break; } } -#elif defined(__SYMBIAN32__) - arena->memmap = new RChunk(); - arena->memmap->CreateDisconnectedLocal(0, 0, 0x10000000); - if (!Memory_TryBase(arena->memmap->Base(), views, num_views, flags, arena)) - { - PanicAlert("MemoryMap_Setup: Failed finding a memory base."); - return 0; - } - u8* base = arena->memmap->Base(); #else // Linux32 is fine with the x64 method, although limited to 32-bit with no automirrors. u8 *base = MemArena::Find4GBBase(); -- cgit v1.2.3