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) {
114114 return @as(wasi.timestamp_t, @intCast(ts.sec * 1_000_000_000)) +
115115 @as(wasi.timestamp_t, @intCast(ts.nsec));
116116 }
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 };
117129 },
118130 // https://github.com/SerenityOS/serenity/blob/0a78056453578c18e0a04a0b45ebfb1c96d59005/Kernel/API/POSIX/time.h#L17-L20
119131 .windows, .serenity => extern struct {
......@@ -123,10 +135,34 @@ pub const timespec = switch (native_os) {
123135 .dragonfly, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
124136 sec: isize,
125137 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 };
126150 },
127151 .netbsd, .illumos => extern struct {
128152 sec: i64,
129153 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 };
130166 },
131167 .openbsd, .haiku => extern struct {
132168 sec: time_t,
lib/std/os/linux.zig+12
......@@ -8417,6 +8417,18 @@ pub const timezone = extern struct {
84178417pub const kernel_timespec = extern struct {
84188418 sec: i64,
84198419 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 };
84208432};
84218433
84228434// https://github.com/ziglang/zig/issues/4726#issuecomment-2190337877