authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-27 11:07:28-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-27 11:08:56-08:00
logc0809c9b68ad33b9963ff3da1a6ad53ca2c8b6f3
tree6c4fa4c74f16dcbac8f64c4af18f10705bab5679
parent10e72a8cad48e3e9e68f51d9e6769e30566029b1

std: add more timespec OMIT and NOW definitions


2 files changed, 48 insertions(+), 0 deletions(-)

lib/std/c.zig+36
...@@ -114,6 +114,18 @@ pub const timespec = switch (native_os) {...@@ -114,6 +114,18 @@ pub const timespec = switch (native_os) {
114 return @as(wasi.timestamp_t, @intCast(ts.sec * 1_000_000_000)) +114 return @as(wasi.timestamp_t, @intCast(ts.sec * 1_000_000_000)) +
115 @as(wasi.timestamp_t, @intCast(ts.nsec));115 @as(wasi.timestamp_t, @intCast(ts.nsec));
116 }116 }
117
118 /// For use with `utimensat` and `futimens`.
119 pub const NOW: timespec = .{
120 .sec = 0,
121 .nsec = 0x3fffffff,
122 };
123
124 /// For use with `utimensat` and `futimens`.
125 pub const OMIT: timespec = .{
126 .sec = 0,
127 .nsec = 0x3ffffffe,
128 };
117 },129 },
118 // https://github.com/SerenityOS/serenity/blob/0a78056453578c18e0a04a0b45ebfb1c96d59005/Kernel/API/POSIX/time.h#L17-L20130 // https://github.com/SerenityOS/serenity/blob/0a78056453578c18e0a04a0b45ebfb1c96d59005/Kernel/API/POSIX/time.h#L17-L20
119 .windows, .serenity => extern struct {131 .windows, .serenity => extern struct {
...@@ -123,10 +135,34 @@ pub const timespec = switch (native_os) {...@@ -123,10 +135,34 @@ pub const timespec = switch (native_os) {
123 .dragonfly, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {135 .dragonfly, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
124 sec: isize,136 sec: isize,
125 nsec: isize,137 nsec: isize,
138
139 /// For use with `utimensat` and `futimens`.
140 pub const NOW: timespec = .{
141 .sec = 0,
142 .nsec = -1,
143 };
144
145 /// For use with `utimensat` and `futimens`.
146 pub const OMIT: timespec = .{
147 .sec = 0,
148 .nsec = -2,
149 };
126 },150 },
127 .netbsd, .illumos => extern struct {151 .netbsd, .illumos => extern struct {
128 sec: i64,152 sec: i64,
129 nsec: isize,153 nsec: isize,
154
155 /// For use with `utimensat` and `futimens`.
156 pub const NOW: timespec = .{
157 .sec = 0,
158 .nsec = 0x3fffffff,
159 };
160
161 /// For use with `utimensat` and `futimens`.
162 pub const OMIT: timespec = .{
163 .sec = 0,
164 .nsec = 0x3ffffffe,
165 };
130 },166 },
131 .openbsd, .haiku => extern struct {167 .openbsd, .haiku => extern struct {
132 sec: time_t,168 sec: time_t,
lib/std/os/linux.zig+12
...@@ -8417,6 +8417,18 @@ pub const timezone = extern struct {...@@ -8417,6 +8417,18 @@ pub const timezone = extern struct {
8417pub const kernel_timespec = extern struct {8417pub const kernel_timespec = extern struct {
8418 sec: i64,8418 sec: i64,
8419 nsec: i64,8419 nsec: i64,
8420
8421 /// For use with `utimensat` and `futimens`.
8422 pub const NOW: timespec = .{
8423 .sec = 0,
8424 .nsec = 0x3fffffff,
8425 };
8426
8427 /// For use with `utimensat` and `futimens`.
8428 pub const OMIT: timespec = .{
8429 .sec = 0,
8430 .nsec = 0x3ffffffe,
8431 };
8420};8432};
84218433
8422// https://github.com/ziglang/zig/issues/4726#issuecomment-21903378778434// https://github.com/ziglang/zig/issues/4726#issuecomment-2190337877