aboutsummaryrefslogtreecommitdiff
path: root/lib/std/special
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2019-12-12 01:31:32 +0000
committerAndrew Kelley <andrew@ziglang.org>2019-12-12 16:00:23 -0500
commitb37acc4d6870a090c3501d81d3f647bc30220e4b (patch)
tree5b906c0cc4c9bb358d64324b25492a4b6cabd48a /lib/std/special
parent81f1f72197113a45e827d5c984e219a28aa28083 (diff)
downloadzig-b37acc4d6870a090c3501d81d3f647bc30220e4b.tar.gz
zig-b37acc4d6870a090c3501d81d3f647bc30220e4b.zip
allow custom OS entrypoint
Also: * Expose `std.start.callMain`. * Other fixes added to fix issues found in development.
Diffstat (limited to 'lib/std/special')
-rw-r--r--lib/std/special/c.zig2
-rw-r--r--lib/std/special/start.zig15
2 files changed, 7 insertions, 10 deletions
diff --git a/lib/std/special/c.zig b/lib/std/special/c.zig
index 4c2eb2a958..0895b1e6f9 100644
--- a/lib/std/special/c.zig
+++ b/lib/std/special/c.zig
@@ -83,7 +83,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn
@setCold(true);
std.debug.panic("{}", msg);
}
- if (builtin.os != .freestanding) {
+ if (builtin.os != .freestanding and builtin.os != .other) {
std.os.abort();
}
while (true) {}
diff --git a/lib/std/special/start.zig b/lib/std/special/start.zig
index 60745dab7f..ee53254098 100644
--- a/lib/std/special/start.zig
+++ b/lib/std/special/start.zig
@@ -17,6 +17,7 @@ const is_mips = switch (builtin.arch) {
.mips, .mipsel, .mips64, .mips64el => true,
else => false,
};
+const start_sym_name = if (is_mips) "__start" else "_start";
comptime {
if (builtin.output_mode == .Lib and builtin.link_mode == .Dynamic) {
@@ -34,14 +35,10 @@ comptime {
}
} else if (builtin.os == .uefi) {
if (!@hasDecl(root, "EfiMain")) @export("EfiMain", EfiMain, .Strong);
- } else if (builtin.os != .freestanding) {
- if (is_mips) {
- if (!@hasDecl(root, "__start")) @export("__start", _start, .Strong);
- } else {
- if (!@hasDecl(root, "_start")) @export("_start", _start, .Strong);
- }
- } else if (is_wasm) {
- if (!@hasDecl(root, "_start")) @export("_start", wasm_freestanding_start, .Strong);
+ } else if (is_wasm and builtin.os == .freestanding) {
+ if (!@hasDecl(root, start_sym_name)) @export(start_sym_name, wasm_freestanding_start, .Strong);
+ } else if (builtin.os != .other and builtin.os != .freestanding) {
+ if (!@hasDecl(root, start_sym_name)) @export(start_sym_name, _start, .Strong);
}
}
}
@@ -247,7 +244,7 @@ async fn callMainAsync(loop: *std.event.Loop) u8 {
// This is not marked inline because it is called with @asyncCall when
// there is an event loop.
-fn callMain() u8 {
+pub fn callMain() u8 {
switch (@typeInfo(@TypeOf(root.main).ReturnType)) {
.NoReturn => {
root.main();