0001-numpy-core-Define-RISCV-32-support.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From 0e2b652a0eff85798584116c905a2d6ad8f25d5f Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Sun, 15 Nov 2020 15:32:39 -0800
  4. Subject: [PATCH] numpy/core: Define RISCV-32 support
  5. Helps compile on riscv32
  6. Upstream-Status: Backport
  7. (https://github.com/numpy/numpy/pull/17780/commits/0e2b652a0eff85798584116c905a2d6ad8f25d5f)
  8. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  9. ---
  10. numpy/_core/include/numpy/npy_cpu.h | 9 +++++++--
  11. numpy/_core/include/numpy/npy_endian.h | 1 +
  12. 2 files changed, 8 insertions(+), 2 deletions(-)
  13. diff --git a/numpy/_core/include/numpy/npy_cpu.h b/numpy/_core/include/numpy/npy_cpu.h
  14. index a19f8e6bbd..15f9f12931 100644
  15. --- a/numpy/_core/include/numpy/npy_cpu.h
  16. +++ b/numpy/_core/include/numpy/npy_cpu.h
  17. @@ -18,6 +18,7 @@
  18. * NPY_CPU_ARCEL
  19. * NPY_CPU_ARCEB
  20. * NPY_CPU_RISCV64
  21. + * NPY_CPU_RISCV32
  22. * NPY_CPU_LOONGARCH
  23. * NPY_CPU_WASM
  24. */
  25. @@ -102,8 +103,12 @@
  26. #define NPY_CPU_ARCEL
  27. #elif defined(__arc__) && defined(__BIG_ENDIAN__)
  28. #define NPY_CPU_ARCEB
  29. -#elif defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64
  30. - #define NPY_CPU_RISCV64
  31. +#elif defined(__riscv)
  32. + #if __riscv_xlen == 64
  33. + #define NPY_CPU_RISCV64
  34. + #elif __riscv_xlen == 32
  35. + #define NPY_CPU_RISCV32
  36. + #endif
  37. #elif defined(__loongarch__)
  38. #define NPY_CPU_LOONGARCH
  39. #elif defined(__EMSCRIPTEN__)
  40. diff --git a/numpy/_core/include/numpy/npy_endian.h b/numpy/_core/include/numpy/npy_endian.h
  41. index 5e58a7f52c..09262120bf 100644
  42. --- a/numpy/_core/include/numpy/npy_endian.h
  43. +++ b/numpy/_core/include/numpy/npy_endian.h
  44. @@ -49,6 +49,7 @@
  45. || defined(NPY_CPU_PPC64LE) \
  46. || defined(NPY_CPU_ARCEL) \
  47. || defined(NPY_CPU_RISCV64) \
  48. + || defined(NPY_CPU_RISCV32) \
  49. || defined(NPY_CPU_LOONGARCH) \
  50. || defined(NPY_CPU_WASM)
  51. #define NPY_BYTE_ORDER NPY_LITTLE_ENDIAN
  52. --
  53. 2.39.5