diff options
author | Sayed Adel <seiko@imavr.com> | 2022-12-31 11:51:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-31 11:51:08 +0200 |
commit | 77f15776e1d6d1357cd8c45dd297da821e18e0c2 (patch) | |
tree | bf425d690cc60271dbc24574df395fc0749a424a | |
parent | 68d7aadd30cb7a4f6f32e76715b38b644df18602 (diff) | |
parent | b748b846800270949c187a5f462d776648d7ab09 (diff) | |
download | numpy-77f15776e1d6d1357cd8c45dd297da821e18e0c2.tar.gz |
Merge pull request #22777 from pkubaj/patch-1
ENH: Properly support FreeBSD/powerpc64
-rw-r--r-- | numpy/core/src/common/npy_cpu_features.c | 16 | ||||
-rw-r--r-- | numpy/distutils/ccompiler_opt.py | 8 |
2 files changed, 20 insertions, 4 deletions
diff --git a/numpy/core/src/common/npy_cpu_features.c b/numpy/core/src/common/npy_cpu_features.c index 7563979d1..949c75ad5 100644 --- a/numpy/core/src/common/npy_cpu_features.c +++ b/numpy/core/src/common/npy_cpu_features.c @@ -513,7 +513,10 @@ npy__cpu_init_features(void) #elif defined(NPY_CPU_PPC64) || defined(NPY_CPU_PPC64LE) -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) + #ifdef __FreeBSD__ + #include <machine/cpu.h> // defines PPC_FEATURE_HAS_VSX + #endif #include <sys/auxv.h> #ifndef AT_HWCAP2 #define AT_HWCAP2 26 @@ -533,12 +536,21 @@ static void npy__cpu_init_features(void) { memset(npy__cpu_have, 0, sizeof(npy__cpu_have[0]) * NPY_CPU_FEATURE_MAX); +#if defined(__linux__) || defined(__FreeBSD__) #ifdef __linux__ unsigned int hwcap = getauxval(AT_HWCAP); if ((hwcap & PPC_FEATURE_HAS_VSX) == 0) return; hwcap = getauxval(AT_HWCAP2); +#else + unsigned long hwcap; + elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); + if ((hwcap & PPC_FEATURE_HAS_VSX) == 0) + return; + + elf_aux_info(AT_HWCAP2, &hwcap, sizeof(hwcap)); +#endif // __linux__ if (hwcap & PPC_FEATURE2_ARCH_3_1) { npy__cpu_have[NPY_CPU_FEATURE_VSX] = @@ -551,7 +563,7 @@ npy__cpu_init_features(void) npy__cpu_have[NPY_CPU_FEATURE_VSX2] = (hwcap & PPC_FEATURE2_ARCH_2_07) != 0; npy__cpu_have[NPY_CPU_FEATURE_VSX3] = (hwcap & PPC_FEATURE2_ARCH_3_00) != 0; npy__cpu_have[NPY_CPU_FEATURE_VSX4] = (hwcap & PPC_FEATURE2_ARCH_3_1) != 0; -// TODO: AIX, FreeBSD +// TODO: AIX, OpenBSD #else npy__cpu_have[NPY_CPU_FEATURE_VSX] = 1; #if defined(NPY_CPU_PPC64LE) || defined(NPY_HAVE_VSX2) diff --git a/numpy/distutils/ccompiler_opt.py b/numpy/distutils/ccompiler_opt.py index 5f18efc7d..da550722c 100644 --- a/numpy/distutils/ccompiler_opt.py +++ b/numpy/distutils/ccompiler_opt.py @@ -959,8 +959,12 @@ class _CCompiler: detect_arch = ( ("cc_on_x64", ".*(x|x86_|amd)64.*", ""), ("cc_on_x86", ".*(win32|x86|i386|i686).*", ""), - ("cc_on_ppc64le", ".*(powerpc|ppc)64(el|le).*", ""), - ("cc_on_ppc64", ".*(powerpc|ppc)64.*", ""), + ("cc_on_ppc64le", ".*(powerpc|ppc)64(el|le).*|.*powerpc.*", + "defined(__powerpc64__) && " + "defined(__LITTLE_ENDIAN__)"), + ("cc_on_ppc64", ".*(powerpc|ppc).*|.*powerpc.*", + "defined(__powerpc64__) && " + "defined(__BIG_ENDIAN__)"), ("cc_on_aarch64", ".*(aarch64|arm64).*", ""), ("cc_on_armhf", ".*arm.*", "defined(__ARM_ARCH_7__) || " "defined(__ARM_ARCH_7A__)"), |