Commit b050130d authored by Wez's avatar Wez Committed by Commit Bot

Fix base::LogMessage to report the process Id under Fuchsia.

Previously LogMessage would use the POSIX getpid() API, which is not
a real implementation under Fuchsia.

Bug: 706592
Change-Id: I9d2b2f06efcecfea9457f7d96295457de2ef888d
Reviewed-on: https://chromium-review.googlesource.com/954420Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542034}
parent fbdbb6d5
...@@ -101,6 +101,11 @@ typedef pthread_mutex_t* MutexHandle; ...@@ -101,6 +101,11 @@ typedef pthread_mutex_t* MutexHandle;
#include <android/log.h> #include <android/log.h>
#endif #endif
#if defined(OS_FUCHSIA)
#include <zircon/process.h>
#include <zircon/syscalls.h>
#endif
namespace logging { namespace logging {
namespace { namespace {
...@@ -161,6 +166,11 @@ LogMessageHandlerFunction log_message_handler = nullptr; ...@@ -161,6 +166,11 @@ LogMessageHandlerFunction log_message_handler = nullptr;
int32_t CurrentProcessId() { int32_t CurrentProcessId() {
#if defined(OS_WIN) #if defined(OS_WIN)
return GetCurrentProcessId(); return GetCurrentProcessId();
#elif defined(OS_FUCHSIA)
zx_info_handle_basic_t basic = {};
zx_object_get_info(zx_process_self(), ZX_INFO_HANDLE_BASIC, &basic,
sizeof(basic), nullptr, nullptr);
return basic.koid;
#elif defined(OS_POSIX) #elif defined(OS_POSIX)
return getpid(); return getpid();
#endif #endif
...@@ -171,6 +181,9 @@ uint64_t TickCount() { ...@@ -171,6 +181,9 @@ uint64_t TickCount() {
return GetTickCount(); return GetTickCount();
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
return mach_absolute_time(); return mach_absolute_time();
#elif defined(OS_FUCHSIA)
return zx_clock_get(ZX_CLOCK_MONOTONIC) /
static_cast<zx_time_t>(base::Time::kNanosecondsPerMicrosecond);
#elif defined(OS_NACL) #elif defined(OS_NACL)
// NaCl sadly does not have _POSIX_TIMERS enabled in sys/features.h // NaCl sadly does not have _POSIX_TIMERS enabled in sys/features.h
// So we have to use clock() for now. // So we have to use clock() for now.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment