| author | |
| committer | |
| log | 0a8e8e67d7e67e8381f2dcdb8e5ede8e42a71649 |
| tree | 71b723b9277106db0ce8b76d19db9cdc9ac0d82a |
| parent | 6376103b23617735044970f08c2a314c46b97c98 |
- Corrects WASI `UTIME_*` definitions now that the libc build has been
fixed (see previous commit), and adds the corresponding definitions
for Emscripten which were missing.
- Fixes `dirReadUnimplemented()`, which didn't compile.
- Prevents a dependency on `pthread_kill` from being pulled in in
single-threaded Emscripten builds, where it isn't defined.
With these changes, Emscripten can now participate in juicy main.3 files changed, 28 insertions(+), 4 deletions(-)
lib/std/Io/Threaded.zig+6-2| ... | ... | @@ -2024,6 +2024,7 @@ fn groupConcurrent( |
| 2024 | 2024 | |
| 2025 | 2025 | fn groupAwait(userdata: ?*anyopaque, type_erased: *Io.Group, initial_token: *anyopaque) Io.Cancelable!void { |
| 2026 | 2026 | _ = initial_token; // we need to load `token` *after* the group finishes |
| 2027 | if (builtin.single_threaded) unreachable; // nothing to await | |
| 2027 | 2028 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2028 | 2029 | const g: Group = .{ .ptr = type_erased }; |
| 2029 | 2030 | |
| ... | ... | @@ -2082,6 +2083,7 @@ fn groupAwait(userdata: ?*anyopaque, type_erased: *Io.Group, initial_token: *any |
| 2082 | 2083 | |
| 2083 | 2084 | fn groupCancel(userdata: ?*anyopaque, type_erased: *Io.Group, initial_token: *anyopaque) void { |
| 2084 | 2085 | _ = initial_token; |
| 2086 | if (builtin.single_threaded) unreachable; // nothing to cancel | |
| 2085 | 2087 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2086 | 2088 | const g: Group = .{ .ptr = type_erased }; |
| 2087 | 2089 | |
| ... | ... | @@ -2152,6 +2154,7 @@ fn await( |
| 2152 | 2154 | result_alignment: Alignment, |
| 2153 | 2155 | ) void { |
| 2154 | 2156 | _ = result_alignment; |
| 2157 | if (builtin.single_threaded) unreachable; // nothing to await | |
| 2155 | 2158 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2156 | 2159 | const future: *Future = @ptrCast(@alignCast(any_future)); |
| 2157 | 2160 | |
| ... | ... | @@ -2218,6 +2221,7 @@ fn cancel( |
| 2218 | 2221 | result_alignment: Alignment, |
| 2219 | 2222 | ) void { |
| 2220 | 2223 | _ = result_alignment; |
| 2224 | if (builtin.single_threaded) unreachable; // nothing to cancel | |
| 2221 | 2225 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2222 | 2226 | const future: *Future = @ptrCast(@alignCast(any_future)); |
| 2223 | 2227 | |
| ... | ... | @@ -4959,7 +4963,7 @@ fn dirReadUnimplemented(userdata: ?*anyopaque, dir_reader: *Dir.Reader, buffer: |
| 4959 | 4963 | _ = userdata; |
| 4960 | 4964 | _ = dir_reader; |
| 4961 | 4965 | _ = buffer; |
| 4962 | return error.Unimplemented; | |
| 4966 | return error.Unexpected; | |
| 4963 | 4967 | } |
| 4964 | 4968 | |
| 4965 | 4969 | const dirRealPathFile = switch (native_os) { |
| ... | ... | @@ -13224,7 +13228,7 @@ fn processSpawnPath(userdata: ?*anyopaque, dir: Dir, options: process.SpawnOptio |
| 13224 | 13228 | } |
| 13225 | 13229 | |
| 13226 | 13230 | const processSpawn = switch (native_os) { |
| 13227 | .wasi, .ios, .tvos, .visionos, .watchos => processSpawnUnsupported, | |
| 13231 | .wasi, .emscripten, .ios, .tvos, .visionos, .watchos => processSpawnUnsupported, | |
| 13228 | 13232 | .windows => processSpawnWindows, |
| 13229 | 13233 | else => processSpawnPosix, |
| 13230 | 13234 | }; |
lib/std/c.zig+6-2| ... | ... | @@ -97,6 +97,7 @@ pub const off_t = switch (native_os) { |
| 97 | 97 | pub const timespec = switch (native_os) { |
| 98 | 98 | .linux => linux.timespec, |
| 99 | 99 | .emscripten => emscripten.timespec, |
| 100 | // lib/libc/include/wasm-wasi-musl/__struct_timespec.h | |
| 100 | 101 | .wasi => extern struct { |
| 101 | 102 | sec: time_t, |
| 102 | 103 | nsec: isize, |
| ... | ... | @@ -115,16 +116,18 @@ pub const timespec = switch (native_os) { |
| 115 | 116 | @as(wasi.timestamp_t, @intCast(ts.nsec)); |
| 116 | 117 | } |
| 117 | 118 | |
| 119 | // lib/libc/include/wasm-wasi-musl/__header_sys_stat.h | |
| 120 | ||
| 118 | 121 | /// For use with `utimensat` and `futimens`. |
| 119 | 122 | pub const NOW: timespec = .{ |
| 120 | 123 | .sec = 0, |
| 121 | .nsec = 0x3fffffff, | |
| 124 | .nsec = -1, | |
| 122 | 125 | }; |
| 123 | 126 | |
| 124 | 127 | /// For use with `utimensat` and `futimens`. |
| 125 | 128 | pub const OMIT: timespec = .{ |
| 126 | 129 | .sec = 0, |
| 127 | .nsec = 0x3ffffffe, | |
| 130 | .nsec = -2, | |
| 128 | 131 | }; |
| 129 | 132 | }, |
| 130 | 133 | // https://github.com/SerenityOS/serenity/blob/0a78056453578c18e0a04a0b45ebfb1c96d59005/Kernel/API/POSIX/time.h#L17-L20 |
| ... | ... | @@ -7007,6 +7010,7 @@ pub const time_t = switch (native_os) { |
| 7007 | 7010 | .linux => linux.time_t, |
| 7008 | 7011 | .emscripten => emscripten.time_t, |
| 7009 | 7012 | .haiku, .dragonfly => isize, |
| 7013 | // lib/libc/include/wasm-wasi-musl/__typedef_time_t.h | |
| 7010 | 7014 | // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L47 |
| 7011 | 7015 | else => i64, |
| 7012 | 7016 | }; |
lib/std/os/emscripten.zig+16| ... | ... | @@ -729,6 +729,7 @@ pub const sockaddr = c.sockaddr; |
| 729 | 729 | |
| 730 | 730 | pub const blksize_t = i32; |
| 731 | 731 | pub const nlink_t = u32; |
| 732 | // https://github.com/emscripten-core/emscripten/blob/946ab574ae39401b51e75cd5257d894ae732ab54/system/lib/libc/musl/arch/emscripten/bits/alltypes.h#L140 | |
| 732 | 733 | pub const time_t = i64; |
| 733 | 734 | pub const mode_t = u32; |
| 734 | 735 | pub const off_t = i64; |
| ... | ... | @@ -765,9 +766,24 @@ pub const stack_t = extern struct { |
| 765 | 766 | size: usize, |
| 766 | 767 | }; |
| 767 | 768 | |
| 769 | // https://github.com/emscripten-core/emscripten/blob/946ab574ae39401b51e75cd5257d894ae732ab54/system/lib/libc/musl/arch/emscripten/bits/alltypes.h#L284 | |
| 768 | 770 | pub const timespec = extern struct { |
| 769 | 771 | sec: time_t, |
| 770 | 772 | nsec: isize, |
| 773 | ||
| 774 | // https://github.com/emscripten-core/emscripten/blob/d72d7226f4733af8ff993dec70198cf09a24142d/system/lib/libc/musl/include/sys/stat.h#L77-L78 | |
| 775 | ||
| 776 | /// For use with `utimensat` and `futimens`. | |
| 777 | pub const NOW: timespec = .{ | |
| 778 | .sec = 0, | |
| 779 | .nsec = 0x3fffffff, | |
| 780 | }; | |
| 781 | ||
| 782 | /// For use with `utimensat` and `futimens`. | |
| 783 | pub const OMIT: timespec = .{ | |
| 784 | .sec = 0, | |
| 785 | .nsec = 0x3ffffffe, | |
| 786 | }; | |
| 771 | 787 | }; |
| 772 | 788 | |
| 773 | 789 | pub const timezone = extern struct { |