[x264-devel] commit: Add AltiVec and CPU numbers detection on OpenBSD. (Brad )

git version control git at videolan.org
Mon Jan 19 14:29:58 CET 2009


x264 | branch: master | Brad <brad at comstyle.com> | Mon Jan 19 05:14:53 2009 -0800| [a48d1d0a2ad590d041b79bb152ed47d00451ba8d] | committer: Guillaume Poirier 

Add AltiVec and CPU numbers detection on OpenBSD.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=a48d1d0a2ad590d041b79bb152ed47d00451ba8d
---

 common/cpu.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/common/cpu.c b/common/cpu.c
index 56c88cb..01bb67b 100644
--- a/common/cpu.c
+++ b/common/cpu.c
@@ -33,6 +33,11 @@
 #include <sys/types.h>
 #include <sys/sysctl.h>
 #endif
+#ifdef SYS_OPENBSD
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <machine/cpu.h>
+#endif
 
 #include "common.h"
 #include "cpu.h"
@@ -194,13 +199,17 @@ uint32_t x264_cpu_detect( void )
 
 #elif defined( ARCH_PPC )
 
-#ifdef SYS_MACOSX
+#if defined(SYS_MACOSX) || defined(SYS_OPENBSD)
 #include <sys/sysctl.h>
 uint32_t x264_cpu_detect( void )
 {
     /* Thank you VLC */
     uint32_t cpu = 0;
+#ifdef SYS_OPENBSD
+    int      selectors[2] = { CTL_MACHDEP, CPU_ALTIVEC };
+#else
     int      selectors[2] = { CTL_HW, HW_VECTORUNIT };
+#endif
     int      has_altivec = 0;
     size_t   length = sizeof( has_altivec );
     int      error = sysctl( selectors, 2, &has_altivec, &length, NULL, 0 );
@@ -294,10 +303,15 @@ int x264_cpu_num_processors( void )
     get_system_info( &info );
     return info.cpu_count;
 
-#elif defined(SYS_MACOSX) || defined(SYS_FREEBSD)
+#elif defined(SYS_MACOSX) || defined(SYS_FREEBSD) || defined(SYS_OPENBSD)
     int numberOfCPUs;
     size_t length = sizeof( numberOfCPUs );
+#ifdef SYS_OPENBSD
+    int mib[2] = { CTL_HW, HW_NCPU };
+    if( sysctl(mib, 2, &numberOfCPUs, &length, NULL, 0) )
+#else
     if( sysctlbyname("hw.ncpu", &numberOfCPUs, &length, NULL, 0) )
+#endif
     {
         numberOfCPUs = 1;
     }



More information about the x264-devel mailing list