[x264-devel] [PATCH] Add x264_cpu_detect() for NetBSD/macppc.

Martin Husemann martin at NetBSD.org
Thu Jan 5 14:45:16 UTC 2023


The altivec instruction set detection is very similar to FreeBSD
and OpenBSD, but uses slightly different sysctl selectors.

Without this change there is no x264_cpu_detect() function compiled
for NetBSD/macppc and linking fails.

---
 common/cpu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/cpu.c b/common/cpu.c
index 41a4c1d7..9acb37e8 100644
--- a/common/cpu.c
+++ b/common/cpu.c
@@ -305,7 +305,7 @@ uint32_t x264_cpu_detect( void )
 
 #elif HAVE_ALTIVEC
 
-#if SYS_MACOSX || SYS_OPENBSD || SYS_FREEBSD
+#if SYS_MACOSX || SYS_OPENBSD || SYS_FREEBSD || SYS_NETBSD
 
 uint32_t x264_cpu_detect( void )
 {
@@ -320,6 +320,8 @@ uint32_t x264_cpu_detect( void )
     size_t   length = sizeof( has_altivec );
 #if SYS_MACOSX || SYS_OPENBSD
     int      error = sysctl( selectors, 2, &has_altivec, &length, NULL, 0 );
+#elif SYS_NETBSD
+    int      error = sysctlbyname( "machdep.altivec", &has_altivec, &length, NULL, 0 );
 #else
     int      error = sysctlbyname( "hw.altivec", &has_altivec, &length, NULL, 0 );
 #endif
-- 
2.38.1



More information about the x264-devel mailing list