Commit fd5892ad authored by Jody Sankey's avatar Jody Sankey Committed by Commit Bot

[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: 's avatarWez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71020}
parent 1b690be2
......@@ -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 =
......
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