Skip to content
This repository was archived by the owner on Apr 2, 2021. It is now read-only.

Commit ae662a5

Browse files
committed
Use getauxval to check for NEON on Linux.
1 parent cd10773 commit ae662a5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

FastNoiseSIMD/FastNoiseSIMD.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@
6666
#ifdef _WIN32
6767
#include <intrin.h>
6868
#elif defined(FN_ARM)
69-
#if !defined(__aarch64__) && !defined(FN_IOS)
69+
#if defined(__linux__) || defined(linux) || defined(__LINUX__) || defined(__linux)
70+
#include <sys/auxv.h>
71+
#include <asm/hwcap.h>
72+
#elif !defined(__aarch64__) && !defined(FN_IOS)
7073
#include "ARM/cpu-features.h"
7174
#endif
7275
#else
@@ -81,6 +84,10 @@ int GetFastestSIMD()
8184
{
8285
#if defined(__aarch64__) || defined(FN_IOS)
8386
return FN_NEON;
87+
#elif defined(__linux__) || defined(linux) || defined(__LINUX__) || defined(__linux)
88+
if ((getauxval(AT_HWCAP) & HWCAP_NEON) != 0) {
89+
return FN_NEON;
90+
}
8491
#else
8592
if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM)
8693
{
@@ -92,9 +99,9 @@ int GetFastestSIMD()
9299
#endif
93100
return FN_NEON;
94101
}
102+
#endif
95103

96104
return FN_NO_SIMD_FALLBACK;
97-
#endif
98105
}
99106
#else
100107

0 commit comments

Comments
 (0)