diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index 212ee2fba18bcff3c33bcdaf8ae66fb7dff8fd9c..055b5e879a825a08500c8679f90f71c218c963bc 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -2024,6 +2024,7 @@ fn groupConcurrent( fn groupAwait(userdata: ?*anyopaque, type_erased: *Io.Group, initial_token: *anyopaque) Io.Cancelable!void { _ = initial_token; // we need to load `token` *after* the group finishes + if (builtin.single_threaded) unreachable; // nothing to await const t: *Threaded = @ptrCast(@alignCast(userdata)); const g: Group = .{ .ptr = type_erased }; @@ -2082,6 +2083,7 @@ fn groupAwait(userdata: ?*anyopaque, type_erased: *Io.Group, initial_token: *any fn groupCancel(userdata: ?*anyopaque, type_erased: *Io.Group, initial_token: *anyopaque) void { _ = initial_token; + if (builtin.single_threaded) unreachable; // nothing to cancel const t: *Threaded = @ptrCast(@alignCast(userdata)); const g: Group = .{ .ptr = type_erased }; @@ -2152,6 +2154,7 @@ fn await( result_alignment: Alignment, ) void { _ = result_alignment; + if (builtin.single_threaded) unreachable; // nothing to await const t: *Threaded = @ptrCast(@alignCast(userdata)); const future: *Future = @ptrCast(@alignCast(any_future)); @@ -2218,6 +2221,7 @@ fn cancel( result_alignment: Alignment, ) void { _ = result_alignment; + if (builtin.single_threaded) unreachable; // nothing to cancel const t: *Threaded = @ptrCast(@alignCast(userdata)); const future: *Future = @ptrCast(@alignCast(any_future)); @@ -4959,7 +4963,7 @@ fn dirReadUnimplemented(userdata: ?*anyopaque, dir_reader: *Dir.Reader, buffer: _ = userdata; _ = dir_reader; _ = buffer; - return error.Unimplemented; + return error.Unexpected; } const dirRealPathFile = switch (native_os) { @@ -13224,7 +13228,7 @@ fn processSpawnPath(userdata: ?*anyopaque, dir: Dir, options: process.SpawnOptio } const processSpawn = switch (native_os) { - .wasi, .ios, .tvos, .visionos, .watchos => processSpawnUnsupported, + .wasi, .emscripten, .ios, .tvos, .visionos, .watchos => processSpawnUnsupported, .windows => processSpawnWindows, else => processSpawnPosix, }; diff --git a/lib/std/c.zig b/lib/std/c.zig index 6f8370ee14a0db8e5d7bc13ee71b9401b25c4304..a59ecfd3a7bb8aa45c7905d3078c424efaa81f11 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -97,6 +97,7 @@ pub const off_t = switch (native_os) { pub const timespec = switch (native_os) { .linux => linux.timespec, .emscripten => emscripten.timespec, + // lib/libc/include/wasm-wasi-musl/__struct_timespec.h .wasi => extern struct { sec: time_t, nsec: isize, @@ -115,16 +116,18 @@ pub const timespec = switch (native_os) { @as(wasi.timestamp_t, @intCast(ts.nsec)); } + // lib/libc/include/wasm-wasi-musl/__header_sys_stat.h + /// For use with `utimensat` and `futimens`. pub const NOW: timespec = .{ .sec = 0, - .nsec = 0x3fffffff, + .nsec = -1, }; /// For use with `utimensat` and `futimens`. pub const OMIT: timespec = .{ .sec = 0, - .nsec = 0x3ffffffe, + .nsec = -2, }; }, // 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) { .linux => linux.time_t, .emscripten => emscripten.time_t, .haiku, .dragonfly => isize, + // lib/libc/include/wasm-wasi-musl/__typedef_time_t.h // https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L47 else => i64, }; diff --git a/lib/std/os/emscripten.zig b/lib/std/os/emscripten.zig index 119f0041e02a9b034b353d1a131851ec0cd6ef90..648407b20cf187f44ccf74234ed1b0621d206039 100644 --- a/lib/std/os/emscripten.zig +++ b/lib/std/os/emscripten.zig @@ -729,6 +729,7 @@ pub const sockaddr = c.sockaddr; pub const blksize_t = i32; pub const nlink_t = u32; +// https://github.com/emscripten-core/emscripten/blob/946ab574ae39401b51e75cd5257d894ae732ab54/system/lib/libc/musl/arch/emscripten/bits/alltypes.h#L140 pub const time_t = i64; pub const mode_t = u32; pub const off_t = i64; @@ -765,9 +766,24 @@ pub const stack_t = extern struct { size: usize, }; +// https://github.com/emscripten-core/emscripten/blob/946ab574ae39401b51e75cd5257d894ae732ab54/system/lib/libc/musl/arch/emscripten/bits/alltypes.h#L284 pub const timespec = extern struct { sec: time_t, nsec: isize, + + // https://github.com/emscripten-core/emscripten/blob/d72d7226f4733af8ff993dec70198cf09a24142d/system/lib/libc/musl/include/sys/stat.h#L77-L78 + + /// 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, + }; }; pub const timezone = extern struct {