mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[fuchsia] Migrate to zx_clock_get_new
Change-Id: Ibf9210e3965e77ff56d244cfd67dbccfb1eef3f0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102104 Auto-Submit: Adam Barth <abarth@google.com> Reviewed-by: Zach Anderson <zra@google.com> Commit-Queue: Zach Anderson <zra@google.com>
This commit is contained in:
parent
36d8e3a9ba
commit
8a3a9dc588
|
@ -77,7 +77,7 @@ int64_t TimerUtils::GetCurrentMonotonicMillis() {
|
|||
}
|
||||
|
||||
int64_t TimerUtils::GetCurrentMonotonicMicros() {
|
||||
int64_t ticks = zx_clock_get(ZX_CLOCK_MONOTONIC);
|
||||
zx_time_t ticks = zx_clock_get_monotonic();
|
||||
return ticks / kNanosecondsPerMicrosecond;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,8 +89,10 @@ int OS::GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch) {
|
|||
|
||||
int OS::GetLocalTimeZoneAdjustmentInSeconds() {
|
||||
int32_t local_offset, dst_offset;
|
||||
zx_time_t now = 0;
|
||||
zx_clock_get_new(ZX_CLOCK_UTC, &now);
|
||||
zx_status_t status = GetLocalAndDstOffsetInSeconds(
|
||||
zx_clock_get(ZX_CLOCK_UTC) / ZX_SEC(1), &local_offset, &dst_offset);
|
||||
now / ZX_SEC(1), &local_offset, &dst_offset);
|
||||
return status == ZX_OK ? local_offset : 0;
|
||||
}
|
||||
|
||||
|
@ -99,11 +101,13 @@ int64_t OS::GetCurrentTimeMillis() {
|
|||
}
|
||||
|
||||
int64_t OS::GetCurrentTimeMicros() {
|
||||
return zx_clock_get(ZX_CLOCK_UTC) / kNanosecondsPerMicrosecond;
|
||||
zx_time_t now = 0;
|
||||
zx_clock_get_new(ZX_CLOCK_UTC, &now);
|
||||
return now / kNanosecondsPerMicrosecond;
|
||||
}
|
||||
|
||||
int64_t OS::GetCurrentMonotonicTicks() {
|
||||
return zx_clock_get(ZX_CLOCK_MONOTONIC);
|
||||
return zx_clock_get_monotonic();
|
||||
}
|
||||
|
||||
int64_t OS::GetCurrentMonotonicFrequency() {
|
||||
|
@ -117,7 +121,9 @@ int64_t OS::GetCurrentMonotonicMicros() {
|
|||
}
|
||||
|
||||
int64_t OS::GetCurrentThreadCPUMicros() {
|
||||
return zx_clock_get(ZX_CLOCK_THREAD) / kNanosecondsPerMicrosecond;
|
||||
zx_time_t now = 0;
|
||||
zx_clock_get_new(ZX_CLOCK_THREAD, &now);
|
||||
return now / kNanosecondsPerMicrosecond;
|
||||
}
|
||||
|
||||
// TODO(5411554): May need to hoist these architecture dependent code
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace dart {
|
|||
|
||||
static void ComputeTimeSpecMicros(struct timespec* ts, int64_t micros) {
|
||||
// time in nanoseconds.
|
||||
zx_time_t now = zx_clock_get(ZX_CLOCK_MONOTONIC);
|
||||
zx_time_t now = zx_clock_get_monotonic();
|
||||
zx_time_t target = now + (micros * kNanosecondsPerMicrosecond);
|
||||
int64_t secs = target / kNanosecondsPerSecond;
|
||||
int64_t nanos = target - (secs * kNanosecondsPerSecond);
|
||||
|
|
Loading…
Reference in a new issue