aarch64: Add OpenBSD runtime detection of dotprod and i8mm using sysctl Signed-off-by: Brad Smith <b...@comstyle.com> --- libavutil/aarch64/cpu.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
diff --git a/libavutil/aarch64/cpu.c b/libavutil/aarch64/cpu.c index 196bdaf6b0..1ea2b94679 100644 --- a/libavutil/aarch64/cpu.c +++ b/libavutil/aarch64/cpu.c @@ -20,6 +20,10 @@ #include "libavutil/cpu_internal.h" #include "config.h" +#ifdef __OpenBSD__ +#include <machine/cpu.h> +#endif + #if (defined(__linux__) || defined(__ANDROID__)) && HAVE_GETAUXVAL #include <stdint.h> #include <sys/auxv.h> @@ -65,6 +69,40 @@ static int detect_flags(void) return flags; } +#elif defined(__OpenBSD__) && defined(CPU_ID_AA64ISAR0) +#include <machine/armreg.h> +#include <sys/types.h> +#include <sys/sysctl.h> + +static int detect_flags(void) +{ + int flags = 0; + int mib[2]; + uint64_t isar0; + uint64_t isar1; + size_t len; + + mib[0] = CTL_MACHDEP; + mib[1] = CPU_ID_AA64ISAR0; + len = sizeof(isar0); + if (sysctl(mib, 2, &isar0, &len, NULL, 0) != -1) { + if (ID_AA64ISAR0_DP(isar0) >= ID_AA64ISAR0_DP_IMPL) + flags |= AV_CPU_FLAG_DOTPROD; + } + + mib[0] = CTL_MACHDEP; + mib[1] = CPU_ID_AA64ISAR1; + len = sizeof(isar1); + if (sysctl(mib, 2, &isar1, &len, NULL, 0) != -1) { +#ifdef ID_AA64ISAR1_I8MM_IMPL + if (ID_AA64ISAR1_I8MM(isar1) >= ID_AA64ISAR1_I8MM_IMPL) + flags |= AV_CPU_FLAG_I8MM; +#endif + } + + return flags; +} + #elif defined(_WIN32) #include <windows.h> -- 2.45.1