patch attached
Description: <short summary of the patch> TODO: Put a short summary on the line above and replace this paragraph with a longer explanation of this change. Complete the meta-information with other relevant fields (see below for details). To make it easier, the information below has been extracted from the changelog. Adjust it or drop it. . python-greenlet (2.0.2-1.loong64) UNRELEASED; urgency=medium . * Add support for loongarch. Author: Xiang Liu <liuxi...@loongson.cn>
--- The information above should follow the Patch Tagging Guidelines, please checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here are templates for supplementary fields that you might want to add: Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>) Bug: <upstream-bugtracker-url> Bug-Debian: https://bugs.debian.org/<bugnumber> Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber> Forwarded: (no|not-needed|<patch-forwarded-url>) Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>) Reviewed-By: <name and email of someone who approved/reviewed the patch> Last-Update: 2023-11-16 --- python-greenlet-2.0.2.orig/setup.py +++ python-greenlet-2.0.2/setup.py @@ -58,6 +58,7 @@ if ( # # Adding the -Os flag fixes the problem. or (is_linux and plat_machine == "riscv64") + or (is_linux and plat_machine == "loongarch64") ): global_compile_args.append("-Os") --- /dev/null +++ python-greenlet-2.0.2/src/greenlet/platform/switch_loongarch64_linux.h @@ -0,0 +1,31 @@ +#define STACK_REFPLUS 1 + +#ifdef SLP_EVAL +#define STACK_MAGIC 0 + +#define REGS_TO_SAVE "s0", "s1", "s2", "s3", "s4", "s5", \ + "s6", "s7", "s8", "fp", \ + "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31" + +static int +slp_switch(void) +{ + register int ret; + register long *stackref, stsizediff; + __asm__ volatile ("" : : : REGS_TO_SAVE); + __asm__ volatile ("move %0, $sp" : "=r" (stackref) : ); + { + SLP_SAVE_STATE(stackref, stsizediff); + __asm__ volatile ( + "add.d $sp, $sp, %0\n\t" + : /* no outputs */ + : "r" (stsizediff) + ); + SLP_RESTORE_STATE(); + } + __asm__ volatile ("" : : : REGS_TO_SAVE); + __asm__ volatile ("move %0, $zero" : "=r" (ret) : ); + return ret; +} + +#endif --- python-greenlet-2.0.2.orig/src/greenlet/slp_platformselect.h +++ python-greenlet-2.0.2/src/greenlet/slp_platformselect.h @@ -38,6 +38,8 @@ extern "C" { #include "platform/switch_s390_unix.h" /* Linux/S390 */ #elif defined(__GNUC__) && defined(__s390x__) && defined(__linux__) #include "platform/switch_s390_unix.h" /* Linux/S390 zSeries (64-bit) */ +#elif defined(__GNUC__) && defined(__loongarch64) && defined(__linux__) +#include "platform/switch_loongarch64_linux.h" /* Linux/LoongArch64 */ #elif defined(__GNUC__) && defined(__arm__) #ifdef __APPLE__ #include <TargetConditionals.h>