mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Symbian support for project.
New UNUSABLE_MMAP code path for platforms that cannot use the required flags (Xbox 360, Symbian). Falls back to malloc() instead. N1 define for compilers (GCCE) that don't like to assume (int)-1 will safely cast to (char)-1. Miscellaneous space->tab fixes.
This commit is contained in:
parent
24bd875a90
commit
a1781b854a
16 changed files with 122 additions and 58 deletions
|
@ -22,6 +22,9 @@
|
|||
|
||||
#include "Common.h"
|
||||
#include "MemoryUtil.h"
|
||||
#ifdef __SYMBIAN32__
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#undef _SP
|
||||
|
||||
|
|
|
@ -53,6 +53,22 @@
|
|||
#define fstat64 fstat
|
||||
#endif
|
||||
|
||||
#if !defined(readdir_r)
|
||||
static inline int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) {
|
||||
struct dirent *readdir_entry;
|
||||
|
||||
readdir_entry = readdir(dirp);
|
||||
if (readdir_entry == NULL) {
|
||||
*result = NULL;
|
||||
return errno;
|
||||
}
|
||||
|
||||
*entry = *readdir_entry;
|
||||
*result = entry;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// This namespace has various generic functions related to files and paths.
|
||||
// The code still needs a ton of cleanup.
|
||||
// REMEMBER: strdup considered harmful!
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
#define INFO_LEVEL 4 // General information.
|
||||
#define DEBUG_LEVEL 5 // Detailed debugging - might make things slow.
|
||||
|
||||
#ifdef __SYMBIAN32__
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
namespace LogTypes
|
||||
{
|
||||
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
#include "Timer.h"
|
||||
#include "Thread.h"
|
||||
#include "FileUtil.h"
|
||||
#ifdef __SYMBIAN32__
|
||||
#include <e32debug.h>
|
||||
#endif
|
||||
|
||||
void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
|
||||
const char *file, int line, const char* fmt, ...)
|
||||
|
@ -197,7 +200,11 @@ void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg)
|
|||
return;
|
||||
|
||||
std::lock_guard<std::mutex> lk(m_log_lock);
|
||||
#ifdef __SYMBIAN32__
|
||||
RDebug::Printf("%s",msg);
|
||||
#else
|
||||
m_logfile << msg << std::flush;
|
||||
#endif
|
||||
}
|
||||
|
||||
void DebuggerLogListener::Log(LogTypes::LOG_LEVELS, const char *msg)
|
||||
|
|
|
@ -33,6 +33,11 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__SYMBIAN32__)
|
||||
// Also Xbox 360
|
||||
#define UNUSABLE_MMAP 1
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ANDROID
|
||||
|
||||
|
@ -108,12 +113,12 @@ SYSTEM_INFO sysInfo;
|
|||
// Windows mappings need to be on 64K boundaries, due to Alpha legacy.
|
||||
#ifdef _WIN32
|
||||
size_t roundup(size_t x) {
|
||||
int gran = sysInfo.dwAllocationGranularity ? sysInfo.dwAllocationGranularity : 0x10000;
|
||||
return (x + gran - 1) & ~(gran - 1);
|
||||
int gran = sysInfo.dwAllocationGranularity ? sysInfo.dwAllocationGranularity : 0x10000;
|
||||
return (x + gran - 1) & ~(gran - 1);
|
||||
}
|
||||
#else
|
||||
size_t roundup(size_t x) {
|
||||
return x;
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -122,8 +127,8 @@ void MemArena::GrabLowMemSpace(size_t size)
|
|||
{
|
||||
#ifdef _WIN32
|
||||
hMemoryMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, (DWORD)(size), NULL);
|
||||
GetSystemInfo(&sysInfo);
|
||||
#elif ANDROID
|
||||
GetSystemInfo(&sysInfo);
|
||||
#elif defined(ANDROID)
|
||||
// Use ashmem so we don't have to allocate a file on disk!
|
||||
fd = ashmem_create_region("PPSSPP_RAM", size);
|
||||
// Note that it appears that ashmem is pinned by default, so no need to pin.
|
||||
|
@ -132,6 +137,8 @@ void MemArena::GrabLowMemSpace(size_t size)
|
|||
ERROR_LOG(MEMMAP, "Failed to grab ashmem space of size: %08x errno: %d", (int)size, (int)(errno));
|
||||
return;
|
||||
}
|
||||
#elif defined(UNUSABLE_MMAP)
|
||||
// Do nothing as we are using malloc()
|
||||
#else
|
||||
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||
fd = open(ram_temp_file.c_str(), O_RDWR | O_CREAT, mode);
|
||||
|
@ -156,6 +163,8 @@ void MemArena::ReleaseSpace()
|
|||
#ifdef _WIN32
|
||||
CloseHandle(hMemoryMapping);
|
||||
hMemoryMapping = 0;
|
||||
#elif defined(UNUSABLE_MMAP)
|
||||
// Do nothing as we are using malloc()
|
||||
#else
|
||||
close(fd);
|
||||
#endif
|
||||
|
@ -165,30 +174,32 @@ void MemArena::ReleaseSpace()
|
|||
void *MemArena::CreateView(s64 offset, size_t size, void *base)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
size = roundup(size);
|
||||
void *ptr = MapViewOfFileEx(hMemoryMapping, FILE_MAP_ALL_ACCESS, 0, (DWORD)((u64)offset), size, base);
|
||||
if (!ptr) {
|
||||
//ERROR_LOG(MEMMAP, "Failed to map memory: %08x %08x %08x : %s", (u32)offset, (u32)size, (u32)base, GetLastErrorMsg());
|
||||
} else {
|
||||
//ERROR_LOG(MEMMAP, "Mapped memory: %08x %08x %08x : %s", (u32)offset, (u32)size, (u32)base, GetLastErrorMsg());
|
||||
}
|
||||
return ptr;
|
||||
size = roundup(size);
|
||||
void *ptr = MapViewOfFileEx(hMemoryMapping, FILE_MAP_ALL_ACCESS, 0, (DWORD)((u64)offset), size, base);
|
||||
if (!ptr) {
|
||||
//ERROR_LOG(MEMMAP, "Failed to map memory: %08x %08x %08x : %s", (u32)offset, (u32)size, (u32)base, GetLastErrorMsg());
|
||||
} else {
|
||||
//ERROR_LOG(MEMMAP, "Mapped memory: %08x %08x %08x : %s", (u32)offset, (u32)size, (u32)base, GetLastErrorMsg());
|
||||
}
|
||||
return ptr;
|
||||
#elif defined(UNUSABLE_MMAP)
|
||||
void *retval = malloc(size);
|
||||
if (!retval)
|
||||
{
|
||||
NOTICE_LOG(MEMMAP, "malloc failed: %s", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
return retval;
|
||||
#else
|
||||
void *retval = mmap(
|
||||
base, size,
|
||||
PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED | ((base == 0) ? 0 : MAP_FIXED),
|
||||
fd, offset);
|
||||
void *retval = mmap(base, size, PROT_READ | PROT_WRITE, MAP_SHARED |
|
||||
((base == 0) ? 0 : MAP_FIXED), fd, offset);
|
||||
|
||||
if (retval == MAP_FAILED)
|
||||
{
|
||||
NOTICE_LOG(MEMMAP, "mmap on %s (fd: %d) failed", ram_temp_file.c_str(), (int)fd);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return retval;
|
||||
}
|
||||
return retval;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -197,6 +208,8 @@ void MemArena::ReleaseView(void* view, size_t size)
|
|||
{
|
||||
#ifdef _WIN32
|
||||
UnmapViewOfFile(view);
|
||||
#elif defined(UNUSABLE_MMAP)
|
||||
free(view);
|
||||
#else
|
||||
munmap(view, size);
|
||||
#endif
|
||||
|
@ -226,6 +239,9 @@ u8* MemArena::Find4GBBase()
|
|||
VirtualFree(base, 0, MEM_RELEASE);
|
||||
}
|
||||
return base;
|
||||
#elif defined(UNUSABLE_MMAP)
|
||||
// We are unable to use relative addresses due to lack of mmap()
|
||||
return NULL;
|
||||
#else
|
||||
void* base = mmap(0, 0x5000000, PROT_READ | PROT_WRITE,
|
||||
MAP_ANON | MAP_SHARED, -1, 0);
|
||||
|
@ -391,7 +407,7 @@ void MemoryMap_Shutdown(const MemoryView *views, int num_views, u32 flags, MemAr
|
|||
if (*views[i].out_ptr && (views[i].out_ptr_low && *views[i].out_ptr != *views[i].out_ptr_low))
|
||||
arena->ReleaseView(*views[i].out_ptr, views[i].size);
|
||||
*views[i].out_ptr = NULL;
|
||||
if (views[i].out_ptr_low)
|
||||
if (views[i].out_ptr_low)
|
||||
*views[i].out_ptr_low = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,9 @@ void* AllocateExecutableMemory(size_t size, bool low)
|
|||
{
|
||||
#if defined(_WIN32)
|
||||
void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
#elif defined(__SYMBIAN32__)
|
||||
// On Symbian, we will need to create an RChunk and allocate with ->CreateLocalCode(size, size);
|
||||
void* ptr = mmap(map_hint, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, -1, 0);
|
||||
#else
|
||||
static char *map_hint = 0;
|
||||
#if defined(__x86_64__) && !defined(MAP_32BIT)
|
||||
|
@ -130,9 +133,12 @@ void* AllocateAlignedMemory(size_t size,size_t alignment)
|
|||
#else
|
||||
void* ptr = NULL;
|
||||
#ifdef ANDROID
|
||||
ptr = memalign(alignment, size);
|
||||
ptr = memalign(alignment, size);
|
||||
#elif defined(__SYMBIAN32__)
|
||||
// On Symbian, we will want to create an RChunk.
|
||||
ptr = malloc(size);
|
||||
#else
|
||||
posix_memalign(&ptr, alignment, size);
|
||||
posix_memalign(&ptr, alignment, size);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "Common.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) || defined(__SYMBIAN32__)
|
||||
#define __thread
|
||||
#endif
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#define GCC_VER(x,y,z) ((x) * 10000 + (y) * 100 + (z))
|
||||
#define GCC_VERSION GCC_VER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
|
||||
|
||||
#if GCC_VERSION >= GCC_VER(4,4,0) && __GXX_EXPERIMENTAL_CXX0X__ && !defined(ANDROID)
|
||||
#if GCC_VERSION >= GCC_VER(4,4,0) && __GXX_EXPERIMENTAL_CXX0X__ && !defined(ANDROID) && !defined(__SYMBIAN32__)
|
||||
// GCC 4.4 provides <condition_variable>
|
||||
#include <condition_variable>
|
||||
#else
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#define GCC_VER(x,y,z) ((x) * 10000 + (y) * 100 + (z))
|
||||
#define GCC_VERSION GCC_VER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
|
||||
|
||||
#if GCC_VERSION >= GCC_VER(4,4,0) && __GXX_EXPERIMENTAL_CXX0X__ && !defined(ANDROID)
|
||||
#if GCC_VERSION >= GCC_VER(4,4,0) && __GXX_EXPERIMENTAL_CXX0X__ && !defined(ANDROID) && !defined(__SYMBIAN32__)
|
||||
// GCC 4.4 provides <mutex>
|
||||
#include <mutex>
|
||||
#else
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#define GCC_VER(x,y,z) ((x) * 10000 + (y) * 100 + (z))
|
||||
#define GCC_VERSION GCC_VER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
|
||||
|
||||
#if GCC_VERSION >= GCC_VER(4,4,0) && __GXX_EXPERIMENTAL_CXX0X__ && !defined(ANDROID)
|
||||
#if GCC_VERSION >= GCC_VER(4,4,0) && __GXX_EXPERIMENTAL_CXX0X__ && !defined(ANDROID) && !defined(__SYMBIAN32__)
|
||||
// GCC 4.4 provides <thread>
|
||||
#ifndef _GLIBCXX_USE_SCHED_YIELD
|
||||
#define _GLIBCXX_USE_SCHED_YIELD
|
||||
|
|
|
@ -258,31 +258,31 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st
|
|||
// Uri encode and decode.
|
||||
// RFC1630, RFC1738, RFC2396
|
||||
|
||||
//#include <string>
|
||||
//#include <assert.h>
|
||||
|
||||
const char HEX2DEC[256] =
|
||||
// Some compilers don't like to assume (int)-1 will safely cast to (char)-1 as
|
||||
// the MSBs aren't 0's. Workaround the issue while maintaining table spacing.
|
||||
#define N1 (char)-1
|
||||
const char HEX2DEC[256] =
|
||||
{
|
||||
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
|
||||
/* 0 */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
/* 1 */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
/* 2 */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
/* 3 */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1, -1,-1,-1,-1,
|
||||
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
|
||||
/* 0 */ N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1,
|
||||
/* 1 */ N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1,
|
||||
/* 2 */ N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1,
|
||||
/* 3 */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,N1,N1, N1,N1,N1,N1,
|
||||
|
||||
/* 4 */ -1,10,11,12, 13,14,15,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
/* 5 */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
/* 6 */ -1,10,11,12, 13,14,15,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
/* 7 */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
/* 4 */ N1,10,11,12, 13,14,15,N1, N1,N1,N1,N1, N1,N1,N1,N1,
|
||||
/* 5 */ N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1,
|
||||
/* 6 */ N1,10,11,12, 13,14,15,N1, N1,N1,N1,N1, N1,N1,N1,N1,
|
||||
/* 7 */ N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1,
|
||||
|
||||
/* 8 */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
/* 9 */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
/* A */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
/* B */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
/* 8 */ N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1,
|
||||
/* 9 */ N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1,
|
||||
/* A */ N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1,
|
||||
/* B */ N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1,
|
||||
|
||||
/* C */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
/* D */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
/* E */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
/* F */ -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1
|
||||
/* C */ N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1,
|
||||
/* D */ N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1,
|
||||
/* E */ N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1,
|
||||
/* F */ N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1, N1,N1,N1,N1
|
||||
};
|
||||
|
||||
std::string UriDecode(const std::string & sSrc)
|
||||
|
|
|
@ -37,11 +37,10 @@
|
|||
#include "sceKernelMemory.h"
|
||||
#include "sceKernelThread.h"
|
||||
|
||||
#define ERROR_ERRNO_FILE_NOT_FOUND 0x80010002
|
||||
#define ERROR_ERRNO_FILE_NOT_FOUND 0x80010002
|
||||
|
||||
|
||||
#define ERROR_MEMSTICK_DEVCTL_BAD_PARAMS 0x80220081
|
||||
#define ERROR_MEMSTICK_DEVCTL_TOO_MANY_CALLBACKS 0x80220082
|
||||
#define ERROR_MEMSTICK_DEVCTL_BAD_PARAMS 0x80220081
|
||||
#define ERROR_MEMSTICK_DEVCTL_TOO_MANY_CALLBACKS 0x80220082
|
||||
|
||||
/*
|
||||
|
||||
|
@ -95,6 +94,12 @@ enum {
|
|||
TYPE_FILE=0x20
|
||||
};
|
||||
|
||||
#ifdef __SYMBIAN32__
|
||||
#undef st_ctime
|
||||
#undef st_atime
|
||||
#undef st_mtime
|
||||
#endif
|
||||
|
||||
struct SceIoStat {
|
||||
SceMode st_mode;
|
||||
unsigned int st_attr;
|
||||
|
@ -110,7 +115,7 @@ struct SceIoDirEnt {
|
|||
char d_name[256];
|
||||
u32 d_private;
|
||||
};
|
||||
|
||||
#ifndef __SYMBIAN32__
|
||||
struct dirent {
|
||||
u32 unk0;
|
||||
u32 type;
|
||||
|
@ -118,6 +123,7 @@ struct dirent {
|
|||
u32 unk[19];
|
||||
char name[0x108];
|
||||
};
|
||||
#endif
|
||||
|
||||
class FileNode : public KernelObject {
|
||||
public:
|
||||
|
|
|
@ -822,7 +822,7 @@ void sceKernelCheckThreadStack()
|
|||
{
|
||||
u32 error;
|
||||
Thread *t = kernelObjects.Get<Thread>(__KernelGetCurThread(), error);
|
||||
u32 diff = (u32)abs((s64)t->stackBlock - (s64)currentMIPS->r[MIPS_REG_SP]);
|
||||
u32 diff = abs((long)((s64)t->stackBlock - (s64)currentMIPS->r[MIPS_REG_SP]));
|
||||
ERROR_LOG(HLE, "%i=sceKernelCheckThreadStack()", diff);
|
||||
RETURN(diff); //Blatant lie
|
||||
}
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
#if defined(_DEBUG)
|
||||
//#define SAFE_MEMORY
|
||||
#endif
|
||||
// Required for UNUSABLE_MMAP. Can define this in cmake instead later
|
||||
#ifdef __SYMBIAN32__
|
||||
#define SAFE_MEMORY
|
||||
#endif
|
||||
|
||||
|
||||
// Global declarations
|
||||
|
|
|
@ -387,8 +387,10 @@ static const char *credits[] =
|
|||
"Free tools used:",
|
||||
#ifdef ANDROID
|
||||
"Android SDK + NDK",
|
||||
#elif BLACKBERRY
|
||||
#elif defined(BLACKBERRY)
|
||||
"Blackberry NDK",
|
||||
#elif defined(__SYMBIAN32__)
|
||||
"Qt",
|
||||
#else
|
||||
"SDL",
|
||||
#endif
|
||||
|
|
|
@ -209,7 +209,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co
|
|||
g_Config.Load(config_filename.c_str());
|
||||
|
||||
if (g_Config.currentDirectory == "") {
|
||||
#if defined(ANDROID) || defined(BLACKBERRY)
|
||||
#if defined(ANDROID) || defined(BLACKBERRY) || defined(__SYMBIAN32__)
|
||||
g_Config.currentDirectory = external_directory;
|
||||
#else
|
||||
g_Config.currentDirectory = getenv("HOME");
|
||||
|
|
Loading…
Add table
Reference in a new issue