aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Progress.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-07-15 01:27:23 -0700
committerGitHub <noreply@github.com>2024-07-15 01:27:23 -0700
commit9d38e82b5c0f28ea6a2d8d31ebd73b6e2a8aad26 (patch)
treeba3290d61fd4c856f73a14b6346c674a1a178ffb /lib/std/Progress.zig
parent583e698256a2a26f26738c983e319d76926ef048 (diff)
parent445bd7a06fc34c9a59c6458774769bfaa2757a2f (diff)
downloadzig-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.zig18
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,