diff options
author | michaelbai@google.com <michaelbai@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-29 20:53:22 +0000 |
---|---|---|
committer | michaelbai@google.com <michaelbai@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-29 20:53:22 +0000 |
commit | 1e932118a2ad13c144f958e46899b535c7bc0bdd (patch) | |
tree | 447007c281c03aeafb4505ff49f453c0d2c6f612 /base | |
parent | 56af67211dafd93bc12756655e20b66b527da7e1 (diff) | |
download | chromium_src-1e932118a2ad13c144f958e46899b535c7bc0bdd.zip chromium_src-1e932118a2ad13c144f958e46899b535c7bc0bdd.tar.gz chromium_src-1e932118a2ad13c144f958e46899b535c7bc0bdd.tar.bz2 |
Upstream process and thread related code.
BUG=
TEST=
Review URL: http://codereview.chromium.org/7247015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91009 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/process_util_linux.cc | 8 | ||||
-rw-r--r-- | base/process_util_posix.cc | 11 | ||||
-rw-r--r-- | base/third_party/nspr/prcpucfg.h | 2 | ||||
-rw-r--r-- | base/time_posix.cc | 2 |
4 files changed, 19 insertions, 4 deletions
diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc index f80cfc0..aabd201 100644 --- a/base/process_util_linux.cc +++ b/base/process_util_linux.cc @@ -611,7 +611,8 @@ void OnNoMemory() { } // namespace extern "C" { -#if !defined(USE_TCMALLOC) && !defined(ADDRESS_SANITIZER) +#if !defined(USE_TCMALLOC) && !defined(ADDRESS_SANITIZER) && \ + !defined(OS_ANDROID) extern "C" { void* __libc_malloc(size_t size); @@ -694,10 +695,15 @@ int posix_memalign(void** ptr, size_t alignment, size_t size) { } // extern C void EnableTerminationOnOutOfMemory() { +#if defined(OS_ANDROID) + // Android doesn't support setting a new handler. + DLOG(WARNING) << "Not feasible."; +#else // Set the new-out of memory handler. std::set_new_handler(&OnNoMemory); // If we're using glibc's allocator, the above functions will override // malloc and friends and make them die on out of memory. +#endif } bool AdjustOOMScore(ProcessId process, int score) { diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index a2398ed..023f1e8 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -106,6 +106,8 @@ int WaitpidWithTimeout(ProcessHandle handle, int64 wait_milliseconds, return status; } +// Android has built-in crash handling. +#if !defined(OS_ANDROID) void StackDumpSignalHandler(int signal, siginfo_t* info, ucontext_t* context) { if (debug::BeingDebugged()) debug::BreakDebugger(); @@ -157,6 +159,7 @@ void StackDumpSignalHandler(int signal, siginfo_t* info, ucontext_t* context) { #endif // defined(OS_MACOSX) _exit(1); } +#endif // !defined(OS_ANDROID) void ResetChildSignalHandlersToDefaults() { // The previous signal handlers are likely to be meaningless in the child's @@ -303,6 +306,9 @@ typedef scoped_ptr_malloc<DIR, ScopedDIRClose> ScopedDIR; #elif defined(OS_OPENBSD) static const rlim_t kSystemDefaultMaxFds = 256; static const char kFDDir[] = "/dev/fd"; +#elif defined(OS_ANDROID) + static const rlim_t kSystemDefaultMaxFds = 1024; + static const char kFDDir[] = "/proc/self/fd"; #endif void CloseSuperfluousFds(const base::InjectiveMultimap& saved_mapping) { @@ -660,6 +666,8 @@ bool EnableInProcessStackDumping() { sigemptyset(&action.sa_mask); bool success = (sigaction(SIGPIPE, &action, NULL) == 0); + // Android has built-in crash handling, so no need to hook the signals. +#if !defined(OS_ANDROID) sig_t handler = reinterpret_cast<sig_t>(&StackDumpSignalHandler); success &= (signal(SIGILL, handler) != SIG_ERR); success &= (signal(SIGABRT, handler) != SIG_ERR); @@ -667,6 +675,7 @@ bool EnableInProcessStackDumping() { success &= (signal(SIGBUS, handler) != SIG_ERR); success &= (signal(SIGSEGV, handler) != SIG_ERR); success &= (signal(SIGSYS, handler) != SIG_ERR); +#endif return success; } @@ -994,7 +1003,7 @@ bool WaitForProcessesToExit(const FilePath::StringType& executable_name, break; } base::PlatformThread::Sleep(100); - } while ((base::Time::Now() - end_time) > base::TimeDelta()); + } while ((end_time - base::Time::Now()) > base::TimeDelta()); return result; } diff --git a/base/third_party/nspr/prcpucfg.h b/base/third_party/nspr/prcpucfg.h index c376524..d6ebb47 100644 --- a/base/third_party/nspr/prcpucfg.h +++ b/base/third_party/nspr/prcpucfg.h @@ -36,7 +36,7 @@ #include "base/third_party/nspr/prcpucfg_mac.h" #elif defined(__native_client__) #include "base/third_party/nspr/prcpucfg_nacl.h" -#elif defined(__linux__) +#elif defined(__linux__) || defined(ANDROID) #include "base/third_party/nspr/prcpucfg_linux.h" #elif defined(__FreeBSD__) #include "base/third_party/nspr/prcpucfg_freebsd.h" diff --git a/base/time_posix.cc b/base/time_posix.cc index a2ea5ae..f83a9656 100644 --- a/base/time_posix.cc +++ b/base/time_posix.cc @@ -163,7 +163,7 @@ Time Time::FromExploded(bool is_local, const Exploded& exploded) { // FreeBSD 6 has CLOCK_MONOLITHIC but defines _POSIX_MONOTONIC_CLOCK to -1. #if (defined(OS_POSIX) && \ defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0) || \ - defined(OS_FREEBSD) || defined(OS_OPENBSD) + defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_ANDROID) // static TimeTicks TimeTicks::Now() { |