[vlc-devel] [PATCH 3/3] Simplify and improve the detection of the number of CPU cores.
Konstantin Pavlov
thresh at videolan.org
Thu Dec 7 14:49:59 CET 2017
---
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 79c087b965..65c3fba54f 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
--
2.11.0 (Apple Git-81)
More information about the vlc-devel
mailing list