_SC_NPROCESSORS_ONLN -> std:🧵:hardware_concurrency()

This commit is contained in:
Eelco Dolstra 2017-02-27 16:01:54 +01:00
parent 4f3fb34844
commit 3fab1f04a7
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -2,9 +2,9 @@
#include "util.hh" #include "util.hh"
#include "archive.hh" #include "archive.hh"
#include <map>
#include <algorithm> #include <algorithm>
#include <unistd.h> #include <map>
#include <thread>
namespace nix { namespace nix {
@ -42,11 +42,7 @@ Settings::Settings()
keepGoing = false; keepGoing = false;
tryFallback = false; tryFallback = false;
maxBuildJobs = 1; maxBuildJobs = 1;
buildCores = 1; buildCores = std::max(1U, std::thread::hardware_concurrency());
#ifdef _SC_NPROCESSORS_ONLN
long res = sysconf(_SC_NPROCESSORS_ONLN);
if (res > 0) buildCores = res;
#endif
readOnlyMode = false; readOnlyMode = false;
thisSystem = SYSTEM; thisSystem = SYSTEM;
maxSilentTime = 0; maxSilentTime = 0;