| ... | ... | @@ -94,13 +94,36 @@ pub const off_t = switch (native_os) { |
| 94 | 94 | else => i64, |
| 95 | 95 | }; |
| 96 | 96 | |
| 97 | /// For use with `utimensat` and `futimens`. |
| 98 | pub const UTIME = switch (native_os) { |
| 99 | .dragonfly, .freebsd, .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .wasi => struct { |
| 100 | pub const NOW: timespec = .{ .sec = 0, .nsec = -1 }; |
| 101 | pub const OMIT: timespec = .{ .sec = 0, .nsec = -2 }; |
| 102 | }, |
| 103 | .emscripten => emscripten.UTIME, |
| 104 | .haiku => struct { |
| 105 | pub const NOW: timespec = .{ .sec = 0, .nsec = 1000000000 }; |
| 106 | pub const OMIT: timespec = .{ .sec = 0, .nsec = 1000000001 }; |
| 107 | }, |
| 108 | .linux => linux.UTIME, |
| 109 | .netbsd => struct { |
| 110 | pub const NOW: timespec = .{ .sec = 0, .nsec = 0x3fffffff }; |
| 111 | pub const OMIT: timespec = .{ .sec = 0, .nsec = 0x3ffffffe }; |
| 112 | }, |
| 113 | .openbsd, .serenity => struct { |
| 114 | pub const NOW: timespec = .{ .sec = 0, .nsec = -2 }; |
| 115 | pub const OMIT: timespec = .{ .sec = 0, .nsec = -1 }; |
| 116 | }, |
| 117 | else => void, |
| 118 | }; |
| 119 | |
| 97 | 120 | pub const timespec = switch (native_os) { |
| 98 | 121 | .linux => linux.timespec, |
| 99 | 122 | .emscripten => emscripten.timespec, |
| 100 | 123 | // lib/libc/include/wasm-wasi-musl/__struct_timespec.h |
| 101 | 124 | .wasi => extern struct { |
| 102 | 125 | sec: time_t, |
| 103 | | nsec: isize, |
| 126 | nsec: c_long, |
| 104 | 127 | |
| 105 | 128 | pub fn fromTimestamp(tm: wasi.timestamp_t) timespec { |
| 106 | 129 | const sec: wasi.timestamp_t = tm / 1_000_000_000; |
| ... | ... | @@ -115,74 +138,12 @@ pub const timespec = switch (native_os) { |
| 115 | 138 | return @as(wasi.timestamp_t, @intCast(ts.sec * 1_000_000_000)) + |
| 116 | 139 | @as(wasi.timestamp_t, @intCast(ts.nsec)); |
| 117 | 140 | } |
| 118 | | |
| 119 | | // lib/libc/include/wasm-wasi-musl/__header_sys_stat.h |
| 120 | | |
| 121 | | /// For use with `utimensat` and `futimens`. |
| 122 | | pub const NOW: timespec = .{ |
| 123 | | .sec = 0, |
| 124 | | .nsec = -1, |
| 125 | | }; |
| 126 | | |
| 127 | | /// For use with `utimensat` and `futimens`. |
| 128 | | pub const OMIT: timespec = .{ |
| 129 | | .sec = 0, |
| 130 | | .nsec = -2, |
| 131 | | }; |
| 132 | 141 | }, |
| 133 | 142 | // https://github.com/SerenityOS/serenity/blob/0a78056453578c18e0a04a0b45ebfb1c96d59005/Kernel/API/POSIX/time.h#L17-L20 |
| 134 | | .windows, .serenity => extern struct { |
| 143 | .dragonfly, .freebsd, .netbsd, .openbsd, .illumos, .haiku, .serenity, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .windows => extern struct { |
| 135 | 144 | sec: time_t, |
| 136 | 145 | nsec: c_long, |
| 137 | 146 | }, |
| 138 | | .dragonfly, .freebsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 139 | | sec: isize, |
| 140 | | nsec: isize, |
| 141 | | |
| 142 | | /// For use with `utimensat` and `futimens`. |
| 143 | | pub const NOW: timespec = .{ |
| 144 | | .sec = 0, |
| 145 | | .nsec = -1, |
| 146 | | }; |
| 147 | | |
| 148 | | /// For use with `utimensat` and `futimens`. |
| 149 | | pub const OMIT: timespec = .{ |
| 150 | | .sec = 0, |
| 151 | | .nsec = -2, |
| 152 | | }; |
| 153 | | }, |
| 154 | | .netbsd, .illumos => extern struct { |
| 155 | | sec: i64, |
| 156 | | nsec: isize, |
| 157 | | |
| 158 | | /// For use with `utimensat` and `futimens`. |
| 159 | | pub const NOW: timespec = .{ |
| 160 | | .sec = 0, |
| 161 | | .nsec = 0x3fffffff, |
| 162 | | }; |
| 163 | | |
| 164 | | /// For use with `utimensat` and `futimens`. |
| 165 | | pub const OMIT: timespec = .{ |
| 166 | | .sec = 0, |
| 167 | | .nsec = 0x3ffffffe, |
| 168 | | }; |
| 169 | | }, |
| 170 | | .openbsd, .haiku => extern struct { |
| 171 | | sec: time_t, |
| 172 | | nsec: isize, |
| 173 | | |
| 174 | | /// For use with `utimensat` and `futimens`. |
| 175 | | pub const NOW: timespec = .{ |
| 176 | | .sec = 0, // ignored |
| 177 | | .nsec = -2, |
| 178 | | }; |
| 179 | | |
| 180 | | /// For use with `utimensat` and `futimens`. |
| 181 | | pub const OMIT: timespec = .{ |
| 182 | | .sec = 0, // ignored |
| 183 | | .nsec = -1, |
| 184 | | }; |
| 185 | | }, |
| 186 | 147 | else => void, |
| 187 | 148 | }; |
| 188 | 149 | |
| ... | ... | @@ -4128,7 +4089,7 @@ pub const in6_pktinfo = switch (native_os) { |
| 4128 | 4089 | }; |
| 4129 | 4090 | pub const itimerspec = switch (native_os) { |
| 4130 | 4091 | .linux => linux.itimerspec, |
| 4131 | | .haiku => extern struct { |
| 4092 | .dragonfly, .freebsd, .netbsd, .openbsd, .haiku, .illumos, .windows, .wasi => extern struct { |
| 4132 | 4093 | interval: timespec, |
| 4133 | 4094 | value: timespec, |
| 4134 | 4095 | }, |
| ... | ... | @@ -7037,18 +6998,19 @@ pub const stack_t = switch (native_os) { |
| 7037 | 6998 | }; |
| 7038 | 6999 | pub const time_t = switch (native_os) { |
| 7039 | 7000 | .linux => linux.time_t, |
| 7001 | .dragonfly, .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => c_long, |
| 7040 | 7002 | .emscripten => emscripten.time_t, |
| 7041 | | .haiku, .dragonfly => isize, |
| 7042 | | // lib/libc/include/wasm-wasi-musl/__typedef_time_t.h |
| 7003 | .freebsd, .haiku => if (native_arch == .x86) c_int else c_longlong, |
| 7043 | 7004 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L47 |
| 7044 | | else => i64, |
| 7005 | // lib/libc/include/wasm-wasi-musl/__typedef_time_t.h |
| 7006 | .netbsd, .openbsd, .serenity, .wasi => c_longlong, |
| 7007 | else => void, |
| 7045 | 7008 | }; |
| 7046 | 7009 | pub const suseconds_t = switch (native_os) { |
| 7010 | .dragonfly, .freebsd, .openbsd, .illumos => c_long, |
| 7011 | .netbsd, .haiku, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => c_int, |
| 7047 | 7012 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L49 |
| 7048 | | .illumos, .serenity => i64, |
| 7049 | | .freebsd, .dragonfly => c_long, |
| 7050 | | .netbsd => c_int, |
| 7051 | | .haiku => i32, |
| 7013 | .serenity, .wasi => c_longlong, |
| 7052 | 7014 | else => void, |
| 7053 | 7015 | }; |
| 7054 | 7016 | |
| ... | ... | @@ -7059,32 +7021,20 @@ pub const timeval = switch (native_os) { |
| 7059 | 7021 | sec: c_long, |
| 7060 | 7022 | usec: c_long, |
| 7061 | 7023 | }, |
| 7062 | | .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 7063 | | sec: c_long, |
| 7064 | | usec: i32, |
| 7065 | | }, |
| 7066 | 7024 | // https://github.com/SerenityOS/serenity/blob/6b6eca0631c893c5f8cfb8274cdfe18e2d0637c0/Kernel/API/POSIX/sys/time.h#L15-L18 |
| 7067 | | .dragonfly, .netbsd, .freebsd, .illumos, .serenity => extern struct { |
| 7025 | .dragonfly, .freebsd, .netbsd, .openbsd, .haiku, .illumos, .serenity, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .wasi => extern struct { |
| 7068 | 7026 | /// seconds |
| 7069 | 7027 | sec: time_t, |
| 7070 | 7028 | /// microseconds |
| 7071 | 7029 | usec: suseconds_t, |
| 7072 | 7030 | }, |
| 7073 | | .openbsd => extern struct { |
| 7074 | | sec: time_t, |
| 7075 | | usec: c_long, |
| 7076 | | }, |
| 7077 | 7031 | else => void, |
| 7078 | 7032 | }; |
| 7079 | 7033 | pub const timezone = switch (native_os) { |
| 7080 | 7034 | .linux => linux.timezone, |
| 7081 | 7035 | .emscripten => emscripten.timezone, |
| 7082 | | .openbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { |
| 7083 | | minuteswest: i32, |
| 7084 | | dsttime: i32, |
| 7085 | | }, |
| 7086 | 7036 | // https://github.com/SerenityOS/serenity/blob/ba776390b5878ec0be1a9e595a3471a6cfe0a0cf/Userland/Libraries/LibC/sys/time.h#L19-L22 |
| 7087 | | .serenity => extern struct { |
| 7037 | .dragonfly, .freebsd, .netbsd, .openbsd, .haiku, .illumos, .serenity, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos, .windows, .wasi => extern struct { |
| 7088 | 7038 | minuteswest: c_int, |
| 7089 | 7039 | dsttime: c_int, |
| 7090 | 7040 | }, |