mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 04:24:33 +01:00
std: add more timespec OMIT and NOW definitions
This commit is contained in:
parent
10e72a8cad
commit
c0809c9b68
2 changed files with 48 additions and 0 deletions
|
|
@ -114,6 +114,18 @@ pub const timespec = switch (native_os) {
|
|||
return @as(wasi.timestamp_t, @intCast(ts.sec * 1_000_000_000)) +
|
||||
@as(wasi.timestamp_t, @intCast(ts.nsec));
|
||||
}
|
||||
|
||||
/// For use with `utimensat` and `futimens`.
|
||||
pub const NOW: timespec = .{
|
||||
.sec = 0,
|
||||
.nsec = 0x3fffffff,
|
||||
};
|
||||
|
||||
/// For use with `utimensat` and `futimens`.
|
||||
pub const OMIT: timespec = .{
|
||||
.sec = 0,
|
||||
.nsec = 0x3ffffffe,
|
||||
};
|
||||
},
|
||||
// https://github.com/SerenityOS/serenity/blob/0a78056453578c18e0a04a0b45ebfb1c96d59005/Kernel/API/POSIX/time.h#L17-L20
|
||||
.windows, .serenity => extern struct {
|
||||
|
|
@ -123,10 +135,34 @@ pub const timespec = switch (native_os) {
|
|||
.dragonfly, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
|
||||
sec: isize,
|
||||
nsec: isize,
|
||||
|
||||
/// For use with `utimensat` and `futimens`.
|
||||
pub const NOW: timespec = .{
|
||||
.sec = 0,
|
||||
.nsec = -1,
|
||||
};
|
||||
|
||||
/// For use with `utimensat` and `futimens`.
|
||||
pub const OMIT: timespec = .{
|
||||
.sec = 0,
|
||||
.nsec = -2,
|
||||
};
|
||||
},
|
||||
.netbsd, .illumos => extern struct {
|
||||
sec: i64,
|
||||
nsec: isize,
|
||||
|
||||
/// For use with `utimensat` and `futimens`.
|
||||
pub const NOW: timespec = .{
|
||||
.sec = 0,
|
||||
.nsec = 0x3fffffff,
|
||||
};
|
||||
|
||||
/// For use with `utimensat` and `futimens`.
|
||||
pub const OMIT: timespec = .{
|
||||
.sec = 0,
|
||||
.nsec = 0x3ffffffe,
|
||||
};
|
||||
},
|
||||
.openbsd, .haiku => extern struct {
|
||||
sec: time_t,
|
||||
|
|
|
|||
|
|
@ -8417,6 +8417,18 @@ pub const timezone = extern struct {
|
|||
pub const kernel_timespec = extern struct {
|
||||
sec: i64,
|
||||
nsec: i64,
|
||||
|
||||
/// For use with `utimensat` and `futimens`.
|
||||
pub const NOW: timespec = .{
|
||||
.sec = 0,
|
||||
.nsec = 0x3fffffff,
|
||||
};
|
||||
|
||||
/// For use with `utimensat` and `futimens`.
|
||||
pub const OMIT: timespec = .{
|
||||
.sec = 0,
|
||||
.nsec = 0x3ffffffe,
|
||||
};
|
||||
};
|
||||
|
||||
// https://github.com/ziglang/zig/issues/4726#issuecomment-2190337877
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue