Skip to content

Commit 1652d31

Browse files
committed
MAINT: LoongArch: switch away from the __loongarch64 preprocessor macro
According to the *Toolchain Conventions of the LoongArch Architecture* specification (v1.1) [1], the `__loongarch64` preprocessor macro is in fact a legacy symbol retained for compatibility; the reason being that the GPR width and the calling convention in use are orthogonal to each other, and in reality we care about the calling convention (e.g. ILP32 or LP64) more often than about the hardware capability -- think of ILP32 code on 64-bit hardware, in which case the GPR is wider than what a pointer actually can occupy, for example. As for the two modified places, the header change is actually concerned with the calling convention; and while the implementation change is actually correct regardless of bitness or calling convention, the Loongson maintainer prefers staying with `__loongarch_lp64` to be extra safe against possible API changes for the future ILP32 ABI. [1]: https://github.com/loongson/la-toolchain-conventions/blob/releases/v1.1/LoongArch-toolchain-conventions-EN.adoc
1 parent 18ea55b commit 1652d31

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

numpy/_core/include/numpy/npy_cpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
#elif __riscv_xlen == 32
110110
#define NPY_CPU_RISCV32
111111
#endif
112-
#elif defined(__loongarch64)
112+
#elif defined(__loongarch_lp64)
113113
#define NPY_CPU_LOONGARCH64
114114
#elif defined(__EMSCRIPTEN__)
115115
/* __EMSCRIPTEN__ is defined by emscripten: an LLVM-to-Web compiler */

numpy/_core/src/common/npy_cpu_features.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ npy__cpu_init_features(void)
668668

669669
/***************** LoongArch ******************/
670670

671-
#elif defined(__loongarch64)
671+
#elif defined(__loongarch_lp64)
672672

673673
#include <sys/auxv.h>
674674
#include <asm/hwcap.h>
@@ -685,7 +685,6 @@ npy__cpu_init_features(void)
685685
}
686686
}
687687

688-
689688
/***************** ARM ******************/
690689

691690
#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64)

0 commit comments

Comments
 (0)