diff options
-rw-r--r-- | src/root.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/root.zig b/src/root.zig index 42ef2d0..f0cc048 100644 --- a/src/root.zig +++ b/src/root.zig @@ -2,6 +2,8 @@ // // SPDX-License-Identifier: AGPL-3.0-or-later +const builtin = @import("builtin"); +const root = @import("root"); const std = @import("std"); pub const hwinfo = @import("hwinfo.zig"); @@ -14,6 +16,16 @@ const Result = struct { const SyscallError = error{Kernel}; +fn _start() noreturn { + if (!@hasDecl(root, "main")) @compileError("no main function"); + root.main(); + end(); +} + +comptime { + if (!builtin.is_test) @export(_start, .{ .name = "_start" }); +} + fn autoCast(value: anytype) usize { return switch (@typeInfo(@TypeOf(value))) { .Type => @compileError("cannot pass type to system call"), |