diff options
author | Matt Madison <madison@bliss-m.org> | 2014-09-19 05:53:23 -0700 |
---|---|---|
committer | Matt Madison <madison@bliss-m.org> | 2014-09-19 05:53:23 -0700 |
commit | 10ff5cfd628dda0618038ad23c35fe4155703222 (patch) | |
tree | 3c01240cf234bad5df4268d53117fa9bd9630d00 | |
parent | b81b53dd33ccc80b8654dd0181c4fbe71397ab9d (diff) | |
download | greenlet-10ff5cfd628dda0618038ad23c35fe4155703222.tar.gz |
Use assembler directives to perform the gp register save/restore.
-rw-r--r-- | platform/switch_mips_unix.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/platform/switch_mips_unix.h b/platform/switch_mips_unix.h index 9acf2b5..10e392b 100644 --- a/platform/switch_mips_unix.h +++ b/platform/switch_mips_unix.h @@ -6,6 +6,7 @@ * Ported from ppc. */ +#include <sgidefs.h> #define STACK_REFPLUS 1 #ifdef SLP_EVAL @@ -18,11 +19,15 @@ static int slp_switch(void) { register int *stackref, stsizediff; -#ifdef __mips64 - volatile register void *gp __asm__("$28"); - volatile void *gpsave = gp; +#if _MIPS_SIM == _ABI64 || _MIPS_SIM == _ABIN32 + void *gpsave; #endif __asm__ __volatile__ ("" : : : REGS_TO_SAVE); +#if _MIPS_SIM == _ABI64 + __asm__ __volatile__ ("sd $28,%0" : "=m" (gpsave) : : ); +#elif _MIPS_SIM == _ABIN32 + __asm__ __volatile__ ("sw $28,%0" : "=m" (gpsave) : : ); +#endif __asm__ ("move %0, $29" : "=r" (stackref) : ); { SLP_SAVE_STATE(stackref, stsizediff); @@ -37,10 +42,12 @@ slp_switch(void) ); SLP_RESTORE_STATE(); } - __asm__ __volatile__ ("" : : : REGS_TO_SAVE); -#ifdef __mips64 - gp = gpsave; +#if _MIPS_SIM == _ABI64 + __asm__ __volatile__ ("ld $28,%0" : : "m" (gpsave) : ); +#elif _MIPS_SIM == _ABIN32 + __asm__ __volatile__ ("lw $28,%0" : : "m" (gpsave) : ); #endif + __asm__ __volatile__ ("" : : : REGS_TO_SAVE); return 0; } |