diff options
author | Evan Martin <martine@danga.com> | 2013-05-23 21:10:47 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2013-05-23 21:10:47 (GMT) |
commit | 8fc51490fbb7b3dabed45f4ca5d791bd3dd00b5b (patch) | |
tree | 55bff08c0dbf9df23d0c6242f3bccde10788691c | |
parent | e659bbf4873d0af74de0f7a0245b2305357974e3 (diff) | |
parent | 4db8e5ddf0c941616842d2a6e947477145f84783 (diff) | |
download | Ninja-8fc51490fbb7b3dabed45f4ca5d791bd3dd00b5b.zip Ninja-8fc51490fbb7b3dabed45f4ca5d791bd3dd00b5b.tar.gz Ninja-8fc51490fbb7b3dabed45f4ca5d791bd3dd00b5b.tar.bz2 |
Merge pull request #583 from tru/add_force_pselect
Added bootstrap/configure option to force pselect
-rwxr-xr-x | bootstrap.py | 6 | ||||
-rwxr-xr-x | configure.py | 5 | ||||
-rw-r--r-- | src/subprocess-posix.cc | 6 |
3 files changed, 14 insertions, 3 deletions
diff --git a/bootstrap.py b/bootstrap.py index cff10ba..5682bf1 100755 --- a/bootstrap.py +++ b/bootstrap.py @@ -36,6 +36,8 @@ parser.add_option('--x64', action='store_true', parser.add_option('--platform', help='target platform (' + '/'.join(platform_helper.platforms()) + ')', choices=platform_helper.platforms()) +parser.add_option('--force-pselect', action='store_true', + help="ppoll() is used by default on Linux and OpenBSD, but older versions might need to use pselect instead",) (options, conf_args) = parser.parse_args() @@ -107,6 +109,10 @@ else: cflags.append('-D_WIN32_WINNT=0x0501') if options.x64: cflags.append('-m64') +if (platform.is_linux() or platform.is_openbsd()) and not options.force_pselect: + cflags.append('-DUSE_PPOLL') +if options.force_pselect: + conf_args.append("--force-pselect") args.extend(cflags) args.extend(ldflags) binary = 'ninja.bootstrap' diff --git a/configure.py b/configure.py index 7c90e66..22eb1e5 100755 --- a/configure.py +++ b/configure.py @@ -47,6 +47,8 @@ parser.add_option('--with-gtest', metavar='PATH', parser.add_option('--with-python', metavar='EXE', help='use EXE as the Python interpreter', default=os.path.basename(sys.executable)) +parser.add_option('--force-pselect', action='store_true', + help="ppoll() is used by default on Linux and OpenBSD, but older versions might need to use pselect instead",) (options, args) = parser.parse_args() if args: print('ERROR: extra unparsed command-line arguments:', args) @@ -163,6 +165,9 @@ else: cflags.append('-fno-omit-frame-pointer') libs.extend(['-Wl,--no-as-needed', '-lprofiler']) +if (platform.is_linux() or platform.is_openbsd()) and not options.force_pselect: + cflags.append('-DUSE_PPOLL') + def shell_escape(str): """Escape str such that it's interpreted as a single argument by the shell.""" diff --git a/src/subprocess-posix.cc b/src/subprocess-posix.cc index 339edfe..b396f84 100644 --- a/src/subprocess-posix.cc +++ b/src/subprocess-posix.cc @@ -40,12 +40,12 @@ bool Subprocess::Start(SubprocessSet* set, const string& command) { if (pipe(output_pipe) < 0) Fatal("pipe: %s", strerror(errno)); fd_ = output_pipe[0]; -#if !defined(linux) && !defined(__OpenBSD__) +#if !defined(USE_PPOLL) // On Linux and OpenBSD, we use ppoll in DoWork(); elsewhere we use pselect // and so must avoid overly-large FDs. if (fd_ >= static_cast<int>(FD_SETSIZE)) Fatal("pipe: %s", strerror(EMFILE)); -#endif // !linux && !__OpenBSD__ +#endif // !USE_PPOLL SetCloseOnExec(fd_); pid_ = fork(); @@ -178,7 +178,7 @@ Subprocess *SubprocessSet::Add(const string& command) { return subprocess; } -#if defined(linux) || defined(__OpenBSD__) +#ifdef USE_PPOLL bool SubprocessSet::DoWork() { vector<pollfd> fds; nfds_t nfds = 0; |