ref: d411d768b6cf3d6b5e51f279eaec3d59e6233a2c
parent: 9cf34e76156205551b702c671c33609c536fb08b
author: Martin Storsjö <martin@martin.st>
date: Fri Feb 28 20:51:59 EST 2014
Add cpu feature detection for generic arm/linux For platforms without runtime detection, assume whoever built it with HAVE_NEON actually wanted it.
--- a/codec/common/cpu.cpp
+++ b/codec/common/cpu.cpp
@@ -38,6 +38,7 @@
*************************************************************************************
*/
#include <string.h>
+#include <stdio.h>
#ifdef ANDROID_NDK
#include <cpu-features.h>
#endif
@@ -258,9 +259,39 @@
}
return uiCPU;
}
+#elif defined(__linux__)
+
+/* Generic arm/linux cpu feature detection */
+uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
+ FILE *f = fopen("/proc/cpuinfo", "r");
+
+ if (!f)
+ return 0;
+
+ char buf[200];
+ int flags = 0;
+ while (fgets(buf, sizeof(buf), f)) {
+ if (!strncmp(buf, "Features", strlen("Features"))) {
+ if (strstr(buf, " neon "))
+ flags |= WELS_CPU_NEON;
+ if (strstr(buf, " vfpv3 "))
+ flags |= WELS_CPU_VFPv3;
+ break;
+ }
+ }
+ fclose(f);
+ return flags;
+}
+
#else /* HAVE_NEON enabled but no runtime detection */
+
+/* No runtime feature detection available, but built with HAVE_NEON - assume
+ * that NEON and all associated features are available. */
+
uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
- return 0;
+ return WELS_CPU_ARMv7 |
+ WELS_CPU_VFPv3 |
+ WELS_CPU_NEON;
}
#endif
#else /* Neither X86_ASM nor HAVE_NEON */