| ... | @@ -94,13 +94,36 @@ pub const off_t = switch (native_os) { | ... | @@ -94,13 +94,36 @@ pub const off_t = switch (native_os) { |
| 94 | else => i64, | 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 | pub const timespec = switch (native_os) { | 120 | pub const timespec = switch (native_os) { |
| 98 | .linux => linux.timespec, | 121 | .linux => linux.timespec, |
| 99 | .emscripten => emscripten.timespec, | 122 | .emscripten => emscripten.timespec, |
| 100 | // lib/libc/include/wasm-wasi-musl/__struct_timespec.h | 123 | // lib/libc/include/wasm-wasi-musl/__struct_timespec.h |
| 101 | .wasi => extern struct { | 124 | .wasi => extern struct { |
| 102 | sec: time_t, | 125 | sec: time_t, |
| 103 | nsec: isize, | 126 | nsec: c_long, |
| 104 | | 127 | |
| 105 | pub fn fromTimestamp(tm: wasi.timestamp_t) timespec { | 128 | pub fn fromTimestamp(tm: wasi.timestamp_t) timespec { |
| 106 | const sec: wasi.timestamp_t = tm / 1_000_000_000; | 129 | const sec: wasi.timestamp_t = tm / 1_000_000_000; |
| ... | @@ -115,74 +138,12 @@ pub const timespec = switch (native_os) { | ... | @@ -115,74 +138,12 @@ pub const timespec = switch (native_os) { |
| 115 | return @as(wasi.timestamp_t, @intCast(ts.sec * 1_000_000_000)) + | 138 | return @as(wasi.timestamp_t, @intCast(ts.sec * 1_000_000_000)) + |
| 116 | @as(wasi.timestamp_t, @intCast(ts.nsec)); | 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 | // https://github.com/SerenityOS/serenity/blob/0a78056453578c18e0a04a0b45ebfb1c96d59005/Kernel/API/POSIX/time.h#L17-L20 | 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 | sec: time_t, | 144 | sec: time_t, |
| 136 | nsec: c_long, | 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 | else => void, | 147 | else => void, |
| 187 | }; | 148 | }; |
| 188 | | 149 | |
| ... | @@ -4128,7 +4089,7 @@ pub const in6_pktinfo = switch (native_os) { | ... | @@ -4128,7 +4089,7 @@ pub const in6_pktinfo = switch (native_os) { |
| 4128 | }; | 4089 | }; |
| 4129 | pub const itimerspec = switch (native_os) { | 4090 | pub const itimerspec = switch (native_os) { |
| 4130 | .linux => linux.itimerspec, | 4091 | .linux => linux.itimerspec, |
| 4131 | .haiku => extern struct { | 4092 | .dragonfly, .freebsd, .netbsd, .openbsd, .haiku, .illumos, .windows, .wasi => extern struct { |
| 4132 | interval: timespec, | 4093 | interval: timespec, |
| 4133 | value: timespec, | 4094 | value: timespec, |
| 4134 | }, | 4095 | }, |
| ... | @@ -7037,18 +6998,19 @@ pub const stack_t = switch (native_os) { | ... | @@ -7037,18 +6998,19 @@ pub const stack_t = switch (native_os) { |
| 7037 | }; | 6998 | }; |
| 7038 | pub const time_t = switch (native_os) { | 6999 | pub const time_t = switch (native_os) { |
| 7039 | .linux => linux.time_t, | 7000 | .linux => linux.time_t, |
| | 7001 | .dragonfly, .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => c_long, |
| 7040 | .emscripten => emscripten.time_t, | 7002 | .emscripten => emscripten.time_t, |
| 7041 | .haiku, .dragonfly => isize, | 7003 | .freebsd, .haiku => if (native_arch == .x86) c_int else c_longlong, |
| 7042 | // lib/libc/include/wasm-wasi-musl/__typedef_time_t.h | | |
| 7043 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L47 | 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 | pub const suseconds_t = switch (native_os) { | 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 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L49 | 7012 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L49 |
| 7048 | .illumos, .serenity => i64, | 7013 | .serenity, .wasi => c_longlong, |
| 7049 | .freebsd, .dragonfly => c_long, | | |
| 7050 | .netbsd => c_int, | | |
| 7051 | .haiku => i32, | | |
| 7052 | else => void, | 7014 | else => void, |
| 7053 | }; | 7015 | }; |
| 7054 | | 7016 | |
| ... | @@ -7059,32 +7021,20 @@ pub const timeval = switch (native_os) { | ... | @@ -7059,32 +7021,20 @@ pub const timeval = switch (native_os) { |
| 7059 | sec: c_long, | 7021 | sec: c_long, |
| 7060 | usec: c_long, | 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 | // https://github.com/SerenityOS/serenity/blob/6b6eca0631c893c5f8cfb8274cdfe18e2d0637c0/Kernel/API/POSIX/sys/time.h#L15-L18 | 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 | /// seconds | 7026 | /// seconds |
| 7069 | sec: time_t, | 7027 | sec: time_t, |
| 7070 | /// microseconds | 7028 | /// microseconds |
| 7071 | usec: suseconds_t, | 7029 | usec: suseconds_t, |
| 7072 | }, | 7030 | }, |
| 7073 | .openbsd => extern struct { | | |
| 7074 | sec: time_t, | | |
| 7075 | usec: c_long, | | |
| 7076 | }, | | |
| 7077 | else => void, | 7031 | else => void, |
| 7078 | }; | 7032 | }; |
| 7079 | pub const timezone = switch (native_os) { | 7033 | pub const timezone = switch (native_os) { |
| 7080 | .linux => linux.timezone, | 7034 | .linux => linux.timezone, |
| 7081 | .emscripten => emscripten.timezone, | 7035 | .emscripten => emscripten.timezone, |
| 7082 | .openbsd, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct { | | |
| 7083 | minuteswest: i32, | | |
| 7084 | dsttime: i32, | | |
| 7085 | }, | | |
| 7086 | // https://github.com/SerenityOS/serenity/blob/ba776390b5878ec0be1a9e595a3471a6cfe0a0cf/Userland/Libraries/LibC/sys/time.h#L19-L22 | 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 | minuteswest: c_int, | 7038 | minuteswest: c_int, |
| 7089 | dsttime: c_int, | 7039 | dsttime: c_int, |
| 7090 | }, | 7040 | }, |