aboutsummaryrefslogtreecommitdiff
path: root/std/special/bootstrap.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-06-03 15:09:40 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-06-03 15:09:40 -0400
commite5b90651ba118cb0d3293c83bdfbc62c40f4c266 (patch)
tree35b7af7aeef87a6bbd8f621c0c4f763156945555 /std/special/bootstrap.zig
parente64f0971fc788cefb348e9516cd3b284df7ea0df (diff)
downloadzig-e5b90651ba118cb0d3293c83bdfbc62c40f4c266.tar.gz
zig-e5b90651ba118cb0d3293c83bdfbc62c40f4c266.zip
compileError builtin includes "referenced by" notes
to help track down the cause closes #278
Diffstat (limited to 'std/special/bootstrap.zig')
-rw-r--r--std/special/bootstrap.zig15
1 files changed, 12 insertions, 3 deletions
diff --git a/std/special/bootstrap.zig b/std/special/bootstrap.zig
index 3afae1096b..3d15fe9c59 100644
--- a/std/special/bootstrap.zig
+++ b/std/special/bootstrap.zig
@@ -8,7 +8,8 @@ const builtin = @import("builtin");
const want_main_symbol = std.target.linking_libc;
const want_start_symbol = !want_main_symbol;
-const exit = std.os.posix.exit;
+const posix_exit = std.os.posix.exit;
+extern fn ExitProcess(exit_code: c_uint) -> noreturn;
var argc_ptr: &usize = undefined;
@@ -34,8 +35,16 @@ fn callMainAndExit() -> noreturn {
const argc = *argc_ptr;
const argv = @ptrCast(&&u8, &argc_ptr[1]);
const envp = @ptrCast(&?&u8, &argv[argc + 1]);
- callMain(argc, argv, envp) %% exit(1);
- exit(0);
+ callMain(argc, argv, envp) %% exit(true);
+ exit(false);
+}
+
+fn exit(failure: bool) -> noreturn {
+ if (builtin.os == builtin.Os.windows) {
+ ExitProcess(c_uint(failure));
+ } else {
+ posix_exit(i32(failure));
+ }
}
fn callMain(argc: usize, argv: &&u8, envp: &?&u8) -> %void {