From 0df7e6cc1114cb378f51a7324bedbb08b9c8dd42 Mon Sep 17 00:00:00 2001 From: "Patrick C. Beard" Date: Mon, 23 Jan 2012 21:21:48 +0400 Subject: [PATCH] Integrate ancient 'pcbeard' GC port for MacOS 9 Classic * include/private/gc_priv.h (bcopy, bzero, BCOPY_EXISTS): Add definition for ancient MacOS/ppc. * mach_dep.c (PushMacRegisters): Add implementation for MacOS/ppc. * mach_dep.c (GC_push_regs): Fix to work on MacOS/ppc. --- include/private/gc_priv.h | 6 ++++++ mach_dep.c | 41 ++++++++++++++++++++++++++++++++------- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 407458b5..dc2944f8 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -386,6 +386,12 @@ typedef char * ptr_t; /* A generic pointer to which we can add */ # include # define BCOPY_EXISTS # endif +# if defined(MACOS) && defined(POWERPC) +# include +# define bcopy(x,y,n) BlockMoveData(x, y, n) +# define bzero(x,n) BlockZero(x, n) +# define BCOPY_EXISTS +# endif # ifndef BCOPY_EXISTS # include diff --git a/mach_dep.c b/mach_dep.c index 0eda3835..28ad562b 100644 --- a/mach_dep.c +++ b/mach_dep.c @@ -30,10 +30,35 @@ # endif #endif -#if defined(__MWERKS__) && !defined(POWERPC) +#if defined(MACOS) && defined(__MWERKS__) -asm static void PushMacRegisters() -{ +#if defined(POWERPC) + +# define NONVOLATILE_GPR_COUNT 19 + struct ppc_registers { + unsigned long gprs[NONVOLATILE_GPR_COUNT]; /* R13-R31 */ + }; + typedef struct ppc_registers ppc_registers; + + asm static void getRegisters(register ppc_registers* regs) + { + stmw r13,regs->gprs /* save R13-R31 */ + blr + } + + static void PushMacRegisters(void) + { + ppc_registers regs; + int i; + getRegisters(®s); + for (i = 0; i < NONVOLATILE_GPR_COUNT; i++) + GC_push_one(regs.gprs[i]); + } + +#else /* M68K */ + + asm static void PushMacRegisters(void) + { sub.w #4,sp /* reserve space for one parameter */ move.l a2,(sp) jsr GC_push_one @@ -61,9 +86,11 @@ asm static void PushMacRegisters() jsr GC_push_one add.w #4,sp /* fix stack */ rts -} + } + +#endif /* M68K */ -#endif /* __MWERKS__ */ +#endif /* MACOS && __MWERKS__ */ # if defined(SPARC) || defined(IA64) /* Value returned from register flushing routine; either sp (SPARC) */ @@ -128,9 +155,9 @@ asm static void PushMacRegisters() } # define HAVE_PUSH_REGS -# elif defined(M68K) && defined(MACOS) +# elif defined(MACOS) -# if defined(THINK_C) +# if defined(M68K) && defined(THINK_C) # define PushMacReg(reg) \ move.l reg,(sp) \ jsr GC_push_one -- 2.40.0