[fuchsia] Migrate off zx_clock_get.

zx_clock_get is a deprecated syscall that we're in the process of
removing. This CL replaces one usage with the modern equivalent.

Ref https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0008_remove_zx_clock_get_and_adjust

Bug: fuchsia:61736
Change-Id: Ia595409e30b6d96139da50b83ba25f0f06b601c3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2521438
Commit-Queue: Jody Sankey <jsankey@google.com>
Reviewed-by: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71020}
This commit is contained in:
Jody Sankey 2020-11-06 12:10:29 -08:00 committed by Commit Bot
parent 1b690be2df
commit fd5892ad2c

View File

@ -4,6 +4,7 @@
#include <zircon/process.h>
#include <zircon/syscalls.h>
#include <zircon/threads.h>
#include "src/base/macros.h"
#include "src/base/platform/platform-posix-time.h"
@ -151,17 +152,18 @@ void OS::SignalCodeMovingGC() {
int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) {
const auto kNanosPerMicrosecond = 1000ULL;
const auto kMicrosPerSecond = 1000000ULL;
zx_time_t nanos_since_thread_started;
zx_status_t status =
zx_clock_get(ZX_CLOCK_THREAD, &nanos_since_thread_started);
zx_info_thread_stats_t info = {};
zx_status_t status = zx_object_get_info(thrd_get_zx_handle(thrd_current()),
ZX_INFO_THREAD_STATS, &info,
sizeof(info), nullptr, nullptr);
if (status != ZX_OK) {
return -1;
}
// First convert to microseconds, rounding up.
const uint64_t micros_since_thread_started =
(nanos_since_thread_started + kNanosPerMicrosecond - 1ULL) /
kNanosPerMicrosecond;
(info.total_runtime + kNanosPerMicrosecond - 1ULL) / kNanosPerMicrosecond;
*secs = static_cast<uint32_t>(micros_since_thread_started / kMicrosPerSecond);
*usecs =