Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions os-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,13 @@ since it has not been updated to support POSIX.1-2008:
#endif
}
}

long
osnproc(void)
{
#ifdef _SC_NPROCESSORS_ONLN
return sysconf(_SC_NPROCESSORS_ONLN);
#else
return 1;
#endif
}
2 changes: 2 additions & 0 deletions os.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ void oschdir(const char *);
int osmkdirs(struct string *, _Bool);
/* queries the mtime of a file in nanoseconds since the UNIX epoch */
int64_t osmtime(const char *);
/* queries the number of online processors */
long osnproc(void);
6 changes: 1 addition & 5 deletions samu.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ main(int argc, char *argv[])
} ARGEND
argdone:
if (!buildopts.maxjobs) {
#ifdef _SC_NPROCESSORS_ONLN
long nproc = sysconf(_SC_NPROCESSORS_ONLN);
long nproc = osnproc();
switch (nproc) {
case -1: case 0: case 1:
buildopts.maxjobs = 2;
Expand All @@ -213,9 +212,6 @@ main(int argc, char *argv[])
buildopts.maxjobs = nproc + 2;
break;
}
#else
buildopts.maxjobs = 2;
#endif
}

buildopts.statusfmt = getenv("NINJA_STATUS");
Expand Down