]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
Do not use nproc to determine the number of processors
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 15 Dec 2014 15:24:48 +0000 (16:24 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 15 Dec 2014 15:24:48 +0000 (16:24 +0100)
On some systems (e.g. with busybox) nproc is not available. Instead use
sysconf(). The only problem is that the _SC_NPROCESSORS_CONF constant is
not defined in the Perl POSIX module. We define it here only for Linux.

novaboot

index dadcd40d3f42b7602b876e896e6860d2b06ab96d..c76eaa5111d72ed55a85b211bc143f4b0ae2c4d7 100755 (executable)
--- a/novaboot
+++ b/novaboot
@@ -27,7 +27,7 @@ use Time::HiRes("usleep");
 use Socket;
 use FileHandle;
 use IPC::Open2;
-use POSIX qw(:errno_h);
+use POSIX qw(:errno_h sysconf);
 use Cwd qw(getcwd abs_path);
 use Expect;
 
@@ -53,9 +53,15 @@ $CFG::default_target = '';
     "ryuglab" => '--target ryu --server=pc-sojkam.felk.cvut.cz:/srv/tftp --remote-cmd="ssh -tt pc-sojkam.felk.cvut.cz \"sterm -d -s 115200 /dev/ttyUSB0\""',
     "ryulocal" => '--target ryu --dhcp-tftp --serial --reset-cmd="if which dtrrts; then dtrrts $NB_SERIAL 0 1; sleep 0.1; dtrrts $NB_SERIAL 1 1; fi"',
     );
-chomp(my $nproc = `nproc`);
-$CFG::scons = "scons -j$nproc";
-$CFG::make = "make -j$nproc";
+
+{
+    my %const;
+    $const{linux}->{_SC_NPROCESSORS_CONF} = 83;
+    my $nproc = sysconf($const{$^O}->{_SC_NPROCESSORS_CONF});
+
+    $CFG::scons = "scons -j$nproc";
+    $CFG::make = "make -j$nproc";
+}
 
 my $builddir;