The following diff for x264 switches the library from using
the signals method of AltiVec detection to using the sysctl
method and adds support for detecting the # of CPUs using
the sysctl.
Index: Makefile
===================================================================
RCS file: /cvs/ports/multimedia/x264/Makefile,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile
--- Makefile 22 Aug 2008 12:43:33 -0000 1.7
+++ Makefile 24 Aug 2008 02:43:06 -0000
@@ -4,7 +4,7 @@ COMMENT= free H264/AVC encoder
V= 20080713
DISTNAME= x264-snapshot-${V}-2245
-PKGNAME= x264-${V}p1
+PKGNAME= x264-${V}p2
CATEGORIES= multimedia
MASTER_SITES= ftp://ftp.videolan.org/pub/videolan/x264/snapshots/
EXTRACT_SUFX= .tar.bz2
Index: patches/patch-common_cpu_c
===================================================================
RCS file: /cvs/ports/multimedia/x264/patches/patch-common_cpu_c,v
retrieving revision 1.2
diff -u -p -r1.2 patch-common_cpu_c
--- patches/patch-common_cpu_c 22 Jul 2008 20:24:04 -0000 1.2
+++ patches/patch-common_cpu_c 24 Aug 2008 02:43:06 -0000
@@ -1,12 +1,67 @@
$OpenBSD: patch-common_cpu_c,v 1.2 2008/07/22 20:24:04 brad Exp $
---- common/cpu.c.orig Fri Jul 4 16:45:05 2008
-+++ common/cpu.c Tue Jul 8 23:59:12 2008
-@@ -201,7 +201,7 @@ uint32_t x264_cpu_detect( void )
- return cpu;
- }
+--- common/cpu.c.orig Sun Jul 13 16:45:06 2008
++++ common/cpu.c Thu Aug 14 20:58:30 2008
+@@ -32,6 +32,10 @@
+ #include <sys/types.h>
+ #include <sys/sysctl.h>
+ #endif
++#ifdef SYS_OPENBSD
++#include <sys/param.h>
++#include <sys/sysctl.h>
++#endif
--#elif defined( SYS_LINUX )
-+#elif defined SYS_LINUX || defined SYS_OPENBSD
- #include <signal.h>
- #include <setjmp.h>
- static sigjmp_buf jmpbuf;
+ #include "common.h"
+ #include "cpu.h"
+@@ -182,17 +186,28 @@ uint32_t x264_cpu_detect( void )
+
+ #elif defined( ARCH_PPC )
+
+-#ifdef SYS_MACOSX
++#if defined(SYS_MACOSX) || defined(SYS_OPENBSD)
+ #include <sys/sysctl.h>
++#ifdef SYS_OPENBSD
++#include <machine/cpu.h>
++#endif
+ uint32_t x264_cpu_detect( void )
+ {
+ /* Thank you VLC */
+ uint32_t cpu = 0;
+- int selectors[2] = { CTL_HW, HW_VECTORUNIT };
+- int has_altivec = 0;
++ int selectors[2];
++ int has_altivec = 0, error;
+ size_t length = sizeof( has_altivec );
+- int error = sysctl( selectors, 2, &has_altivec, &length, NULL, 0 );
+
++#ifdef SYS_OPENBSD
++ selectors[0] = CTL_MACHDEP;
++ selectors[1] = CPU_ALTIVEC;
++#else
++ selectors[0] = CTL_HW;
++ selectors[1] = HW_VECTORUNIT;
++#endif
++
++ error = sysctl( selectors, 2, &has_altivec, &length, NULL, 0 );
+ if( error == 0 && has_altivec != 0 )
+ {
+ cpu |= X264_CPU_ALTIVEC;
+@@ -286,6 +301,19 @@ int x264_cpu_num_processors( void )
+ int numberOfCPUs;
+ size_t length = sizeof( numberOfCPUs );
+ if( sysctlbyname("hw.ncpu", &numberOfCPUs, &length, NULL, 0) )
++ {
++ numberOfCPUs = 1;
++ }
++ return numberOfCPUs;
++
++#elif defined(SYS_OPENBSD)
++ int mib[2], numberOfCPUs;
++ size_t length = sizeof( numberOfCPUs );
++
++ mib[0] = CTL_HW;
++ mib[1] = HW_NCPU;
++
++ if( sysctl(mib, 2, &numberOfCPUs, &length, NULL, 0) )
+ {
+ numberOfCPUs = 1;
+ }
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.