Skip to content

Commit 13feb0b

Browse files
authored
Merge pull request #439 from kraj/kraj/riscv32
slp_switch: Implement for RISCV32
2 parents 46f2d13 + 93e9618 commit 13feb0b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/greenlet/platform/switch_riscv_unix.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@
1111
static int
1212
slp_switch(void)
1313
{
14-
long fp;
1514
int ret;
15+
#if __riscv_xlen == 32
16+
long fp;
1617
long *stackref, stsizediff;
18+
#else
19+
int fp;
20+
int *stackref, stsizediff;
21+
#endif
1722
__asm__ volatile ("" : : : REGS_TO_SAVE);
1823
__asm__ volatile ("mv %0, fp" : "=r" (fp) : );
1924
__asm__ volatile ("mv %0, sp" : "=r" (stackref) : );
@@ -28,7 +33,11 @@ slp_switch(void)
2833
SLP_RESTORE_STATE();
2934
}
3035
__asm__ volatile ("" : : : REGS_TO_SAVE);
36+
#if __riscv_xlen == 32
37+
__asm__ volatile ("lw fp, %0" : : "m" (fp));
38+
#else
3139
__asm__ volatile ("ld fp, %0" : : "m" (fp));
40+
#endif
3241
__asm__ volatile ("mv %0, zero" : "=r" (ret) : );
3342
return ret;
3443
}

0 commit comments

Comments
 (0)