diff --git a/celt/arm/armcpu.c b/celt/arm/armcpu.c index 6785121ac..36733b4cf 100644 --- a/celt/arm/armcpu.c +++ b/celt/arm/armcpu.c @@ -191,7 +191,7 @@ static opus_uint32 opus_cpu_capabilities(void) return flags; } -#elif defined(__FreeBSD__) +#elif defined(HAVE_ELF_AUX_INFO) #include static opus_uint32 opus_cpu_capabilities(void) @@ -239,6 +239,38 @@ static opus_uint32 opus_cpu_capabilities(void) return (flags); } +#elif defined(__OpenBSD__) +#include +#include +#include +#include + +static opus_uint32 opus_cpu_capabilities(void) +{ + opus_uint32 flags = 0; + +#if defined(OPUS_ARM_MAY_HAVE_DOTPROD) && defined(CPU_ID_AA64ISAR0) + const int isar0_mib[] = { CTL_MACHDEP, CPU_ID_AA64ISAR0 }; + uint64_t isar0; + size_t len = sizeof(isar0); + + if (sysctl(isar0_mib, 2, &isar0, &len, NULL, 0) != -1) + { + if (ID_AA64ISAR0_DP(isar0) >= ID_AA64ISAR0_DP_IMPL) + flags |= OPUS_CPU_ARM_DOTPROD_FLAG; + } +#endif + +#if defined(OPUS_ARM_PRESUME_NEON_INTR) \ + || defined(OPUS_ARM_PRESUME_AARCH64_NEON_INTR) + flags |= OPUS_CPU_ARM_EDSP_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_NEON_FLAG; +# if defined(OPUS_ARM_PRESUME_DOTPROD) + flags |= OPUS_CPU_ARM_DOTPROD_FLAG; +# endif +#endif + return flags; +} + #else /* The feature registers which can tell us what the processor supports are * accessible in priveleged modes only, so we can't have a general user-space diff --git a/configure.ac b/configure.ac index 78defd6f4..f671f18f1 100644 --- a/configure.ac +++ b/configure.ac @@ -1032,7 +1032,7 @@ AC_CHECK_FUNCS([lrintf]) AC_CHECK_FUNCS([lrint]) LIBS="$saved_LIBS" -AC_CHECK_FUNCS([__malloc_hook]) +AC_CHECK_FUNCS([__malloc_hook elf_aux_info]) AC_SUBST([PC_BUILD]) diff --git a/meson.build b/meson.build index d040ddfd7..aadf7caf3 100644 --- a/meson.build +++ b/meson.build @@ -83,6 +83,7 @@ libm = cc.find_library('m', required : false) opus_conf.set('HAVE_LRINTF', cc.has_function('lrintf', prefix: '#include ', dependencies: libm)) opus_conf.set('HAVE_LRINT', cc.has_function('lrint', prefix: '#include ', dependencies: libm)) opus_conf.set('HAVE___MALLOC_HOOK', cc.has_function('__malloc_hook', prefix: '#include ')) +opus_conf.set('HAVE_ELF_AUX_INFO', cc.has_function('elf_aux_info', prefix: '#include ')) opus_conf.set('HAVE_STDINT_H', cc.check_header('stdint.h')) # Check for restrict keyword