diff options
author | Bran <bran_avan@hotmail.co.uk> | 2019-04-05 06:59:33 +0100 |
---|---|---|
committer | Bran <bran_avan@hotmail.co.uk> | 2019-04-05 06:59:33 +0100 |
commit | d90f854af4b2ba1f0ac6eb9c36bcfe53ffa7cf1d (patch) | |
tree | 76762f746a33a5990bc78a20bba086308beded84 /numpy/_build_utils | |
parent | 95342f6df4952bc88c5a02e1f3f8909ced05ae7f (diff) | |
download | numpy-d90f854af4b2ba1f0ac6eb9c36bcfe53ffa7cf1d.tar.gz |
BUG: Use C call to sysctlbyname for AVX detection on MacOS
Diffstat (limited to 'numpy/_build_utils')
-rw-r--r-- | numpy/_build_utils/src/apple_sgemv_fix.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/numpy/_build_utils/src/apple_sgemv_fix.c b/numpy/_build_utils/src/apple_sgemv_fix.c index aef7ff534..c33c68992 100644 --- a/numpy/_build_utils/src/apple_sgemv_fix.c +++ b/numpy/_build_utils/src/apple_sgemv_fix.c @@ -69,26 +69,34 @@ static int AVX_and_10_9 = 0; /* Dynamic check for AVX support * __builtin_cpu_supports("avx") is available in gcc 4.8, * but clang and icc do not currently support it. */ -static inline int cpu_supports_avx() { +static inline int +cpu_supports_avx() +{ int enabled, r; size_t length = sizeof(enabled); r = sysctlbyname("hw.optional.avx1_0", &enabled, &length, NULL, 0); - if ( r == 0 && enabled != 0) + if ( r == 0 && enabled != 0) { return 1; - else + } + else { return 0; + } } /* Check if we are using MacOS X version 10.9 */ -static inline int using_mavericks() { +static inline int +using_mavericks() +{ int r; char str[32] = {0}; size_t size = sizeof(str); r = sysctlbyname("kern.osproductversion", str, &size, NULL, 0); - if ( r == 0 && strncmp(str, "10.9", strlen("10.9")) == 0) + if ( r == 0 && strncmp(str, "10.9", strlen("10.9")) == 0) { return 1; - else + } + else { return 0; + } } __attribute__((destructor)) |