Commit 12a6f6fe authored by Oskar Skog's avatar Oskar Skog

Which sysctl on which BSD?

parent b7613220
#!/bin/sh
if [ $# -ne 4 ]; then
cat >&2 <<__EOF__
# ./mkenginecfg python_interpreter srcdir builddir hiscorefile
# This shell script is a wrapper around a Python script that will be spit
# out.
__EOF__
exit 1
echo "./mkenginecfg python_interpreter srcdir builddir hiscorefile" >&2
exit 1
fi
python=$1
......@@ -74,17 +69,17 @@ __EOF__
# succeed! (wc -l says there are zero processors.)
# BUG *1: sysctl(1) on OpenBSD does not fail, the first sysctl command
# must work.
# NOTICE v: Don't forget the semicolon!
# NOTICE v: Don't forget the semicolon!
_n0 () { nproc --all; } # Debian
_n1 () { lscpu && lscpu -p | grep -v '#' | wc -l; } # (Linux)/Debian
_n2 () { sysctl -n hw.ncpufound; } # OpenBSD, BUG *1
_n3 () { sysctl -n kern.smp.cpus; } # BSD (Should I use this?)
_n4 () { sysctl -n hw.logicalcpu; } # BSD
_n5 () { sysctl -n hw.ncpu; } # BSD (fallback)
_n2 () { sysctl -n hw.ncpufound; } # OpenBSD (BUG *1)
_n3 () { sysctl -n kern.smp.cpus; } # FreeBSD
_n4 () { sysctl -n hw.logicalcpu; } # Mac OS X
_n5 () { sysctl -n hw.ncpu; } # OpenBSD, NetBSD, DragonflyBSD, Mac OS X
_n6 () { psrinfo && psrinfo | wc -l; } # (OpenSolaris)/openidiana
n=0; last=6
while [ $n -le $last ]; do
ncpus=`_n$n` 2> /dev/null && break
ncpus=`_n$n` 2>/dev/null && break
n=$(($n + 1))
done
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment