Commit 3674cf4f authored by Anton Mitrofanov's avatar Anton Mitrofanov Committed by Fiona Glaser

Re-add support for glibc <2.6, which doesn't have CPU_COUNT

parent 1dd4b85f
......@@ -29,7 +29,7 @@
#include "common.h"
#include "cpu.h"
#if HAVE_PTHREAD && SYS_LINUX
#if HAVE_POSIXTHREAD && SYS_LINUX
#include <sched.h>
#endif
#if SYS_BEOS
......@@ -366,7 +366,17 @@ int x264_cpu_num_processors( void )
#elif SYS_LINUX
cpu_set_t p_aff;
return sched_getaffinity( 0, sizeof(p_aff), &p_aff ) ? 1 : CPU_COUNT(&p_aff);
memset( &p_aff, 0, sizeof(p_aff) );
if( sched_getaffinity( 0, sizeof(p_aff), &p_aff ) )
return 1;
#if HAVE_CPU_COUNT
return CPU_COUNT(&p_aff);
#else
int np = 0;
for( unsigned int bit = 0; bit < 8 * sizeof(p_aff); bit++ )
np += (((uint8_t *)&p_aff)[bit / 8] >> (bit % 8)) & 1;
return np;
#endif
#elif SYS_BEOS
system_info info;
......
......@@ -249,7 +249,7 @@ cross_prefix=""
EXE=""
# list of all preprocessor HAVE values we can define
CONFIG_HAVE="MALLOC_H ALTIVEC ALTIVEC_H MMX ARMV6 ARMV6T2 NEON BEOSTHREAD POSIXTHREAD WIN32THREAD THREAD LOG2F VISUALIZE SWSCALE LAVF FFMS GPAC GF_MALLOC AVS GPL VECTOREXT INTERLACED"
CONFIG_HAVE="MALLOC_H ALTIVEC ALTIVEC_H MMX ARMV6 ARMV6T2 NEON BEOSTHREAD POSIXTHREAD WIN32THREAD THREAD LOG2F VISUALIZE SWSCALE LAVF FFMS GPAC GF_MALLOC AVS GPL VECTOREXT INTERLACED CPU_COUNT"
# parse options
......@@ -703,6 +703,9 @@ fi
if [ "$thread" = "posix" ]; then
LDFLAGS="$LDFLAGS $libpthread"
define HAVE_POSIXTHREAD
if [ "$SYS" = "LINUX" ] && cc_check sched.h "-D_GNU_SOURCE -Werror" "cpu_set_t p_aff; return CPU_COUNT(&p_aff);" ; then
define HAVE_CPU_COUNT
fi
fi
if [ "$thread" = "win32" ]; then
# cygwin does not support win32 threads
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment