Skip to content

Commit b74bce0

Browse files
committed
std.time.Clock: fix posix clock ids after ziglang#9618
1 parent 65de246 commit b74bce0

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lib/std/time.zig

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -249,28 +249,28 @@ pub const Clock = struct {
249249
// https://www.freebsd.org/cgi/man.cgi?query=clock_gettime
250250
fn toOsClockId(id: Id) ?i32 {
251251
return switch (id) {
252-
.realtime => os.CLOCK_REALTIME,
252+
.realtime => os.CLOCK.REALTIME,
253253
.monotonic => switch (target.os.tag) {
254254
// Calls mach_continuous_time() internally
255-
.macos, .tvos, .ios, .watchos => os.CLOCK_MONOTONIC_RAW,
256-
// Unlike CLOCK_MONOTONIC, this actually counts time suspended (true POSIX MONOTONIC)
257-
.linux => os.CLOCK_BOOTTIME,
258-
else => os.CLOCK_MONOTONIC,
255+
.macos, .tvos, .ios, .watchos => os.CLOCK.MONOTONIC_RAW,
256+
// Unlike CLOCK.MONOTONIC, this actually counts time suspended (true POSIX MONOTONIC)
257+
.linux => os.CLOCK.BOOTTIME,
258+
else => os.CLOCK.MONOTONIC,
259259
},
260260
.uptime => switch (target.os.tag) {
261-
.openbsd, .freebsd, .kfreebsd, .dragonfly => os.CLOCK_UPTIME,
261+
.openbsd, .freebsd, .kfreebsd, .dragonfly => os.CLOCK.UPTIME,
262262
// Calls mach_absolute_time() internally
263-
.macos, .tvos, .ios, .watchos => os.CLOCK_UPTIME_RAW,
264-
// CLOCK_MONOTONIC on linux actually doesn't count time suspended (not POSIX compliant).
265-
// At some point we may change our minds on CLOCK_MONOTONIC_RAW,
266-
// but for now we're sticking with CLOCK_MONOTONIC standard.
263+
.macos, .tvos, .ios, .watchos => os.CLOCK.UPTIME_RAW,
264+
// CLOCK.MONOTONIC on linux actually doesn't count time suspended (not POSIX compliant).
265+
// At some point we may change our minds on CLOCK.MONOTONIC_RAW,
266+
// but for now we're sticking with CLOCK.MONOTONIC standard.
267267
// For more information, see: https://github.com/ziglang/zig/pull/933
268-
.linux => os.CLOCK_MONOTONIC, // doesn't count time suspended
268+
.linux => os.CLOCK.MONOTONIC, // doesn't count time suspended
269269
// Platforms like wasi and netbsd don't support getting time without suspend
270270
else => null,
271271
},
272-
.thread_cputime => os.CLOCK_THREAD_CPUTIME_ID,
273-
.process_cputime => os.CLOCK_PROCESS_CPUTIME_ID,
272+
.thread_cputime => os.CLOCK.THREAD_CPUTIME_ID,
273+
.process_cputime => os.CLOCK.PROCESS_CPUTIME_ID,
274274
};
275275
}
276276
};

0 commit comments

Comments
 (0)