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/954420
Reviewed-by: Daniel Cheng <[email protected]>
Commit-Queue: Wez <[email protected]>
Cr-Commit-Position: refs/heads/master@{#542034}
diff --git a/base/logging.cc b/base/logging.cc
index 7db189f..20550a7b 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -101,6 +101,11 @@
#include <android/log.h>
#endif
+#if defined(OS_FUCHSIA)
+#include <zircon/process.h>
+#include <zircon/syscalls.h>
+#endif
+
namespace logging {
namespace {
@@ -161,6 +166,11 @@
int32_t CurrentProcessId() {
#if defined(OS_WIN)
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)
return getpid();
#endif
@@ -171,6 +181,9 @@
return GetTickCount();
#elif defined(OS_MACOSX)
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)
// NaCl sadly does not have _POSIX_TIMERS enabled in sys/features.h
// So we have to use clock() for now.