diff options
author | Himbeer <himbeer@disroot.org> | 2024-07-31 16:36:43 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-07-31 16:36:43 +0200 |
commit | dba6cc46c970c858e2bb00313ca5d58294b5fa57 (patch) | |
tree | d70d41f2c0bcff24d744d78776b85a61983fe146 | |
parent | 8052528c7bcf30311f94cd39a6a5c2798db84a35 (diff) |
root: Provide entry point if not overriden by importer root source file
-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"), |