util: detect NEON at runtime on FreeBSD
authorJan Beich <jbeich@FreeBSD.org>
Mon, 16 Sep 2019 11:34:28 +0000 (11:34 +0000)
committerMatt Turner <mattst88@gmail.com>
Wed, 9 Oct 2019 19:55:10 +0000 (12:55 -0700)
Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Jan Beich <jbeich@FreeBSD.org>
src/util/u_cpu_detect.c

index 387003d6cba761762f6de8233ff76d71cb0bc94a..19b21b0aa44a98dbbe24ad489395cf0c9da06a38 100644 (file)
 #if defined(PIPE_OS_FREEBSD) || defined(PIPE_OS_DRAGONFLY)
 #include <sys/types.h>
 #include <sys/sysctl.h>
+#if __has_include(<sys/auxv.h>)
+#include <sys/auxv.h>
+#define HAVE_ELF_AUX_INFO
+#endif
 #endif
 
 #if defined(PIPE_OS_LINUX)
@@ -362,6 +366,11 @@ check_os_arm_support(void)
     */
 #if defined(__ARM_NEON) || defined(__ARM_NEON__)
    util_cpu_caps.has_neon = 1;
+#elif defined(PIPE_OS_FREEBSD) && defined(HAVE_ELF_AUX_INFO)
+   unsigned long hwcap = 0;
+   elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
+   if (hwcap & HWCAP_NEON)
+      util_cpu_caps.has_neon = 1;
 #elif defined(HAS_ANDROID_CPUFEATURES)
    AndroidCpuFamily cpu_family = android_getCpuFamily();
    uint64_t cpu_features = android_getCpuFeatures();