Skip to content

Commit

Permalink
support Bitrig
Browse files Browse the repository at this point in the history
  • Loading branch information
dajohi committed Jun 29, 2013
1 parent c8ac05c commit 7b9b1fb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
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()


Expand All @@ -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')

Expand Down Expand Up @@ -109,7 +109,7 @@ def run(*args, **kwargs):
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")
Expand Down
4 changes: 2 additions & 2 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
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)
Expand Down Expand Up @@ -165,7 +165,7 @@ def binary(name):
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):
Expand Down
7 changes: 6 additions & 1 deletion platform_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

def platforms():
return ['linux', 'darwin', 'freebsd', 'openbsd', 'solaris', 'sunos5',
'mingw', 'msvc', 'gnukfreebsd8']
'mingw', 'msvc', 'gnukfreebsd8', 'bitrig']

class Platform( object ):
def __init__( self, platform):
Expand All @@ -41,6 +41,8 @@ def __init__( self, platform):
self._platform = 'mingw'
elif self._platform.startswith('win'):
self._platform = 'msvc'
elif self._platform.startswith('bitrig'):
self._platform = 'bitrig'


def platform(self):
Expand Down Expand Up @@ -69,3 +71,6 @@ def is_openbsd(self):

def is_sunos5(self):
return self._platform == 'sunos5'

def is_bitrig(self):
return self._platform == 'bitrig'
6 changes: 3 additions & 3 deletions src/subprocess-posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(FD_SETSIZE))
Fatal("pipe: %s", strerror(EMFILE));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -266,7 +266,7 @@ bool SubprocessSet::DoWork() {

return interrupted_;
}
#endif // linux || __OpenBSD__
#endif // linux || __OpenBSD__ || __Bitrig__

Subprocess* SubprocessSet::NextFinished() {
if (finished_.empty())
Expand Down
4 changes: 2 additions & 2 deletions src/subprocess_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 7b9b1fb

Please sign in to comment.