summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-greenlet/0001-slp_switch-Implement-for-RISCV32.patch
blob: 83877d38603629d3f72e6dc208e52cffb1320ca6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From 524fd7244cfec4ec6760e52001c9a41d1913066e Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 6 Apr 2025 20:54:08 -0700
Subject: [PATCH] slp_switch: Implement for RISCV32

Changed data types from long to int for fp variable
stackref pointer and stsizediff variable

Changed the load instruction from ld (64-bit load) to lw (32-bit load)

Upstream-Status: Submitted [https://github.com/python-greenlet/greenlet/pull/439]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 src/greenlet/platform/switch_riscv_unix.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/greenlet/platform/switch_riscv_unix.h b/src/greenlet/platform/switch_riscv_unix.h
index e74f37a..32ca78c 100644
--- a/src/greenlet/platform/switch_riscv_unix.h
+++ b/src/greenlet/platform/switch_riscv_unix.h
@@ -11,9 +11,14 @@
 static int
 slp_switch(void)
 {
-  long fp;
   int ret;
+#if __riscv_xlen == 32
+  long fp;
   long *stackref, stsizediff;
+#else
+  int fp;
+  int *stackref, stsizediff;
+#endif
   __asm__ volatile ("" : : : REGS_TO_SAVE);
   __asm__ volatile ("mv %0, fp" : "=r" (fp) : );
   __asm__ volatile ("mv %0, sp" : "=r" (stackref) : );
@@ -28,7 +33,11 @@ slp_switch(void)
       SLP_RESTORE_STATE();
   }
   __asm__ volatile ("" : : : REGS_TO_SAVE);
+#if __riscv_xlen == 32
+  __asm__ volatile ("lw fp, %0" : : "m" (fp));
+#else
   __asm__ volatile ("ld fp, %0" : : "m" (fp));
+#endif
   __asm__ volatile ("mv %0, zero" : "=r" (ret) : );
   return ret;
 }