Skip to content

Commit aedd843

Browse files
authored
Merge pull request #404 from xypron/riscv64
platform: riscv64: fix building with -fno-omit-frame-pointer
2 parents 1efb038 + de3c5ad commit aedd843

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/greenlet/platform/switch_riscv_unix.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,32 @@
33
#ifdef SLP_EVAL
44
#define STACK_MAGIC 0
55

6-
#define REGS_TO_SAVE "s0", "s1", "s2", "s3", "s4", "s5", \
6+
#define REGS_TO_SAVE "s1", "s2", "s3", "s4", "s5", \
77
"s6", "s7", "s8", "s9", "s10", "s11", "fs0", "fs1", \
88
"fs2", "fs3", "fs4", "fs5", "fs6", "fs7", "fs8", "fs9", \
99
"fs10", "fs11"
1010

1111
static int
1212
slp_switch(void)
1313
{
14+
long fp;
1415
int ret;
1516
long *stackref, stsizediff;
1617
__asm__ volatile ("" : : : REGS_TO_SAVE);
18+
__asm__ volatile ("mv %0, fp" : "=r" (fp) : );
1719
__asm__ volatile ("mv %0, sp" : "=r" (stackref) : );
1820
{
1921
SLP_SAVE_STATE(stackref, stsizediff);
2022
__asm__ volatile (
2123
"add sp, sp, %0\n\t"
24+
"add fp, fp, %0\n\t"
2225
: /* no outputs */
2326
: "r" (stsizediff)
2427
);
2528
SLP_RESTORE_STATE();
2629
}
2730
__asm__ volatile ("" : : : REGS_TO_SAVE);
31+
__asm__ volatile ("ld fp, %0" : : "m" (fp));
2832
__asm__ volatile ("mv %0, zero" : "=r" (ret) : );
2933
return ret;
3034
}

0 commit comments

Comments
 (0)