| ... | ... | @@ -269,6 +269,19 @@ pub const Node = struct { |
| 269 | 269 | storageByIndex(index).setIpcFd(fd); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | /// Posix-only. Thread-safe. Assumes the node is storing an IPC file |
| 273 | /// descriptor. |
| 274 | pub fn getIpcFd(node: Node) ?posix.fd_t { |
| 275 | const index = node.index.unwrap() orelse return null; |
| 276 | const storage = storageByIndex(index); |
| 277 | const int = @atomicLoad(u32, &storage.completed_count, .monotonic); |
| 278 | return switch (@typeInfo(posix.fd_t)) { |
| 279 | .Int => @bitCast(int), |
| 280 | .Pointer => @ptrFromInt(int), |
| 281 | else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)), |
| 282 | }; |
| 283 | } |
| 284 | |
| 272 | 285 | fn storageByIndex(index: Node.Index) *Node.Storage { |
| 273 | 286 | return &global_progress.node_storage[@intFromEnum(index)]; |
| 274 | 287 | } |
| ... | ... | @@ -329,6 +342,11 @@ var default_draw_buffer: [4096]u8 = undefined; |
| 329 | 342 | |
| 330 | 343 | var debug_start_trace = std.debug.Trace.init; |
| 331 | 344 | |
| 345 | pub const have_ipc = switch (builtin.os.tag) { |
| 346 | .wasi, .freestanding, .windows => false, |
| 347 | else => true, |
| 348 | }; |
| 349 | |
| 332 | 350 | const noop_impl = builtin.single_threaded or switch (builtin.os.tag) { |
| 333 | 351 | .wasi, .freestanding => true, |
| 334 | 352 | else => false, |