mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 02:44:43 +01:00
Misc. std.Io fixes for WASI and Emscripten
- 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.
This commit is contained in:
parent
6376103b23
commit
0a8e8e67d7
3 changed files with 28 additions and 4 deletions
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue