mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 19:25:43 +00:00
b0a1468c01
This replaces some old Chromium code that tries to minimally disentangle an arbitrary file descriptor mapping with simpler algorithm, for several reasons: 1. Do something appropriate when a file descriptor is mapped to the same fd number in the child; currently they're ignored, which means they'll be closed if they were close-on-exec. This implementation duplicates the fd twice in that case, which seems to be uncommon in practice; this isn't maximally efficient but avoids special-case code. 2. Make this more generally applicable; the previous design is specialized for arbitrary code running between fork and exec, but we also want to use this on OS X with posix_spawn, which exposes a very limited set of operations. 3. Avoid the use of C++ standard library iterators in async signal safe code; the Chromium developers mention that this is a potential problem in some debugging implementations that take locks. 4. In general the algorithm is simpler and should be more "obviously correct"; more concretely, it should get complete coverage just by being run normally in a debug build. As a convenient side benefit, CloseSuperfluousFds now takes an arbitrary predicate for which fds to leave open, which means it can be used in other code that needs it without creating a fake fd mapping. MozReview-Commit-ID: EoiRttrbrKL --HG-- extra : rebase_source : 336e0ba9f56dc80f7347dc62617b4ad1efea7e7e
156 lines
4.6 KiB
Python
156 lines
4.6 KiB
Python
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
|
# vim: set filetype=python:
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
libevent_path_prefix = 'src/third_party'
|
|
include(libevent_path_prefix + '/libeventcommon.mozbuild')
|
|
|
|
UNIFIED_SOURCES += [
|
|
'src/base/at_exit.cc',
|
|
'src/base/command_line.cc',
|
|
'src/base/file_path.cc',
|
|
'src/base/file_util.cc',
|
|
'src/base/histogram.cc',
|
|
'src/base/logging.cc',
|
|
'src/base/message_loop.cc',
|
|
'src/base/message_pump_default.cc',
|
|
'src/base/pickle.cc',
|
|
'src/base/rand_util.cc',
|
|
'src/base/revocable_store.cc',
|
|
'src/base/string_piece.cc',
|
|
'src/base/string_util.cc',
|
|
'src/base/thread.cc',
|
|
'src/base/time.cc',
|
|
'src/base/timer.cc',
|
|
'src/chrome/common/child_process.cc',
|
|
'src/chrome/common/child_process_host.cc',
|
|
'src/chrome/common/child_thread.cc',
|
|
'src/chrome/common/chrome_switches.cc',
|
|
'src/chrome/common/ipc_channel.cc',
|
|
'src/chrome/common/ipc_message.cc',
|
|
]
|
|
|
|
if os_win:
|
|
SOURCES += [
|
|
'src/base/condition_variable_win.cc',
|
|
'src/base/file_util_win.cc',
|
|
'src/base/lock_impl_win.cc',
|
|
'src/base/message_pump_win.cc',
|
|
'src/base/object_watcher.cc',
|
|
'src/base/platform_thread_win.cc',
|
|
'src/base/process_util_win.cc',
|
|
'src/base/rand_util_win.cc',
|
|
'src/base/shared_memory_win.cc',
|
|
'src/base/sys_string_conversions_win.cc',
|
|
'src/base/thread_local_win.cc',
|
|
'src/base/time_win.cc',
|
|
'src/base/waitable_event_win.cc',
|
|
'src/base/win_util.cc',
|
|
'src/chrome/common/ipc_channel_win.cc',
|
|
'src/chrome/common/process_watcher_win.cc',
|
|
]
|
|
|
|
elif not CONFIG['MOZ_SYSTEM_LIBEVENT']:
|
|
DIRS += ['src/third_party']
|
|
|
|
if os_posix:
|
|
UNIFIED_SOURCES += [
|
|
'src/base/condition_variable_posix.cc',
|
|
'src/base/file_util_posix.cc',
|
|
'src/base/lock_impl_posix.cc',
|
|
'src/base/message_pump_libevent.cc',
|
|
'src/base/platform_thread_posix.cc',
|
|
'src/base/process_util_posix.cc',
|
|
'src/base/rand_util_posix.cc',
|
|
'src/base/shared_memory_posix.cc',
|
|
'src/base/string16.cc',
|
|
'src/base/thread_local_posix.cc',
|
|
'src/base/waitable_event_posix.cc',
|
|
'src/chrome/common/file_descriptor_set_posix.cc',
|
|
'src/chrome/common/ipc_channel_posix.cc',
|
|
'src/chrome/common/process_watcher_posix_sigchld.cc',
|
|
]
|
|
|
|
if os_macosx:
|
|
UNIFIED_SOURCES += [
|
|
'src/base/chrome_application_mac.mm',
|
|
'src/base/file_util_mac.mm',
|
|
'src/base/mac_util.mm',
|
|
'src/base/message_pump_mac.mm',
|
|
'src/base/process_util_mac.mm',
|
|
'src/base/scoped_nsautorelease_pool.mm',
|
|
'src/base/sys_string_conversions_mac.mm',
|
|
'src/base/time_mac.cc',
|
|
'src/chrome/common/mach_ipc_mac.mm',
|
|
'src/chrome/common/mach_message_source_mac.cc',
|
|
]
|
|
SOURCES += [
|
|
# This file cannot be built in unified mode because of the redefinition
|
|
# of NoOp.
|
|
'src/base/platform_thread_mac.mm',
|
|
]
|
|
|
|
if os_bsd:
|
|
SOURCES += [
|
|
'src/base/atomicops_internals_x86_gcc.cc',
|
|
'src/base/time_posix.cc',
|
|
]
|
|
if CONFIG['OS_ARCH'] == 'GNU_kFreeBSD':
|
|
SOURCES += [
|
|
'src/base/process_util_linux.cc'
|
|
]
|
|
else:
|
|
SOURCES += [
|
|
'src/base/process_util_bsd.cc'
|
|
]
|
|
|
|
if os_linux:
|
|
SOURCES += [
|
|
'src/base/atomicops_internals_x86_gcc.cc',
|
|
'src/base/process_util_linux.cc',
|
|
'src/base/time_posix.cc',
|
|
]
|
|
if CONFIG['OS_TARGET'] == 'Android':
|
|
UNIFIED_SOURCES += [
|
|
'src/base/message_pump_android.cc',
|
|
]
|
|
DEFINES['ANDROID'] = True
|
|
DEFINES['_POSIX_MONOTONIC_CLOCK'] = 0
|
|
|
|
if os_bsd or os_linux:
|
|
if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
|
|
SOURCES += [
|
|
'src/base/message_pump_glib.cc',
|
|
]
|
|
|
|
if os_solaris:
|
|
SOURCES += [
|
|
'src/base/atomicops_internals_x86_gcc.cc',
|
|
'src/base/process_util_linux.cc',
|
|
'src/base/time_posix.cc',
|
|
]
|
|
|
|
ost = CONFIG['OS_TEST']
|
|
if '86' not in ost and 'arm' not in ost and 'aarch64' != ost and 'mips' not in ost and 'powerpc' not in ost:
|
|
SOURCES += [
|
|
'src/base/atomicops_internals_mutex.cc',
|
|
]
|
|
|
|
CXXFLAGS += CONFIG['TK_CFLAGS']
|
|
|
|
include('/ipc/chromium/chromium-config.mozbuild')
|
|
|
|
FINAL_LIBRARY = 'xul'
|
|
|
|
DIRS += [
|
|
'atomics',
|
|
]
|
|
|
|
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
|
|
CXXFLAGS += ['-Wno-error=shadow']
|
|
|
|
# Add libFuzzer configuration directives
|
|
include('/tools/fuzzing/libfuzzer-config.mozbuild')
|