From 75d404913b1f84f13bb2c4586b725e646566f947 Mon Sep 17 00:00:00 2001 From: Yu Xiaolei Date: Sun, 23 Feb 2014 04:12:51 -0800 Subject: [PATCH] Fix build with Android NDK Android NDK does not expose sched_getaffinity. --- common/cpu.c | 5 +++++ configure | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/common/cpu.c b/common/cpu.c index f2c72123..f1ae2662 100644 --- a/common/cpu.c +++ b/common/cpu.c @@ -426,6 +426,10 @@ int x264_cpu_num_processors( void ) return sysconf( _SC_NPROCESSORS_ONLN ); #elif SYS_LINUX +#ifdef __ANDROID__ + // Android NDK does not expose sched_getaffinity + return sysconf( _SC_NPROCESSORS_CONF ); +#else cpu_set_t p_aff; memset( &p_aff, 0, sizeof(p_aff) ); if( sched_getaffinity( 0, sizeof(p_aff), &p_aff ) ) @@ -438,6 +442,7 @@ int x264_cpu_num_processors( void ) np += (((uint8_t *)&p_aff)[bit / 8] >> (bit % 8)) & 1; return np; #endif +#endif #elif SYS_BEOS system_info info; diff --git a/configure b/configure index 0177cfce..49a3d8ff 100755 --- a/configure +++ b/configure @@ -806,10 +806,15 @@ if [ "$thread" = "auto" ]; then fi ;; QNX) - cc_check pthread.h -lc && thread="posix" && libpthread="-lc" + cc_check pthread.h -lc "pthread_create(0,0,0,0);" && thread="posix" && libpthread="-lc" ;; *) - cc_check pthread.h -lpthread && thread="posix" && libpthread="-lpthread" + if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then + thread="posix" + libpthread="-lpthread" + else + cc_check pthread.h "" "pthread_create(0,0,0,0);" && thread="posix" && libpthread="" + fi ;; esac fi -- 2.47.3