summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2021-01-14 20:25:49 +0000
committerDavid Carlier <devnexen@gmail.com>2021-01-17 15:47:21 +0000
commitc47e9621ebf76f8085ff5ec8b01c07921d14f6a7 (patch)
treed1790f631cc386cfd15513333cf485d96ed102f7 /numpy/core
parent5c7002926ec8ad12785b36024f9da80b7017ad1c (diff)
downloadnumpy-c47e9621ebf76f8085ff5ec8b01c07921d14f6a7.tar.gz
ENH: cpu features detection implementation on FreeBSD ARM
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/src/common/npy_cpu_features.c.src25
1 files changed, 24 insertions, 1 deletions
diff --git a/numpy/core/src/common/npy_cpu_features.c.src b/numpy/core/src/common/npy_cpu_features.c.src
index 69bbc83a2..4f3a95c71 100644
--- a/numpy/core/src/common/npy_cpu_features.c.src
+++ b/numpy/core/src/common/npy_cpu_features.c.src
@@ -500,7 +500,7 @@ npy__cpu_init_features_arm8(void)
npy__cpu_have[NPY_CPU_FEATURE_ASIMD] = 1;
}
-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__)
/*
* we aren't sure of what kind kernel or clib we deal with
* so we play it safe
@@ -509,10 +509,23 @@ npy__cpu_init_features_arm8(void)
#include "npy_cpuinfo_parser.h"
__attribute__((weak)) unsigned long getauxval(unsigned long); // linker should handle it
+#ifdef __FreeBSD__
+__attribute__((weak)) int elf_aux_info(int, void *, int); // linker should handle it
+
+static unsigned long getauxval(unsigned long k)
+{
+ unsigned long val = 0ul;
+ if (elf_aux_info == 0 || elf_aux_info((int)k, (void *)&val, (int)sizeof(val)) != 0) {
+ return 0ul;
+ }
+ return val;
+}
+#endif
static int
npy__cpu_init_features_linux(void)
{
unsigned long hwcap = 0, hwcap2 = 0;
+ #ifdef __linux__
if (getauxval != 0) {
hwcap = getauxval(NPY__HWCAP);
#ifdef __arm__
@@ -539,7 +552,14 @@ npy__cpu_init_features_linux(void)
close(fd);
}
}
+ #else
+ hwcap = getauxval(NPY__HWCAP);
+ #ifdef __arm__
+ hwcap2 = getauxval(NPY__HWCAP2);
+ #endif
+ #endif
if (hwcap == 0 && hwcap2 == 0) {
+ #ifdef __linux__
/*
* try parsing with /proc/cpuinfo, if sandboxed
* failback to compiler definitions
@@ -547,6 +567,9 @@ npy__cpu_init_features_linux(void)
if(!get_feature_from_proc_cpuinfo(&hwcap, &hwcap2)) {
return 0;
}
+ #else
+ return 0;
+ #endif
}
#ifdef __arm__
// Detect Arm8 (aarch32 state)