Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/arch/simddetect.cpp: fix NEON detection on FreeBSD #3782

Merged
merged 6 commits into from
May 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/arch/simddetect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@
#if defined(HAVE_NEON) && !defined(__aarch64__)
# ifdef ANDROID
# include <cpu-features.h>
# else
/* Assume linux */
# elif defined(__linux__)
# include <asm/hwcap.h>
# include <sys/auxv.h>
# elif defined(__FreeBSD__)
clausecker marked this conversation as resolved.
Show resolved Hide resolved
# include <sys/auxv.h>
# include <sys/elf.h>
# endif
#endif

Expand All @@ -85,7 +87,7 @@ SIMDDetect SIMDDetect::detector;
bool SIMDDetect::neon_available_ = true;
#elif defined(HAVE_NEON)
// If true, then Neon has been detected.
bool SIMDDetect::neon_available_;
bool SIMDDetect::neon_available_ = false;
clausecker marked this conversation as resolved.
Show resolved Hide resolved
clausecker marked this conversation as resolved.
Show resolved Hide resolved
#else
// If true, then AVX has been detected.
bool SIMDDetect::avx_available_;
Expand Down Expand Up @@ -216,9 +218,12 @@ SIMDDetect::SIMDDetect() {
if (family == ANDROID_CPU_FAMILY_ARM)
neon_available_ = (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON);
}
# else
/* Assume linux */
# elif defined(__linux__)
clausecker marked this conversation as resolved.
Show resolved Hide resolved
neon_available_ = getauxval(AT_HWCAP) & HWCAP_NEON;
# elif defined(__FreeBSD__)
unsigned long hwcap = 0;
elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
neon_available_ = hwcap & HWCAP_NEON;
# endif
#endif

Expand Down