Merge pull request #421 from linkmauve/remove-dead-platforms
Remove dead platform #ifdefs to make the code more readable.
This commit is contained in:
commit
5217e3f873
5 changed files with 2 additions and 101 deletions
|
@ -154,16 +154,10 @@ enum EMUSTATE_CHANGE
|
||||||
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#ifndef _XBOX
|
|
||||||
inline unsigned long long bswap64(unsigned long long x) { return _byteswap_uint64(x); }
|
inline unsigned long long bswap64(unsigned long long x) { return _byteswap_uint64(x); }
|
||||||
inline unsigned int bswap32(unsigned int x) { return _byteswap_ulong(x); }
|
inline unsigned int bswap32(unsigned int x) { return _byteswap_ulong(x); }
|
||||||
inline unsigned short bswap16(unsigned short x) { return _byteswap_ushort(x); }
|
inline unsigned short bswap16(unsigned short x) { return _byteswap_ushort(x); }
|
||||||
#else
|
#else
|
||||||
inline unsigned long long bswap64(unsigned long long x) { return __loaddoublewordbytereverse(0, &x); }
|
|
||||||
inline unsigned int bswap32(unsigned int x) { return __loadwordbytereverse(0, &x); }
|
|
||||||
inline unsigned short bswap16(unsigned short x) { return __loadshortbytereverse(0, &x); }
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
// TODO: speedup
|
// TODO: speedup
|
||||||
inline unsigned short bswap16(unsigned short x) { return (x << 8) | (x >> 8); }
|
inline unsigned short bswap16(unsigned short x) { return (x << 8) | (x >> 8); }
|
||||||
inline unsigned int bswap32(unsigned int x) { return (x >> 24) | ((x & 0xFF0000) >> 8) | ((x & 0xFF00) << 8) | (x << 24);}
|
inline unsigned int bswap32(unsigned int x) { return (x >> 24) | ((x & 0xFF0000) >> 8) | ((x & 0xFF00) << 8) | (x << 24);}
|
||||||
|
|
|
@ -29,10 +29,6 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef IOS
|
|
||||||
void* globalbase = nullptr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
|
|
||||||
// Hopefully this ABI will never change...
|
// Hopefully this ABI will never change...
|
||||||
|
@ -95,7 +91,7 @@ int ashmem_unpin_region(int fd, size_t offset, size_t len)
|
||||||
#endif // Android
|
#endif // Android
|
||||||
|
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(_XBOX)
|
#if defined(_WIN32)
|
||||||
SYSTEM_INFO sysInfo;
|
SYSTEM_INFO sysInfo;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -103,11 +99,7 @@ SYSTEM_INFO sysInfo;
|
||||||
// Windows mappings need to be on 64K boundaries, due to Alpha legacy.
|
// Windows mappings need to be on 64K boundaries, due to Alpha legacy.
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
size_t roundup(size_t x) {
|
size_t roundup(size_t x) {
|
||||||
#ifndef _XBOX
|
|
||||||
int gran = sysInfo.dwAllocationGranularity ? sysInfo.dwAllocationGranularity : 0x10000;
|
int gran = sysInfo.dwAllocationGranularity ? sysInfo.dwAllocationGranularity : 0x10000;
|
||||||
#else
|
|
||||||
int gran = 0x10000; // 64k in 360
|
|
||||||
#endif
|
|
||||||
return (x + gran - 1) & ~(gran - 1);
|
return (x + gran - 1) & ~(gran - 1);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -120,10 +112,8 @@ size_t roundup(size_t x) {
|
||||||
void MemArena::GrabLowMemSpace(size_t size)
|
void MemArena::GrabLowMemSpace(size_t size)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef _XBOX
|
|
||||||
hMemoryMapping = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, (DWORD)(size), nullptr);
|
hMemoryMapping = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, (DWORD)(size), nullptr);
|
||||||
GetSystemInfo(&sysInfo);
|
GetSystemInfo(&sysInfo);
|
||||||
#endif
|
|
||||||
#elif defined(ANDROID)
|
#elif defined(ANDROID)
|
||||||
// Use ashmem so we don't have to allocate a file on disk!
|
// Use ashmem so we don't have to allocate a file on disk!
|
||||||
fd = ashmem_create_region("PPSSPP_RAM", size);
|
fd = ashmem_create_region("PPSSPP_RAM", size);
|
||||||
|
@ -163,9 +153,6 @@ void MemArena::ReleaseSpace()
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
CloseHandle(hMemoryMapping);
|
CloseHandle(hMemoryMapping);
|
||||||
hMemoryMapping = 0;
|
hMemoryMapping = 0;
|
||||||
#elif defined(__SYMBIAN32__)
|
|
||||||
memmap->Close();
|
|
||||||
delete memmap;
|
|
||||||
#else
|
#else
|
||||||
close(fd);
|
close(fd);
|
||||||
#endif
|
#endif
|
||||||
|
@ -175,22 +162,13 @@ void MemArena::ReleaseSpace()
|
||||||
void *MemArena::CreateView(s64 offset, size_t size, void *base)
|
void *MemArena::CreateView(s64 offset, size_t size, void *base)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#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);
|
size = roundup(size);
|
||||||
void *ptr = MapViewOfFileEx(hMemoryMapping, FILE_MAP_ALL_ACCESS, 0, (DWORD)((u64)offset), size, base);
|
void *ptr = MapViewOfFileEx(hMemoryMapping, FILE_MAP_ALL_ACCESS, 0, (DWORD)((u64)offset), size, base);
|
||||||
return ptr;
|
return ptr;
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
void *retval = mmap(base, size, PROT_READ | PROT_WRITE, MAP_SHARED |
|
void *retval = mmap(base, size, PROT_READ | PROT_WRITE, MAP_SHARED |
|
||||||
// Do not sync memory to underlying file. Linux has this by default.
|
// Do not sync memory to underlying file. Linux has this by default.
|
||||||
#ifdef BLACKBERRY
|
#ifdef __FreeBSD__
|
||||||
MAP_NOSYNCFILE |
|
|
||||||
#elif defined(__FreeBSD__)
|
|
||||||
MAP_NOSYNC |
|
MAP_NOSYNC |
|
||||||
#endif
|
#endif
|
||||||
((base == nullptr) ? 0 : MAP_FIXED), fd, offset);
|
((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)
|
void MemArena::ReleaseView(void* view, size_t size)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef _XBOX
|
|
||||||
UnmapViewOfFile(view);
|
UnmapViewOfFile(view);
|
||||||
#endif
|
|
||||||
#elif defined(__SYMBIAN32__)
|
|
||||||
memmap->Decommit(((int)view - (int)memmap->Base()) & 0x3FFFFFFF, size);
|
|
||||||
#else
|
#else
|
||||||
munmap(view, size);
|
munmap(view, size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __SYMBIAN32__
|
|
||||||
u8* MemArena::Find4GBBase()
|
u8* MemArena::Find4GBBase()
|
||||||
{
|
{
|
||||||
#ifdef _M_X64
|
#ifdef _M_X64
|
||||||
|
@ -241,20 +214,6 @@ u8* MemArena::Find4GBBase()
|
||||||
VirtualFree(base, 0, MEM_RELEASE);
|
VirtualFree(base, 0, MEM_RELEASE);
|
||||||
}
|
}
|
||||||
return base;
|
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
|
#else
|
||||||
void* base = mmap(0, 0x10000000, PROT_READ | PROT_WRITE,
|
void* base = mmap(0, 0x10000000, PROT_READ | PROT_WRITE,
|
||||||
MAP_ANON | MAP_SHARED, -1, 0);
|
MAP_ANON | MAP_SHARED, -1, 0);
|
||||||
|
@ -263,12 +222,10 @@ u8* MemArena::Find4GBBase()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
munmap(base, 0x10000000);
|
munmap(base, 0x10000000);
|
||||||
#endif
|
|
||||||
return static_cast<u8*>(base);
|
return static_cast<u8*>(base);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// yeah, this could also be done in like two bitwise ops...
|
// 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 position = 0;
|
||||||
size_t last_position = 0;
|
size_t last_position = 0;
|
||||||
|
|
||||||
#if defined(_XBOX)
|
|
||||||
void *ptr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Zero all the pointers to be sure.
|
// Zero all the pointers to be sure.
|
||||||
for (int i = 0; i < num_views; i++)
|
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;
|
position = last_position;
|
||||||
}
|
}
|
||||||
else {
|
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);
|
*(view.out_ptr_low) = (u8*)arena->CreateView(position, view.size);
|
||||||
if (!*view.out_ptr_low)
|
if (!*view.out_ptr_low)
|
||||||
goto bail;
|
goto bail;
|
||||||
|
@ -340,7 +281,6 @@ static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
last_position = position;
|
last_position = position;
|
||||||
position += roundup(view.size);
|
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);
|
total_mem += roundup(views[i].size);
|
||||||
}
|
}
|
||||||
// Grab some pagefile backed memory out of the void ...
|
// Grab some pagefile backed memory out of the void ...
|
||||||
#ifndef __SYMBIAN32__
|
|
||||||
arena->GrabLowMemSpace(total_mem);
|
arena->GrabLowMemSpace(total_mem);
|
||||||
#endif
|
|
||||||
|
|
||||||
// Now, create views in high memory where there's plenty of space.
|
// Now, create views in high memory where there's plenty of space.
|
||||||
#ifdef _M_X64
|
#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.");
|
PanicAlert("MemoryMap_Setup: Failed finding a memory base.");
|
||||||
return 0;
|
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)
|
#elif defined(_WIN32)
|
||||||
// Try a whole range of possible bases. Return once we got a valid one.
|
// Try a whole range of possible bases. Return once we got a valid one.
|
||||||
u32 max_base_addr = 0x7FFF0000 - 0x10000000;
|
u32 max_base_addr = 0x7FFF0000 - 0x10000000;
|
||||||
|
@ -428,15 +357,6 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
|
||||||
break;
|
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
|
#else
|
||||||
// Linux32 is fine with the x64 method, although limited to 32-bit with no automirrors.
|
// Linux32 is fine with the x64 method, although limited to 32-bit with no automirrors.
|
||||||
u8 *base = MemArena::Find4GBBase();
|
u8 *base = MemArena::Find4GBBase();
|
||||||
|
|
|
@ -21,10 +21,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __SYMBIAN32__
|
|
||||||
#include <e32std.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
|
|
||||||
// This class lets you create a block of anonymous RAM, and then arbitrarily map views into it.
|
// This class lets you create a block of anonymous RAM, and then arbitrarily map views into it.
|
||||||
|
@ -39,12 +35,8 @@ public:
|
||||||
void *CreateView(s64 offset, size_t size, void *base = 0);
|
void *CreateView(s64 offset, size_t size, void *base = 0);
|
||||||
void ReleaseView(void *view, size_t size);
|
void ReleaseView(void *view, size_t size);
|
||||||
|
|
||||||
#ifdef __SYMBIAN32__
|
|
||||||
RChunk* memmap;
|
|
||||||
#else
|
|
||||||
// This only finds 1 GB in 32-bit
|
// This only finds 1 GB in 32-bit
|
||||||
static u8 *Find4GBBase();
|
static u8 *Find4GBBase();
|
||||||
#endif
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
#define PLATFORM_MACOSX 2
|
#define PLATFORM_MACOSX 2
|
||||||
#define PLATFORM_LINUX 3
|
#define PLATFORM_LINUX 3
|
||||||
#define PLATFORM_ANDROID 4
|
#define PLATFORM_ANDROID 4
|
||||||
#define PLATFORM_IOS 5
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Platform detection
|
// Platform detection
|
||||||
|
|
|
@ -48,11 +48,7 @@
|
||||||
// MSVC
|
// MSVC
|
||||||
#elif defined(_MSC_VER) && !defined(COMMON_BIG_ENDIAN) && !defined(COMMON_LITTLE_ENDIAN)
|
#elif defined(_MSC_VER) && !defined(COMMON_BIG_ENDIAN) && !defined(COMMON_LITTLE_ENDIAN)
|
||||||
|
|
||||||
#ifdef _XBOX
|
|
||||||
#define COMMON_BIG_ENDIAN 1
|
|
||||||
#else
|
|
||||||
#define COMMON_LITTLE_ENDIAN 1
|
#define COMMON_LITTLE_ENDIAN 1
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue