Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli.zig
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub fn main(init: std.process.Init.Minimal) !void {
const alloc = gpa.allocator();

// Initialize std.Io runtime (Auto-selects Evented on Linux, Threaded elsewhere)
try runtime.init(alloc);
try runtime.init(alloc, init.environ);
defer runtime.deinit();

var arena_state: std.heap.ArenaAllocator = .init(std.heap.page_allocator);
Expand Down
2 changes: 1 addition & 1 deletion examples/ui-showcase/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn main(init: std.process.Init.Minimal) !void {
const alloc = gpa.allocator();

// Initialize std.Io runtime (Auto-selects Evented on Linux, Threaded elsewhere)
try runtime.init(alloc);
try runtime.init(alloc, init.environ);
defer runtime.deinit();

var arena_state: std.heap.ArenaAllocator = .init(std.heap.page_allocator);
Expand Down
2 changes: 1 addition & 1 deletion src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn main(init: std.process.Init.Minimal) !void {
const alloc = gpa.allocator();

// Initialize std.Io runtime (Auto-selects Evented on Linux, Threaded elsewhere)
try runtime.init(alloc);
try runtime.init(alloc, init.environ);
defer runtime.deinit();

// 0.16: args come through init parameter.
Expand Down
6 changes: 3 additions & 3 deletions src/runtime.zig
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ const use_evented = blk: {
// Evented storage only exists when supported
var evented: if (use_evented) std.Io.Evented else void = undefined;

pub fn init(gpa: std.mem.Allocator) !void {
pub fn init(gpa: std.mem.Allocator, environ: std.process.Environ) !void {
if (use_evented) {
// Linux: Use Evented (io_uring)
evented = undefined;
try std.Io.Evented.init(&evented, gpa, .{});
try std.Io.Evented.init(&evented, gpa, .{ .environ = environ });
io = evented.io();
} else {
// macOS/Other: Use Threaded (Evented has bugs or isn't available)
threaded = std.Io.Threaded.init(gpa, .{});
threaded = std.Io.Threaded.init(gpa, .{ .environ = environ });
io = threaded.io();
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/runtime_threaded.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const std = @import("std");
/// This lets us flip between Threaded (today) and Evented (tomorrow for io_uring)
/// without touching call sites.
///
/// Initialize once in main(): runtime.init(gpa);
/// Initialize once in main(): runtime.init(gpa, init.environ);
/// Clean up on exit: defer runtime.deinit();
pub var threaded: std.Io.Threaded = undefined;
pub var io: std.Io = undefined;

pub fn init(gpa: std.mem.Allocator) void {
threaded = std.Io.Threaded.init(gpa, .{});
pub fn init(gpa: std.mem.Allocator, environ: std.process.Environ) void {
threaded = std.Io.Threaded.init(gpa, .{ .environ = environ });
io = threaded.io();
}

Expand Down
2 changes: 1 addition & 1 deletion tools/codegen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn main() !void {
const alloc = gpa.allocator();

// Initialize std.Io runtime (Auto-selects Evented on Linux, Threaded elsewhere)
try runtime.init(alloc);
try runtime.init(alloc, .empty);
defer runtime.deinit();

// Each entry stores the full relative path from the project root.
Expand Down