summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Emmanuel Gil Peyrot2015-01-05 16:30:02 +0000
committerGravatar Emmanuel Gil Peyrot2015-01-06 18:57:28 +0000
commit6b411c63c9b084e99a3711da10f93225ff93cc85 (patch)
tree963e9f9afcbc6e052466e4d3a1acee7cd654f8b3 /src
parentMerge pull request #402 from chrisvj/master (diff)
downloadyuzu-6b411c63c9b084e99a3711da10f93225ff93cc85.tar.gz
yuzu-6b411c63c9b084e99a3711da10f93225ff93cc85.tar.xz
yuzu-6b411c63c9b084e99a3711da10f93225ff93cc85.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/common/common.h6
-rw-r--r--src/common/mem_arena.cpp84
-rw-r--r--src/common/mem_arena.h8
-rw-r--r--src/common/platform.h1
-rw-r--r--src/common/swap.h4
5 files changed, 2 insertions, 101 deletions
diff --git a/src/common/common.h b/src/common/common.h
index ba33373ae..bf48ae667 100644
--- a/src/common/common.h
+++ b/src/common/common.h
@@ -154,16 +154,10 @@ enum EMUSTATE_CHANGE
154 154
155 155
156#ifdef _MSC_VER 156#ifdef _MSC_VER
157#ifndef _XBOX
158inline unsigned long long bswap64(unsigned long long x) { return _byteswap_uint64(x); } 157inline unsigned long long bswap64(unsigned long long x) { return _byteswap_uint64(x); }
159inline unsigned int bswap32(unsigned int x) { return _byteswap_ulong(x); } 158inline unsigned int bswap32(unsigned int x) { return _byteswap_ulong(x); }
160inline unsigned short bswap16(unsigned short x) { return _byteswap_ushort(x); } 159inline unsigned short bswap16(unsigned short x) { return _byteswap_ushort(x); }
161#else 160#else
162inline unsigned long long bswap64(unsigned long long x) { return __loaddoublewordbytereverse(0, &x); }
163inline unsigned int bswap32(unsigned int x) { return __loadwordbytereverse(0, &x); }
164inline unsigned short bswap16(unsigned short x) { return __loadshortbytereverse(0, &x); }
165#endif
166#else
167// TODO: speedup 161// TODO: speedup
168inline unsigned short bswap16(unsigned short x) { return (x << 8) | (x >> 8); } 162inline unsigned short bswap16(unsigned short x) { return (x << 8) | (x >> 8); }
169inline unsigned int bswap32(unsigned int x) { return (x >> 24) | ((x & 0xFF0000) >> 8) | ((x & 0xFF00) << 8) | (x << 24);} 163inline unsigned int bswap32(unsigned int x) { return (x >> 24) | ((x & 0xFF0000) >> 8) | ((x & 0xFF00) << 8) | (x << 24);}
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 @@
29#endif 29#endif
30#endif 30#endif
31 31
32#ifdef IOS
33void* globalbase = nullptr;
34#endif
35
36#ifdef ANDROID 32#ifdef ANDROID
37 33
38// Hopefully this ABI will never change... 34// Hopefully this ABI will never change...
@@ -95,7 +91,7 @@ int ashmem_unpin_region(int fd, size_t offset, size_t len)
95#endif // Android 91#endif // Android
96 92
97 93
98#if defined(_WIN32) && !defined(_XBOX) 94#if defined(_WIN32)
99SYSTEM_INFO sysInfo; 95SYSTEM_INFO sysInfo;
100#endif 96#endif
101 97
@@ -103,11 +99,7 @@ SYSTEM_INFO sysInfo;
103// Windows mappings need to be on 64K boundaries, due to Alpha legacy. 99// Windows mappings need to be on 64K boundaries, due to Alpha legacy.
104#ifdef _WIN32 100#ifdef _WIN32
105size_t roundup(size_t x) { 101size_t roundup(size_t x) {
106#ifndef _XBOX
107 int gran = sysInfo.dwAllocationGranularity ? sysInfo.dwAllocationGranularity : 0x10000; 102 int gran = sysInfo.dwAllocationGranularity ? sysInfo.dwAllocationGranularity : 0x10000;
108#else
109 int gran = 0x10000; // 64k in 360
110#endif
111 return (x + gran - 1) & ~(gran - 1); 103 return (x + gran - 1) & ~(gran - 1);
112} 104}
113#else 105#else
@@ -120,10 +112,8 @@ size_t roundup(size_t x) {
120void MemArena::GrabLowMemSpace(size_t size) 112void MemArena::GrabLowMemSpace(size_t size)
121{ 113{
122#ifdef _WIN32 114#ifdef _WIN32
123#ifndef _XBOX
124 hMemoryMapping = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, (DWORD)(size), nullptr); 115 hMemoryMapping = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, (DWORD)(size), nullptr);
125 GetSystemInfo(&sysInfo); 116 GetSystemInfo(&sysInfo);
126#endif
127#elif defined(ANDROID) 117#elif defined(ANDROID)
128 // Use ashmem so we don't have to allocate a file on disk! 118 // Use ashmem so we don't have to allocate a file on disk!
129 fd = ashmem_create_region("PPSSPP_RAM", size); 119 fd = ashmem_create_region("PPSSPP_RAM", size);
@@ -163,9 +153,6 @@ void MemArena::ReleaseSpace()
163#ifdef _WIN32 153#ifdef _WIN32
164 CloseHandle(hMemoryMapping); 154 CloseHandle(hMemoryMapping);
165 hMemoryMapping = 0; 155 hMemoryMapping = 0;
166#elif defined(__SYMBIAN32__)
167 memmap->Close();
168 delete memmap;
169#else 156#else
170 close(fd); 157 close(fd);
171#endif 158#endif
@@ -175,22 +162,13 @@ void MemArena::ReleaseSpace()
175void *MemArena::CreateView(s64 offset, size_t size, void *base) 162void *MemArena::CreateView(s64 offset, size_t size, void *base)
176{ 163{
177#ifdef _WIN32 164#ifdef _WIN32
178#ifdef _XBOX
179 size = roundup(size);
180 // use 64kb pages
181 void * ptr = VirtualAlloc(nullptr, size, MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);
182 return ptr;
183#else
184 size = roundup(size); 165 size = roundup(size);
185 void *ptr = MapViewOfFileEx(hMemoryMapping, FILE_MAP_ALL_ACCESS, 0, (DWORD)((u64)offset), size, base); 166 void *ptr = MapViewOfFileEx(hMemoryMapping, FILE_MAP_ALL_ACCESS, 0, (DWORD)((u64)offset), size, base);
186 return ptr; 167 return ptr;
187#endif
188#else 168#else
189 void *retval = mmap(base, size, PROT_READ | PROT_WRITE, MAP_SHARED | 169 void *retval = mmap(base, size, PROT_READ | PROT_WRITE, MAP_SHARED |
190 // Do not sync memory to underlying file. Linux has this by default. 170 // Do not sync memory to underlying file. Linux has this by default.
191#ifdef BLACKBERRY 171#ifdef __FreeBSD__
192 MAP_NOSYNCFILE |
193#elif defined(__FreeBSD__)
194 MAP_NOSYNC | 172 MAP_NOSYNC |
195#endif 173#endif
196 ((base == nullptr) ? 0 : MAP_FIXED), fd, offset); 174 ((base == nullptr) ? 0 : MAP_FIXED), fd, offset);
@@ -208,17 +186,12 @@ void *MemArena::CreateView(s64 offset, size_t size, void *base)
208void MemArena::ReleaseView(void* view, size_t size) 186void MemArena::ReleaseView(void* view, size_t size)
209{ 187{
210#ifdef _WIN32 188#ifdef _WIN32
211#ifndef _XBOX
212 UnmapViewOfFile(view); 189 UnmapViewOfFile(view);
213#endif
214#elif defined(__SYMBIAN32__)
215 memmap->Decommit(((int)view - (int)memmap->Base()) & 0x3FFFFFFF, size);
216#else 190#else
217 munmap(view, size); 191 munmap(view, size);
218#endif 192#endif
219} 193}
220 194
221#ifndef __SYMBIAN32__
222u8* MemArena::Find4GBBase() 195u8* MemArena::Find4GBBase()
223{ 196{
224#ifdef _M_X64 197#ifdef _M_X64
@@ -242,20 +215,6 @@ u8* MemArena::Find4GBBase()
242 } 215 }
243 return base; 216 return base;
244#else 217#else
245#ifdef IOS
246 void* base = nullptr;
247 if (globalbase == nullptr){
248 base = mmap(0, 0x08000000, PROT_READ | PROT_WRITE,
249 MAP_ANON | MAP_SHARED, -1, 0);
250 if (base == MAP_FAILED) {
251 PanicAlert("Failed to map 128 MB of memory space: %s", strerror(errno));
252 return 0;
253 }
254 munmap(base, 0x08000000);
255 globalbase = base;
256 }
257 else{ base = globalbase; }
258#else
259 void* base = mmap(0, 0x10000000, PROT_READ | PROT_WRITE, 218 void* base = mmap(0, 0x10000000, PROT_READ | PROT_WRITE,
260 MAP_ANON | MAP_SHARED, -1, 0); 219 MAP_ANON | MAP_SHARED, -1, 0);
261 if (base == MAP_FAILED) { 220 if (base == MAP_FAILED) {
@@ -263,12 +222,10 @@ u8* MemArena::Find4GBBase()
263 return 0; 222 return 0;
264 } 223 }
265 munmap(base, 0x10000000); 224 munmap(base, 0x10000000);
266#endif
267 return static_cast<u8*>(base); 225 return static_cast<u8*>(base);
268#endif 226#endif
269#endif 227#endif
270} 228}
271#endif
272 229
273 230
274// yeah, this could also be done in like two bitwise ops... 231// 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
284 size_t position = 0; 241 size_t position = 0;
285 size_t last_position = 0; 242 size_t last_position = 0;
286 243
287#if defined(_XBOX)
288 void *ptr;
289#endif
290
291 // Zero all the pointers to be sure. 244 // Zero all the pointers to be sure.
292 for (int i = 0; i < num_views; i++) 245 for (int i = 0; i < num_views; i++)
293 { 246 {
@@ -308,18 +261,6 @@ static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32
308 position = last_position; 261 position = last_position;
309 } 262 }
310 else { 263 else {
311#ifdef __SYMBIAN32__
312 *(view.out_ptr_low) = (u8*)((int)arena->memmap->Base() + view.virtual_address);
313 arena->memmap->Commit(view.virtual_address & 0x3FFFFFFF, view.size);
314 }
315 *(view.out_ptr) = (u8*)((int)arena->memmap->Base() + view.virtual_address & 0x3FFFFFFF);
316#elif defined(_XBOX)
317 *(view.out_ptr_low) = (u8*)(base + view.virtual_address);
318 //arena->memmap->Commit(view.virtual_address & 0x3FFFFFFF, view.size);
319 ptr = VirtualAlloc(base + (view.virtual_address & 0x3FFFFFFF), view.size, MEM_COMMIT, PAGE_READWRITE);
320 }
321 *(view.out_ptr) = (u8*)base + (view.virtual_address & 0x3FFFFFFF);
322#else
323 *(view.out_ptr_low) = (u8*)arena->CreateView(position, view.size); 264 *(view.out_ptr_low) = (u8*)arena->CreateView(position, view.size);
324 if (!*view.out_ptr_low) 265 if (!*view.out_ptr_low)
325 goto bail; 266 goto bail;
@@ -340,7 +281,6 @@ static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32
340 } 281 }
341#endif 282#endif
342 283
343#endif
344 last_position = position; 284 last_position = position;
345 position += roundup(view.size); 285 position += roundup(view.size);
346 } 286 }
@@ -389,9 +329,7 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
389 total_mem += roundup(views[i].size); 329 total_mem += roundup(views[i].size);
390 } 330 }
391 // Grab some pagefile backed memory out of the void ... 331 // Grab some pagefile backed memory out of the void ...
392#ifndef __SYMBIAN32__
393 arena->GrabLowMemSpace(total_mem); 332 arena->GrabLowMemSpace(total_mem);
394#endif
395 333
396 // Now, create views in high memory where there's plenty of space. 334 // Now, create views in high memory where there's plenty of space.
397#ifdef _M_X64 335#ifdef _M_X64
@@ -403,15 +341,6 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
403 PanicAlert("MemoryMap_Setup: Failed finding a memory base."); 341 PanicAlert("MemoryMap_Setup: Failed finding a memory base.");
404 return 0; 342 return 0;
405 } 343 }
406#elif defined(_XBOX)
407 // Reserve 256MB
408 u8 *base = (u8*)VirtualAlloc(0, 0x10000000, MEM_RESERVE | MEM_LARGE_PAGES, PAGE_READWRITE);
409 if (!Memory_TryBase(base, views, num_views, flags, arena))
410 {
411 PanicAlert("MemoryMap_Setup: Failed finding a memory base.");
412 exit(0);
413 return 0;
414 }
415#elif defined(_WIN32) 344#elif defined(_WIN32)
416 // Try a whole range of possible bases. Return once we got a valid one. 345 // Try a whole range of possible bases. Return once we got a valid one.
417 u32 max_base_addr = 0x7FFF0000 - 0x10000000; 346 u32 max_base_addr = 0x7FFF0000 - 0x10000000;
@@ -428,15 +357,6 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
428 break; 357 break;
429 } 358 }
430 } 359 }
431#elif defined(__SYMBIAN32__)
432 arena->memmap = new RChunk();
433 arena->memmap->CreateDisconnectedLocal(0, 0, 0x10000000);
434 if (!Memory_TryBase(arena->memmap->Base(), views, num_views, flags, arena))
435 {
436 PanicAlert("MemoryMap_Setup: Failed finding a memory base.");
437 return 0;
438 }
439 u8* base = arena->memmap->Base();
440#else 360#else
441 // Linux32 is fine with the x64 method, although limited to 32-bit with no automirrors. 361 // Linux32 is fine with the x64 method, although limited to 32-bit with no automirrors.
442 u8 *base = MemArena::Find4GBBase(); 362 u8 *base = MemArena::Find4GBBase();
diff --git a/src/common/mem_arena.h b/src/common/mem_arena.h
index b5f0aa890..3379d2529 100644
--- a/src/common/mem_arena.h
+++ b/src/common/mem_arena.h
@@ -21,10 +21,6 @@
21#include <windows.h> 21#include <windows.h>
22#endif 22#endif
23 23
24#ifdef __SYMBIAN32__
25#include <e32std.h>
26#endif
27
28#include "common/common.h" 24#include "common/common.h"
29 25
30// This class lets you create a block of anonymous RAM, and then arbitrarily map views into it. 26// This class lets you create a block of anonymous RAM, and then arbitrarily map views into it.
@@ -39,12 +35,8 @@ public:
39 void *CreateView(s64 offset, size_t size, void *base = 0); 35 void *CreateView(s64 offset, size_t size, void *base = 0);
40 void ReleaseView(void *view, size_t size); 36 void ReleaseView(void *view, size_t size);
41 37
42#ifdef __SYMBIAN32__
43 RChunk* memmap;
44#else
45 // This only finds 1 GB in 32-bit 38 // This only finds 1 GB in 32-bit
46 static u8 *Find4GBBase(); 39 static u8 *Find4GBBase();
47#endif
48private: 40private:
49 41
50#ifdef _WIN32 42#ifdef _WIN32
diff --git a/src/common/platform.h b/src/common/platform.h
index ce9cfd4a2..ba1109c9f 100644
--- a/src/common/platform.h
+++ b/src/common/platform.h
@@ -35,7 +35,6 @@
35#define PLATFORM_MACOSX 2 35#define PLATFORM_MACOSX 2
36#define PLATFORM_LINUX 3 36#define PLATFORM_LINUX 3
37#define PLATFORM_ANDROID 4 37#define PLATFORM_ANDROID 4
38#define PLATFORM_IOS 5
39 38
40//////////////////////////////////////////////////////////////////////////////////////////////////// 39////////////////////////////////////////////////////////////////////////////////////////////////////
41// Platform detection 40// Platform detection
diff --git a/src/common/swap.h b/src/common/swap.h
index 4f8f39efb..e2d918362 100644
--- a/src/common/swap.h
+++ b/src/common/swap.h
@@ -48,11 +48,7 @@
48// MSVC 48// MSVC
49#elif defined(_MSC_VER) && !defined(COMMON_BIG_ENDIAN) && !defined(COMMON_LITTLE_ENDIAN) 49#elif defined(_MSC_VER) && !defined(COMMON_BIG_ENDIAN) && !defined(COMMON_LITTLE_ENDIAN)
50 50
51#ifdef _XBOX
52#define COMMON_BIG_ENDIAN 1
53#else
54#define COMMON_LITTLE_ENDIAN 1 51#define COMMON_LITTLE_ENDIAN 1
55#endif
56 52
57#endif 53#endif
58 54