diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-07-15 01:27:23 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-15 01:27:23 -0700 |
| commit | 9d38e82b5c0f28ea6a2d8d31ebd73b6e2a8aad26 (patch) | |
| tree | ba3290d61fd4c856f73a14b6346c674a1a178ffb /lib/std/Progress.zig | |
| parent | 583e698256a2a26f26738c983e319d76926ef048 (diff) | |
| parent | 445bd7a06fc34c9a59c6458774769bfaa2757a2f (diff) | |
| download | zig-9d38e82b5c0f28ea6a2d8d31ebd73b6e2a8aad26.tar.gz zig-9d38e82b5c0f28ea6a2d8d31ebd73b6e2a8aad26.zip | |
Merge pull request #20633 from ziglang/long-live-zig
make zig compiler processes live across rebuilds
Diffstat (limited to 'lib/std/Progress.zig')
| -rw-r--r-- | lib/std/Progress.zig | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/std/Progress.zig b/lib/std/Progress.zig index bb5adcefd1..190f667897 100644 --- a/lib/std/Progress.zig +++ b/lib/std/Progress.zig @@ -269,6 +269,19 @@ pub const Node = struct { storageByIndex(index).setIpcFd(fd); } + /// Posix-only. Thread-safe. Assumes the node is storing an IPC file + /// descriptor. + pub fn getIpcFd(node: Node) ?posix.fd_t { + const index = node.index.unwrap() orelse return null; + const storage = storageByIndex(index); + const int = @atomicLoad(u32, &storage.completed_count, .monotonic); + return switch (@typeInfo(posix.fd_t)) { + .Int => @bitCast(int), + .Pointer => @ptrFromInt(int), + else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)), + }; + } + fn storageByIndex(index: Node.Index) *Node.Storage { return &global_progress.node_storage[@intFromEnum(index)]; } @@ -329,6 +342,11 @@ var default_draw_buffer: [4096]u8 = undefined; var debug_start_trace = std.debug.Trace.init; +pub const have_ipc = switch (builtin.os.tag) { + .wasi, .freestanding, .windows => false, + else => true, +}; + const noop_impl = builtin.single_threaded or switch (builtin.os.tag) { .wasi, .freestanding => true, else => false, |
