[fuchsia] Migrate off zx_clock_get.
zx_clock_get is a deprecated syscall that we're in the process of removing.
This CL replaces the only remaining usage with the modern equivalent.
Ref:
https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0008_remove_zx_clock_get_and_adjust
TEST=existing tests on vm-fuchsia-release-x64-try
Bug: fuchsia:60521
Change-Id: Ic48563a09d7585af52027470f8202605da4ba70e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175324
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
diff --git a/runtime/vm/os_fuchsia.cc b/runtime/vm/os_fuchsia.cc
index 0a9ffa1..e79827b 100644
--- a/runtime/vm/os_fuchsia.cc
+++ b/runtime/vm/os_fuchsia.cc
@@ -23,6 +23,7 @@
#include <zircon/syscalls.h>
#include <zircon/syscalls/object.h>
#include <zircon/time.h>
+#include <zircon/threads.h>
#include <zircon/types.h>
#include "platform/assert.h"
@@ -216,9 +217,11 @@
}
int64_t OS::GetCurrentThreadCPUMicros() {
- zx_time_t now = 0;
- zx_clock_get(ZX_CLOCK_THREAD, &now);
- return now / kNanosecondsPerMicrosecond;
+ 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);
+ return status == ZX_OK ? info.total_runtime / kNanosecondsPerMicrosecond : 0;
}
// On Fuchsia, thread timestamp values are not used in the tracing/timeline