[vlc-commits] Simplify and improve the detection of the number of CPU cores.

Konstantin Pavlov git at videolan.org
Thu Dec 7 23:25:55 CET 2017


vlc/vlc-3.0 | branch: master | Konstantin Pavlov <thresh at videolan.org> | Thu Dec  7 15:30:13 2017 +0300| [5458ff10a1520450d39e5a7687aa6e6358260066] | committer: Jean-Baptiste Kempf

Simplify and improve the detection of the number of CPU cores.

(cherry picked from commit e3dc51fba81c1c34e6eaf4293335135060eccb21)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=5458ff10a1520450d39e5a7687aa6e6358260066
---

 extras/package/macosx/build.sh |  2 +-
 extras/package/win32/build.sh  |  2 +-
 extras/tools/bootstrap         | 11 +++++++----
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/extras/package/macosx/build.sh b/extras/package/macosx/build.sh
index b7e09a4c86..23aa480f7b 100755
--- a/extras/package/macosx/build.sh
+++ b/extras/package/macosx/build.sh
@@ -16,7 +16,7 @@ OSX_KERNELVERSION=`uname -r | cut -d. -f1`
 SDKROOT=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
 VLCBUILDDIR=""
 
-CORE_COUNT=`sysctl -n machdep.cpu.core_count`
+CORE_COUNT=`getconf NPROCESSORS_ONLN 2>&1`
 let JOBS=$CORE_COUNT+1
 
 usage()
diff --git a/extras/package/win32/build.sh b/extras/package/win32/build.sh
index 3c76c19b5a..2d943220bd 100755
--- a/extras/package/win32/build.sh
+++ b/extras/package/win32/build.sh
@@ -78,7 +78,7 @@ esac
 
 #####
 
-JOBS=`nproc --all`
+JOBS=`getconf _NPROCESSORS_ONLN 2>&1`
 TRIPLET=$ARCH-w64-mingw32
 
 info "Building extra tools"
diff --git a/extras/tools/bootstrap b/extras/tools/bootstrap
index 2dcdd2fc53..93205dea99 100755
--- a/extras/tools/bootstrap
+++ b/extras/tools/bootstrap
@@ -91,13 +91,16 @@ check flex
 CPUS=
 case `uname` in
     Linux|MINGW32*|MINGW64*)
-        CPUS=`grep -c ^processor /proc/cpuinfo`
+        CPUS=`getconf _NPROCESSORS_ONLN 2>&1`
      ;;
-    Darwin)
-        CPUS=`sysctl hw.ncpu|cut -d" " -f2`
+    Darwin|FreeBSD|NetBSD)
+        CPUS=`getconf NPROCESSORS_ONLN 2>&1`
+    ;;
+    OpenBSD)
+        CPUS=`sysctl -n hw.ncpu 2>&1`
     ;;
     SunOS)
-        CPUS=`/usr/bin/kstat -p :::state | grep 'on-line$' | wc -l | sed 's/ //g'`
+        CPUS=`psrinfo | wc -l 2>&1`
     ;;
     *)
         CPUS=1  # default



More information about the vlc-commits mailing list