[x264-devel] [PATCH] add support for FreeBSD in common/cpu.c

Igor Mozolevsky igor at hybrid-lab.co.uk
Sun Dec 30 22:59:37 CET 2007


--- common/cpu.c.orig	2007-12-30 21:40:50.000000000 +0000
+++ common/cpu.c	2007-12-30 21:44:20.000000000 +0000
@@ -28,7 +28,7 @@
 #ifdef SYS_BEOS
 #include <kernel/OS.h>
 #endif
-#ifdef SYS_MACOSX
+#if defined(SYS_MACOSX) || defined(__FreeBSD__)
 #include <sys/types.h>
 #include <sys/sysctl.h>
 #endif
@@ -237,14 +237,10 @@
     get_system_info( &info );
     return info.cpu_count;

-#elif defined(SYS_MACOSX)
+#elif defined(SYS_MACOSX) || defined(__FreeBSD__)
     int numberOfCPUs;
     size_t length = sizeof( numberOfCPUs );
-    if( sysctlbyname("hw.ncpu", &numberOfCPUs, &length, NULL, 0) )
-    {
-        numberOfCPUs = 1;
-    }
-    return numberOfCPUs;
+    return sysctlbyname("hw.ncpu", &numberOfCPUs, &length, NULL, 0)
!= 0 ? 1 : numberOfCPUs;

 #else
     return 1;



More information about the x264-devel mailing list