From 7b9b1fb94aa44784e33734bef68c76e6a43361ef Mon Sep 17 00:00:00 2001 From: David Hill Date: Sat, 29 Jun 2013 17:34:51 -0400 Subject: [PATCH] support Bitrig --- bootstrap.py | 6 +++--- configure.py | 4 ++-- platform_helper.py | 7 ++++++- src/subprocess-posix.cc | 6 +++--- src/subprocess_test.cc | 4 ++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/bootstrap.py b/bootstrap.py index 5682bf1..66ec85b 100755 --- a/bootstrap.py +++ b/bootstrap.py @@ -37,7 +37,7 @@ 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",) + help="ppoll() is used by default on Linux, OpenBSD and Bitrig, but older versions might need to use pselect instead",) (options, conf_args) = parser.parse_args() @@ -53,7 +53,7 @@ def run(*args, **kwargs): # g++ call as well as in the later configure.py. cflags = os.environ.get('CFLAGS', '').split() ldflags = os.environ.get('LDFLAGS', '').split() -if platform.is_freebsd() or platform.is_openbsd(): +if platform.is_freebsd() or platform.is_openbsd() or platform.is_bitrig(): cflags.append('-I/usr/local/include') ldflags.append('-L/usr/local/lib') @@ -109,7 +109,7 @@ 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: +if (platform.is_linux() or platform.is_openbsd() or platform.is_bitrig()) and not options.force_pselect: cflags.append('-DUSE_PPOLL') if options.force_pselect: conf_args.append("--force-pselect") diff --git a/configure.py b/configure.py index 22eb1e5..6b6b3d0 100755 --- a/configure.py +++ b/configure.py @@ -48,7 +48,7 @@ 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",) + help="ppoll() is used by default on Linux, OpenBSD and Bitrig, but older versions might need to use pselect instead",) (options, args) = parser.parse_args() if args: print('ERROR: extra unparsed command-line arguments:', args) @@ -165,7 +165,7 @@ 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: +if (platform.is_linux() or platform.is_openbsd() or platform.is_bitrig()) and not options.force_pselect: cflags.append('-DUSE_PPOLL') def shell_escape(str): diff --git a/platform_helper.py b/platform_helper.py index 5097f49..e040246 100644 --- a/platform_helper.py +++ b/platform_helper.py @@ -19,7 +19,7 @@ import sys def platforms(): return ['linux', 'darwin', 'freebsd', 'openbsd', 'solaris', 'sunos5', - 'mingw', 'msvc', 'gnukfreebsd8'] + 'mingw', 'msvc', 'gnukfreebsd8', 'bitrig'] class Platform( object ): def __init__( self, platform): @@ -41,6 +41,8 @@ class Platform( object ): self._platform = 'mingw' elif self._platform.startswith('win'): self._platform = 'msvc' + elif self._platform.startswith('bitrig'): + self._platform = 'bitrig' def platform(self): @@ -69,3 +71,6 @@ class Platform( object ): def is_sunos5(self): return self._platform == 'sunos5' + + def is_bitrig(self): + return self._platform == 'bitrig' diff --git a/src/subprocess-posix.cc b/src/subprocess-posix.cc index b396f84..ae010c9 100644 --- a/src/subprocess-posix.cc +++ b/src/subprocess-posix.cc @@ -41,7 +41,7 @@ bool Subprocess::Start(SubprocessSet* set, const string& command) { Fatal("pipe: %s", strerror(errno)); fd_ = output_pipe[0]; #if !defined(USE_PPOLL) - // On Linux and OpenBSD, we use ppoll in DoWork(); elsewhere we use pselect + // On Linux, OpenBSD and Bitrig, we use ppoll in DoWork(); elsewhere we use pselect // and so must avoid overly-large FDs. if (fd_ >= static_cast(FD_SETSIZE)) Fatal("pipe: %s", strerror(EMFILE)); @@ -224,7 +224,7 @@ bool SubprocessSet::DoWork() { return interrupted_; } -#else // linux || __OpenBSD__ +#else // linux || __OpenBSD__ || __Bitrig__ bool SubprocessSet::DoWork() { fd_set set; int nfds = 0; @@ -266,7 +266,7 @@ bool SubprocessSet::DoWork() { return interrupted_; } -#endif // linux || __OpenBSD__ +#endif // linux || __OpenBSD__ || __Bitrig__ Subprocess* SubprocessSet::NextFinished() { if (finished_.empty()) diff --git a/src/subprocess_test.cc b/src/subprocess_test.cc index afd9008..7e98cad 100644 --- a/src/subprocess_test.cc +++ b/src/subprocess_test.cc @@ -152,7 +152,7 @@ TEST_F(SubprocessTest, SetWithMulti) { // OS X's process limit is less than 1025 by default // (|sysctl kern.maxprocperuid| is 709 on 10.7 and 10.8 and less prior to that). -#if defined(linux) || defined(__OpenBSD__) +#if defined(linux) || defined(__OpenBSD__) || defined(__Bitrig__) TEST_F(SubprocessTest, SetWithLots) { // Arbitrary big number; needs to be over 1024 to confirm we're no longer // hostage to pselect. @@ -179,7 +179,7 @@ TEST_F(SubprocessTest, SetWithLots) { } ASSERT_EQ(kNumProcs, subprocs_.finished_.size()); } -#endif // linux || __OpenBSD__ +#endif // linux || __OpenBSD__ || __Bitrig__ // TODO: this test could work on Windows, just not sure how to simply // read stdin. -- 2.7.4