eina_cpu: Detect NEON if available
authorDerek Foreman <derekf@osg.samsung.com>
Fri, 16 Sep 2016 18:05:56 +0000 (13:05 -0500)
committerDerek Foreman <derekf@osg.samsung.com>
Fri, 16 Sep 2016 19:10:49 +0000 (14:10 -0500)
We may have a few conditionals around that think this has actually been
set at some point, let's surprise them by actually doing that.

configure.ac
src/lib/eina/eina_cpu.c

index 924ceaa..d0b9962 100644 (file)
@@ -449,6 +449,8 @@ sys/types.h \
 sys/param.h \
 sys/mman.h \
 netinet/in.h \
+sys/auxv.h \
+asm/hwcap.h \
 ])
 
 EFL_CHECK_PATH_MAX
index fe39861..1de86d8 100644 (file)
 
 #include "eina_cpu_private.h"
 
+#if defined(HAVE_SYS_AUXV_H) && defined(HAVE_ASM_HWCAP_H) && defined(__arm__) && defined(__linux__)
+# include <sys/auxv.h>
+# include <asm/hwcap.h>
+#endif
+
 /*============================================================================*
 *                                  Local                                     *
 *============================================================================*/
@@ -129,6 +134,19 @@ void _x86_simd(Eina_Cpu_Features *features)
 }
 #endif
 
+#if defined(HAVE_SYS_AUXV_H) && defined(HAVE_ASM_HWCAP_H) && defined(__arm__) && defined(__linux__)
+static void
+_arm_cpu_features(Eina_Cpu_Features *features)
+{
+   unsigned long aux;
+
+   aux = getauxval(AT_HWCAP);
+
+   if (aux & HWCAP_NEON)
+     *features |= EINA_CPU_NEON;
+}
+#endif
+
 /*============================================================================*
 *                                 Global                                     *
 *============================================================================*/
@@ -147,8 +165,9 @@ eina_cpu_init(void)
 {
 #if defined(__i386__) || defined(__x86_64__)
    _x86_simd(&eina_cpu_features);
+#elif defined(HAVE_SYS_AUXV_H) && defined(HAVE_ASM_HWCAP_H) && defined(__arm__) && defined(__linux__)
+   _arm_cpu_features(&eina_cpu_features);
 #endif
-   // FIXME: Handle NEON and friends
 
    // Figure out the page size for this system
    _eina_page_size();