mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 17:12:25 -05:00
Get PSP support a little further along
This commit is contained in:
parent
008262acac
commit
66dfef319d
3 changed files with 72 additions and 13 deletions
37
src/Logger.c
37
src/Logger.c
|
@ -26,6 +26,8 @@
|
|||
#define _GNU_SOURCE
|
||||
#include <sys/ucontext.h>
|
||||
#include <signal.h>
|
||||
#elif defined CC_BUILD_PSP
|
||||
/* TODO can this be supported somehow? */
|
||||
#elif defined CC_BUILD_POSIX
|
||||
#include <signal.h>
|
||||
#include <sys/ucontext.h>
|
||||
|
@ -232,6 +234,8 @@ static void DumpFrame(cc_string* trace, void* addr) {
|
|||
String_AppendString(trace, &str);
|
||||
Logger_Log(&str);
|
||||
}
|
||||
#elif defined CC_BUILD_PSP
|
||||
/* No backtrace support implemented for PSP */
|
||||
#elif defined CC_BUILD_POSIX
|
||||
/* need to define __USE_GNU for dladdr */
|
||||
#ifndef __USE_GNU
|
||||
|
@ -351,6 +355,11 @@ void Logger_Backtrace(cc_string* trace, void* ctx) {
|
|||
String_AppendConst(trace, "-- backtrace unimplemented --");
|
||||
/* TODO: Backtrace using LibSymbolication */
|
||||
}
|
||||
#elif defined CC_BUILD_PSP
|
||||
void Logger_Backtrace(cc_string* trace, void* ctx) {
|
||||
String_AppendConst(trace, "-- backtrace unimplemented --");
|
||||
/* Backtrace not implemented for PSP */
|
||||
}
|
||||
#elif defined CC_BUILD_POSIX
|
||||
#include <execinfo.h>
|
||||
void Logger_Backtrace(cc_string* trace, void* ctx) {
|
||||
|
@ -781,6 +790,10 @@ static void PrintRegisters(cc_string* str, void* ctx) {
|
|||
#error "Unknown CPU architecture"
|
||||
#endif
|
||||
}
|
||||
#elif defined CC_BUILD_PSP
|
||||
static void PrintRegisters(cc_string* str, void* ctx) {
|
||||
/* Register dumping not implemented */
|
||||
}
|
||||
#endif
|
||||
|
||||
static void DumpRegisters(void* ctx) {
|
||||
|
@ -957,11 +970,11 @@ static LONG WINAPI UnhandledFilter(struct _EXCEPTION_POINTERS* info) {
|
|||
|
||||
void Logger_Hook(void) {
|
||||
static const struct DynamicLibSym funcs[] = {
|
||||
#ifdef _IMAGEHLP64
|
||||
#ifdef _IMAGEHLP64
|
||||
{ "EnumerateLoadedModules64", (void**)&_EnumerateLoadedModules},
|
||||
#else
|
||||
#else
|
||||
{ "EnumerateLoadedModules", (void**)&_EnumerateLoadedModules },
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
static const cc_string imagehlp = String_FromConst("IMAGEHLP.DLL");
|
||||
void* lib;
|
||||
|
@ -978,7 +991,7 @@ void __attribute__((optimize("O0"))) Logger_Abort2(cc_result result, const char*
|
|||
void Logger_Abort2(cc_result result, const char* raw_msg) {
|
||||
#endif
|
||||
CONTEXT ctx;
|
||||
#if _M_IX86 && __GNUC__
|
||||
#if _M_IX86 && __GNUC__
|
||||
/* Stack frame layout on x86: */
|
||||
/* [ebp] is previous frame's EBP */
|
||||
/* [ebp+4] is previous frame's EIP (return address) */
|
||||
|
@ -995,15 +1008,23 @@ void Logger_Abort2(cc_result result, const char* raw_msg) {
|
|||
: "eax", "memory"
|
||||
);
|
||||
ctx.ContextFlags = CONTEXT_CONTROL;
|
||||
#else
|
||||
#else
|
||||
/* This method is guaranteed to exist on 64 bit windows. */
|
||||
/* NOTE: This is missing in 32 bit Windows 2000 however, */
|
||||
/* so an alternative is provided for MinGW above so that */
|
||||
/* the game can be cross-compiled for Windows 98 / 2000 */
|
||||
RtlCaptureContext(&ctx);
|
||||
#endif
|
||||
#endif
|
||||
AbortCommon(result, raw_msg, &ctx);
|
||||
}
|
||||
#elif defined CC_BUILD_PSP
|
||||
void Logger_Hook(void) {
|
||||
/* TODO can signals be supported somehow? */
|
||||
}
|
||||
|
||||
void Logger_Abort2(cc_result result, const char* raw_msg) {
|
||||
AbortCommon(result, raw_msg, NULL);
|
||||
}
|
||||
#elif defined CC_BUILD_POSIX
|
||||
static void SignalHandler(int sig, siginfo_t* info, void* ctx) {
|
||||
cc_string msg; char msgBuffer[128 + 1];
|
||||
|
@ -1025,10 +1046,10 @@ static void SignalHandler(int sig, siginfo_t* info, void* ctx) {
|
|||
String_Format3(&msg, "Unhandled signal %i (code %i) at %x", &type, &code, &addr);
|
||||
msg.buffer[msg.length] = '\0';
|
||||
|
||||
#if defined CC_BUILD_ANDROID
|
||||
#if defined CC_BUILD_ANDROID
|
||||
/* deliberate Dalvik VM abort, try to log a nicer error for this */
|
||||
if (type == SIGSEGV && addr == 0xDEADD00D) Platform_TryLogJavaError();
|
||||
#endif
|
||||
#endif
|
||||
AbortCommon(0, msg.buffer, ctx);
|
||||
}
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@ endif
|
|||
|
||||
ifeq ($(PLAT),psp)
|
||||
CC=psp-gcc
|
||||
LIBS=-lm -lpspgum -lpspgu -lpspge -lpspdisplay
|
||||
endif
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
|
@ -129,7 +130,7 @@ haiku:
|
|||
serenityos:
|
||||
$(MAKE) $(ENAME) PLAT=serenityos
|
||||
psp:
|
||||
$(MAKE) $(ENAME) PLAT=psp
|
||||
$(MAKE) ClassiCube.elf PLAT=psp
|
||||
|
||||
clean:
|
||||
$(DEL) $(OBJECTS)
|
||||
|
@ -145,3 +146,9 @@ interop_cocoa.o: interop_cocoa.m
|
|||
|
||||
Window_Haiku.o: Window_Haiku.cpp
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# PSP requires fixups
|
||||
ClassiCube.elf : $(ENAME)
|
||||
cp $(ENAME) ClassiCube.elf
|
||||
psp-fixup-imports ClassiCube.elf
|
||||
|
||||
|
|
|
@ -53,6 +53,13 @@ const cc_result ReturnCode_DirectoryExists = EEXIST;
|
|||
/* TODO: Use load_image/resume_thread instead of fork */
|
||||
/* Otherwise opening browser never works because fork fails */
|
||||
#include <kernel/image.h>
|
||||
#elif defined CC_BUILD_PSP
|
||||
/* pspsdk doesn't seem to support IPv6 */
|
||||
#undef AF_INET6
|
||||
#include <pspkernel.h>
|
||||
|
||||
PSP_MODULE_INFO("ClassiCube", PSP_MODULE_USER, 1, 0);
|
||||
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -477,10 +484,12 @@ void Platform_LoadSysFonts(void) {
|
|||
*---------------------------------------------------------Socket----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
union SocketAddress {
|
||||
struct sockaddr_storage total;
|
||||
struct sockaddr raw;
|
||||
struct sockaddr_in v4;
|
||||
#ifdef AF_INET6
|
||||
struct sockaddr_in6 v6;
|
||||
struct sockaddr_storage total;
|
||||
#endif
|
||||
};
|
||||
|
||||
static int ParseHost(union SocketAddress* addr, const char* host) {
|
||||
|
@ -513,7 +522,9 @@ static int ParseAddress(union SocketAddress* addr, const cc_string* address) {
|
|||
String_EncodeUtf8(str, address);
|
||||
|
||||
if (inet_pton(AF_INET, str, &addr->v4.sin_addr) > 0) return AF_INET;
|
||||
#ifdef AF_INET6
|
||||
if (inet_pton(AF_INET6, str, &addr->v6.sin6_addr) > 0) return AF_INET6;
|
||||
#endif
|
||||
return ParseHost(addr, str);
|
||||
}
|
||||
|
||||
|
@ -533,13 +544,22 @@ cc_result Socket_Connect(cc_socket* s, const cc_string* address, int port) {
|
|||
|
||||
*s = socket(family, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (*s == -1) return errno;
|
||||
|
||||
#if defined CC_BUILD_PSP
|
||||
int on = 1;
|
||||
setsockopt(*s, SOL_SOCKET, SO_NONBLOCK, &on, sizeof(int));
|
||||
#else
|
||||
ioctl(*s, FIONBIO, &blocking_raw);
|
||||
#endif
|
||||
|
||||
#ifdef AF_INET6
|
||||
if (family == AF_INET6) {
|
||||
addr.v6.sin6_family = AF_INET6;
|
||||
addr.v6.sin6_port = htons(port);
|
||||
addrSize = sizeof(addr.v6);
|
||||
} else if (family == AF_INET) {
|
||||
}
|
||||
#endif
|
||||
if (family == AF_INET) {
|
||||
addr.v4.sin_family = AF_INET;
|
||||
addr.v4.sin_port = htons(port);
|
||||
addrSize = sizeof(addr.v4);
|
||||
|
@ -566,7 +586,7 @@ void Socket_Close(cc_socket s) {
|
|||
close(s);
|
||||
}
|
||||
|
||||
#if defined CC_BUILD_DARWIN
|
||||
#if defined CC_BUILD_DARWIN || defined CC_BUILD_PSP
|
||||
/* poll is broken on old OSX apparently https://daniel.haxx.se/docs/poll-vs-select.html */
|
||||
static cc_result Socket_Poll(cc_socket s, int mode, cc_bool* success) {
|
||||
fd_set set;
|
||||
|
@ -900,7 +920,18 @@ cc_result Updater_SetNewBuildTime(cc_uint64 timestamp) {
|
|||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Dynamic lib-------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
#if defined MAC_OS_X_VERSION_MIN_REQUIRED && (MAC_OS_X_VERSION_MIN_REQUIRED < 1040)
|
||||
#if defined CC_BUILD_PSP
|
||||
/* TODO can this actually be supported somehow */
|
||||
const cc_string DynamicLib_Ext = String_FromConst(".so");
|
||||
|
||||
void* DynamicLib_Load2(const cc_string* path) { return NULL; }
|
||||
void* DynamicLib_Get2(void* lib, const char* name) { return NULL; }
|
||||
|
||||
cc_bool DynamicLib_DescribeError(cc_string* dst) {
|
||||
String_AppendConst(dst, "Dynamic linking unsupported");
|
||||
return true;
|
||||
}
|
||||
#elif defined MAC_OS_X_VERSION_MIN_REQUIRED && (MAC_OS_X_VERSION_MIN_REQUIRED < 1040)
|
||||
/* Really old mac OS versions don't have the dlopen/dlsym API */
|
||||
const cc_string DynamicLib_Ext = String_FromConst(".dylib");
|
||||
|
||||
|
|
Loading…
Reference in a new issue