]> git.sesse.net Git - x264/commitdiff
Fix build with Android NDK
authorYu Xiaolei <dreifachstein@gmail.com>
Sun, 23 Feb 2014 12:12:51 +0000 (04:12 -0800)
committerFiona Glaser <fiona@x264.com>
Mon, 24 Feb 2014 03:14:00 +0000 (19:14 -0800)
Android NDK does not expose sched_getaffinity.

common/cpu.c
configure

index 3f6076658e1f8c39b81448b7bac80a7ba2ab9908..39d114cc01d9d5dac7ac512f4ff46b6097a55f67 100644 (file)
@@ -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;
index 0177cfceffe7df7c18e9e2962d64fcd3b5010e7f..49a3d8ff1bbcf0ff5128d0c1dbe97b5f183b7a92 100755 (executable)
--- 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