[x264-devel] x264_cpu_num_processors and sysconf

Evan McClain evan.mcclain at gatech.edu
Wed Jan 13 07:12:49 CET 2010


After working on cleaning up the build on recent versions of opensolaris 
I noticed that x264_cpu_num_processors() would always return 1 for 
SunOS. Attached is a patch that uses sysconf(_SC_NPROCESSORS_ONLN) to 
return the number of online processors when possible.

The attached patch will use sysconf() if _SC_NPROCESSORS_ONLN is 
defined, which it is for SunOS and Linux. It should also be defined for 
FreeBSD, NetBSD, and Mac OS X but I haven't tested on those systems. I 
don't know about BeOS or OpenBSD.

Is there any reason why sysconf() isn't used for Linux? If not, the 
Linux section could be safely removed and the BSD section could be 
cleaned up.

Also attached is cpu.c which should check to see if sysconf() and the 
current x264_cpu_num_processors() return different values.

-- 
Evan McClain
Aerospace Engineering
Graduate Student Senator  .
evan.mcclain at gatech.edu  ..:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Use-sysconf-_SC_NPROCESSORS_ONLN-to-get-number-of-pr.patch
Type: text/x-patch
Size: 740 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x264-devel/attachments/20100113/b6d28f94/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cpu.c
Type: text/x-c++src
Size: 372 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x264-devel/attachments/20100113/b6d28f94/attachment.cc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 271 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x264-devel/attachments/20100113/b6d28f94/attachment.pgp>


More information about the x264-devel mailing list