Replace setjmp with libco, update aurora
This commit is contained in:
parent
b05b70d6b7
commit
41f9f7737e
38 changed files with 601 additions and 805 deletions
|
|
@ -8,9 +8,9 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#ifdef AURORA
|
||||
#define GXCALLDISPLAYLISTLE GXCallDisplayListLE
|
||||
#define GXCallDisplayListNative GXCallDisplayListLE
|
||||
#else
|
||||
#define GXCALLDISPLAYLISTLE GXCallDisplayList
|
||||
#define GXCallDisplayListNative GXCallDisplayList
|
||||
#endif
|
||||
|
||||
void GXBeginDisplayList(void* list, u32 size);
|
||||
|
|
|
|||
|
|
@ -1,159 +1,9 @@
|
|||
#ifndef _GAME_JMP_H
|
||||
#define _GAME_JMP_H
|
||||
|
||||
#ifdef TARGET_PC
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef _M_X64
|
||||
#include "../extern/longjmp_win64/longjmp_win64.h"
|
||||
#define SETJMP setjmp_win64
|
||||
#define LONGJMP longjmp_win64
|
||||
#define JMPBUF JMP_BUF_WIN64
|
||||
#else
|
||||
#include <setjmp.h>
|
||||
#define SETJMP setjmp
|
||||
#define LONGJMP longjmp
|
||||
#define JMPBUF jmp_buf
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _JMP_BUF_DEFINED
|
||||
#if defined(_M_IX86)
|
||||
typedef struct __JUMP_BUFFER {
|
||||
uint32_t Ebp;
|
||||
uint32_t Ebx;
|
||||
uint32_t Edi;
|
||||
uint32_t Esi;
|
||||
uint32_t Esp;
|
||||
uint32_t Eip;
|
||||
uint32_t Registration;
|
||||
uint32_t TryLevel;
|
||||
uint32_t Cookie;
|
||||
uint32_t UnwindFunc;
|
||||
uint32_t UnwindData[6];
|
||||
} _JUMP_BUFFER;
|
||||
#elif defined(__i386__)
|
||||
typedef struct __JUMP_BUFFER {
|
||||
uint32_t Bx;
|
||||
uint32_t Si;
|
||||
uint32_t Di;
|
||||
uint32_t Bp;
|
||||
uint32_t Sp;
|
||||
uint32_t Pc;
|
||||
} _JUMP_BUFFER;
|
||||
#elif defined(__x86_64__)
|
||||
typedef struct __JUMP_BUFFER {
|
||||
uint64_t Rbx;
|
||||
uint64_t Rbp;
|
||||
uint64_t R12;
|
||||
uint64_t R13;
|
||||
uint64_t R14;
|
||||
uint64_t R15;
|
||||
uint64_t Rsp;
|
||||
uint64_t Pc;
|
||||
} _JUMP_BUFFER;
|
||||
#elif defined(_M_ARM)
|
||||
typedef struct _JUMP_BUFFER {
|
||||
uint32_t Frame;
|
||||
|
||||
uint32_t R4;
|
||||
uint32_t R5;
|
||||
uint32_t R6;
|
||||
uint32_t R7;
|
||||
uint32_t R8;
|
||||
uint32_t R9;
|
||||
uint32_t R10;
|
||||
uint32_t R11;
|
||||
|
||||
uint32_t Sp;
|
||||
uint32_t Pc;
|
||||
uint32_t Fpscr;
|
||||
uint32_t long D[8]; // D8-D15 VFP/NEON regs
|
||||
} _JUMP_BUFFER;
|
||||
#elif defined(_M_ARM64)
|
||||
typedef struct _JUMP_BUFFER {
|
||||
uint64_t Frame;
|
||||
uint64_t Reserved;
|
||||
uint64_t X19; // x19 -- x28: callee saved registers
|
||||
uint64_t X20;
|
||||
uint64_t X21;
|
||||
uint64_t X22;
|
||||
uint64_t X23;
|
||||
uint64_t X24;
|
||||
uint64_t X25;
|
||||
uint64_t X26;
|
||||
uint64_t X27;
|
||||
uint64_t X28;
|
||||
uint64_t Fp; // x29 frame pointer
|
||||
uint64_t Lr; // x30 link register
|
||||
uint64_t Sp; // x31 stack pointer
|
||||
uint32_t Fpcr; // fp control register
|
||||
uint32_t Fpsr; // fp status register
|
||||
|
||||
double D[8]; // D8-D15 FP regs
|
||||
} _JUMP_BUFFER;
|
||||
#elif defined(__riscv)
|
||||
typedef struct _JUMP_BUFFER {
|
||||
uint32_t ra;
|
||||
uint32_t sp;
|
||||
uint32_t s0;
|
||||
uint32_t s1;
|
||||
uint32_t s2;
|
||||
uint32_t s3;
|
||||
uint32_t s4;
|
||||
uint32_t s5;
|
||||
uint32_t s6;
|
||||
uint32_t s7;
|
||||
uint32_t s8;
|
||||
uint32_t s9;
|
||||
uint32_t s10;
|
||||
uint32_t s11;
|
||||
|
||||
#if __riscv_xlen == 64
|
||||
uint64_t fs0;
|
||||
uint64_t fs1;
|
||||
uint64_t fs2;
|
||||
uint64_t fs3;
|
||||
uint64_t fs4;
|
||||
uint64_t fs5;
|
||||
uint64_t fs6;
|
||||
uint64_t fs7;
|
||||
uint64_t fs8;
|
||||
uint64_t fs9;
|
||||
uint64_t fs10;
|
||||
uint64_t fs11;
|
||||
#endif
|
||||
} _JUMP_BUFFER;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_M_IX86)
|
||||
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Eip = (uintptr_t)func
|
||||
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Esp = (uintptr_t)sp
|
||||
#elif defined(__i386__)
|
||||
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Pc = (uintptr_t)func
|
||||
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Sp = (uintptr_t)sp
|
||||
#elif defined(__x86_64__)
|
||||
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Pc = (uintptr_t)func
|
||||
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Rsp = (uintptr_t)sp
|
||||
#elif defined(_M_X64)
|
||||
#define SETJMP_SET_IP(jump, func) (jump)->rip_getjmp = (uintptr_t)func
|
||||
#define SETJMP_SET_SP(jump, sp) (jump)->rsp_getjmp = (uintptr_t)sp
|
||||
#elif defined(_M_ARM) || defined(__arm__)
|
||||
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Pc = (uintptr_t)func
|
||||
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Sp = (uintptr_t)sp
|
||||
#elif defined(_M_ARM64) || defined(__aarch64__)
|
||||
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Lr = (uintptr_t)func
|
||||
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Sp = (uintptr_t)sp
|
||||
#elif defined(__riscv)
|
||||
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->ra = (uintptr_t)func
|
||||
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->sp = (uintptr_t)sp
|
||||
#endif
|
||||
|
||||
#else
|
||||
#include "dolphin.h"
|
||||
|
||||
typedef struct jmp_buf {
|
||||
typedef struct jump_buf {
|
||||
u32 lr;
|
||||
u32 cr;
|
||||
u32 sp;
|
||||
|
|
@ -166,12 +16,4 @@ typedef struct jmp_buf {
|
|||
s32 gcsetjmp(jmp_buf *jump);
|
||||
s32 gclongjmp(jmp_buf *jump, s32 status);
|
||||
|
||||
#define JMPBUF jmp_buf
|
||||
#define SETJMP(jump) gcsetjmp(&(jump))
|
||||
#define LONGJMP(jump, status) gclongjmp(&(jump), (status))
|
||||
|
||||
#define SETJMP_SET_IP(jump, func) jump.lr = (u32)func
|
||||
#define SETJMP_SET_SP(jump, stack_ptr) jump.sp = (u32)stack_ptr
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -3,10 +3,11 @@
|
|||
|
||||
#include "dolphin/types.h"
|
||||
|
||||
#include "game/jmp.h"
|
||||
|
||||
#ifdef TARGET_PC
|
||||
#include <stdio.h>
|
||||
#include "libco.h"
|
||||
#else
|
||||
#include "game/jmp.h"
|
||||
#endif
|
||||
|
||||
#define PROCESS_STAT_PAUSE 0x1
|
||||
|
|
@ -26,8 +27,12 @@ typedef struct process {
|
|||
u16 stat;
|
||||
u16 prio;
|
||||
s32 sleep_time;
|
||||
#ifdef TARGET_PC
|
||||
cothread_t thread;
|
||||
#else
|
||||
uintptr_t base_sp;
|
||||
JMPBUF jump;
|
||||
jmp_buf jump;
|
||||
#endif
|
||||
void (*dtor)(void);
|
||||
void *user_data;
|
||||
} Process;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue