[x264-devel] [PATCH] Fix build with Android NDK

Yu Xiaolei dreifachstein at gmail.com
Mon Feb 17 11:04:58 CET 2014


---
 common/cpu.c | 5 +++++
 configure    | 7 ++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/common/cpu.c b/common/cpu.c
index f2c7212..f1ae266 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 0177cfc..8f995af 100755
--- a/configure
+++ b/configure
@@ -809,7 +809,12 @@ if [ "$thread" = "auto" ]; then
             cc_check pthread.h -lc && thread="posix" && libpthread="-lc"
             ;;
         *)
-            cc_check pthread.h -lpthread && thread="posix" &&
libpthread="-lpthread"
+            if cc_check pthread.h -lpthread ; then
+               thread="posix"
+               libpthread="-lpthread"
+            else
+                cc_check pthread.h && thread="posix" && libpthread=""
+            fi
             ;;
     esac
 fi
-- 
1.9.0.rc3


More information about the x264-devel mailing list