- Add support for x264 detecting the number of CPUs via the
hw.ncpu sysctl. - Switch the AltiVec code from using the signals method of presence detection to using the machdep.altivec sysctl. ok kili@
This commit is contained in:
parent
0686f65669
commit
acf00b96dc
@ -1,10 +1,10 @@
|
||||
# $OpenBSD: Makefile,v 1.7 2008/08/22 12:43:33 brad Exp $
|
||||
# $OpenBSD: Makefile,v 1.8 2008/08/28 15:23:31 brad Exp $
|
||||
|
||||
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
|
||||
|
@ -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;
|
||||
}
|
||||
$OpenBSD: patch-common_cpu_c,v 1.3 2008/08/28 15:23:31 brad Exp $
|
||||
--- 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user