diff options
| author | Chris Boesch <48591413+chrboesch@users.noreply.github.com> | 2025-02-01 07:53:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-01 06:53:57 +0000 |
| commit | 58c00a829e8acf438b91e9f7e1729ce79be722fa (patch) | |
| tree | 21a7941f28fe1aea30c2591d116ad09334b34c8d /lib/std/time.zig | |
| parent | c44be99f1abff2ab67d69964efecca380b96219e (diff) | |
| download | zig-58c00a829e8acf438b91e9f7e1729ce79be722fa.tar.gz zig-58c00a829e8acf438b91e9f7e1729ce79be722fa.zip | |
std.posix: Use separate clock ID enums for clock_gettime() and timerfd_create() (#22627)
Diffstat (limited to 'lib/std/time.zig')
| -rw-r--r-- | lib/std/time.zig | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/std/time.zig b/lib/std/time.zig index d253b63512..3dbe2e837b 100644 --- a/lib/std/time.zig +++ b/lib/std/time.zig @@ -68,8 +68,7 @@ pub fn nanoTimestamp() i128 { return value.toEpoch(); }, else => { - var ts: posix.timespec = undefined; - posix.clock_gettime(.REALTIME, &ts) catch |err| switch (err) { + const ts = posix.clock_gettime(.REALTIME) catch |err| switch (err) { error.UnsupportedClock, error.Unexpected => return 0, // "Precision of timing depends on hardware and OS". }; return (@as(i128, ts.sec) * ns_per_s) + ts.nsec; @@ -171,8 +170,7 @@ pub const Instant = struct { else => posix.CLOCK.MONOTONIC, }; - var ts: posix.timespec = undefined; - posix.clock_gettime(clock_id, &ts) catch return error.Unsupported; + const ts = posix.clock_gettime(clock_id) catch return error.Unsupported; return .{ .timestamp = ts }; } |
