summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 11:40:11 -0300
committerGabriel Schneider <[email protected]>2026-11-05 12:41:36 -0300
commit3f1533813b6692a736251e4d467a7f108229ddee (patch)
tree37a32c5ebbf9d3af08923856fd6fa516f3b33a39 /src/main.zig
parentcfd2b993feda1b3f7474225bb32db8cac8edc5ae (diff)
downloadpardes-3f1533813b6692a736251e4d467a7f108229ddee.tar.gz
pardes-3f1533813b6692a736251e4d467a7f108229ddee.zip
targets: the DOM web shell goes (src/web.zig and src/web/, its harnesses web_harness, web_snapshot, web_driver_test and web-snapshots/, tools/web_fixture.py, -Dplatform=web, -Ddump, and the web, web-harness, web-snap, web-e2e and web-driver-test steps), and with it what only a freestanding build needed: `hosted` and every guard on it (every build has a host now), memory's stack-fallback arenas and reduced_target sizes, the emscripten main, the tree-sitter libc shim and the stb stub, lsp's has_client, the web arms of the platform switches (-Dplatform is tui, gui or macos); the macOS files pass zig ast-check; docs/web.md is a paragraph on what it was
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig46
1 files changed, 6 insertions, 40 deletions
diff --git a/src/main.zig b/src/main.zig
index a79a9716..4a3fbe8d 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -5,18 +5,8 @@ const ninep_io = @import("9p_io.zig");
const daemon = @import("daemon.zig");
const upgrade = @import("upgrade.zig");
-const is_emscripten = builtin.os.tag == .emscripten;
-
-extern "c" fn emscripten_console_error(utf8: [*:0]const u8) void;
-
-pub const std_options_debug_threaded_io: ?*std.Io.Threaded = if (is_emscripten)
- null
-else
- std.Io.Threaded.global_single_threaded;
-pub const std_options_debug_io: std.Io = if (is_emscripten)
- std.Io.failing
-else
- std_options_debug_threaded_io.?.io();
+pub const std_options_debug_threaded_io: ?*std.Io.Threaded = std.Io.Threaded.global_single_threaded;
+pub const std_options_debug_io: std.Io = std_options_debug_threaded_io.?.io();
// Every thread's alternate signal stack is a threadlocal that libc zeroes as
// the thread starts, so std's 256 KiB made each 9P connection's thread cost
@@ -42,7 +32,7 @@ fn logFn(
std.log.defaultLog(level, scope, format, args);
}
-pub const panic = if (is_emscripten) std.debug.FullPanic(std.debug.defaultPanic) else std.debug.FullPanic(struct {
+pub const panic = std.debug.FullPanic(struct {
fn call(msg: []const u8, ret_addr: ?usize) noreturn {
if (!recovering.swap(true, .seq_cst)) {
pardes.replica.dying();
@@ -55,7 +45,7 @@ pub const panic = if (is_emscripten) std.debug.FullPanic(std.debug.defaultPanic)
var recovering: std.atomic.Value(bool) = .init(false);
-pub const debug = if (is_emscripten) struct {} else struct {
+pub const debug = struct {
pub fn handleSegfault(addr: ?usize, name: []const u8, opt_ctx: anytype) noreturn {
if (!recovering.swap(true, .seq_cst)) {
pardes.replica.dying();
@@ -327,9 +317,7 @@ const nested_text =
\\
;
-// The browser runtime calls a C main (exported below); everything else keeps
-// the std.process.Init entry.
-pub const main = if (is_emscripten) webMain else nativeMain;
+pub const main = nativeMain;
// glibc's struct termios is 60 bytes, Zig 0.17's std.c.termios the kernel's
// 44: libc's tcgetattr wrote 16 bytes past every Zig caller's (vaxis's
@@ -372,28 +360,6 @@ test "tcgetattr writes nothing past a Zig termios" {
try std.testing.expectEqual(-1, std.c.tcgetattr(-1, &s.t));
}
-comptime {
- if (is_emscripten) @export(&emscriptenMain, .{ .name = "main" });
-}
-
-fn emscriptenMain(argc: c_int, argv: [*]?[*:0]u8) callconv(.c) c_int {
- _ = argc;
- _ = argv;
- webMain() catch |err| {
- var buf: [128]u8 = undefined;
- const msg = std.fmt.bufPrintSentinel(&buf, "pardes web init failed: {t}", .{err}, 0) catch "pardes web init failed";
- emscripten_console_error(msg.ptr);
- return 1;
- };
- return 0;
-}
-
-// no argv in the browser: options stay default, state comes from the dump, and
-// there is no session to attach to — a browser tab has no unix socket.
-fn webMain() !void {
- try @import("gui/gui.zig").run(.{}, .{}, false);
-}
-
// init.gpa, what the tui, gui and detached shells allocate from, is their
// own fixed arena (memory.host) in a release build, spilling to libc's
// malloc, and std.start's DebugAllocator in Debug. Zig 0.17's std.start
@@ -850,7 +816,7 @@ fn nativeMain(std_init: std.process.Init) !void {
else => return err,
},
.gui => try @import("gui/gui.zig").run(init, opts, headless),
- .web, .macos => unreachable,
+ .macos => unreachable,
}
daemon.tellStubExit(0);
}