Commit 323cab15 authored by Adam Lesinski's avatar Adam Lesinski Committed by Commit Bot

[base][fuchsia][time] Use C11 timespec for UTC time

UTC time is being removed from the zircon kernel in favor of
user-space clocks, passed to a process through proc_args.

The Fuchsia libc implementation of timespec_get knows where to find
the process-wide clock handle. This implementation is more portable.

Bug: 1119976
Change-Id: Ia5528f51551fedb80059e0bf3960de27512cecf3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368013Reviewed-by: default avatarWez <wez@chromium.org>
Commit-Queue: Adam Lesinski <adamlesinski@google.com>
Auto-Submit: Adam Lesinski <adamlesinski@google.com>
Cr-Commit-Position: refs/heads/master@{#801507}
parent 5d0f3cc7
...@@ -15,11 +15,10 @@ namespace base { ...@@ -15,11 +15,10 @@ namespace base {
namespace subtle { namespace subtle {
Time TimeNowIgnoringOverride() { Time TimeNowIgnoringOverride() {
zx_time_t nanos_since_unix_epoch; timespec ts;
zx_status_t status = zx_clock_get(ZX_CLOCK_UTC, &nanos_since_unix_epoch); int status = timespec_get(&ts, TIME_UTC);
ZX_CHECK(status == ZX_OK, status); CHECK(status != 0);
// The following expression will overflow in the year 289938 A.D.: return Time::FromTimeSpec(ts);
return Time::FromZxTime(nanos_since_unix_epoch);
} }
Time TimeNowFromSystemTimeIgnoringOverride() { Time TimeNowFromSystemTimeIgnoringOverride() {
......
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