diff options
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 46 |
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); } |
