Skip to content

Commit

Permalink
Change the platform for roc-lang/roc#6116
Browse files Browse the repository at this point in the history
  • Loading branch information
ostcar committed Nov 30, 2023
1 parent b5981ce commit 162e2f1
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions platform/host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@ export fn roc_dealloc(ptr: [*]u8, alignment: u32) callconv(.C) void {
_ = alignment;
}

export fn roc_panic(msg: *RocStr, tag_id: u32) callconv(.C) void {
const stderr = std.io.getStdErr().writer();
switch (tag_id) {
0 => {
stderr.print("Roc standard library crashed with message\n\n {s}\n\nShutting down\n", .{msg.asSlice()}) catch unreachable;
},
1 => {
stderr.print("Application crashed with message\n\n {s}\n\nShutting down\n", .{msg.asSlice()}) catch unreachable;
},
else => unreachable,
}
std.process.exit(1);
}

export fn roc_dbg(loc: *RocStr, msg: *RocStr) callconv(.C) void {
const stderr = std.io.getStdErr().writer();
stderr.print("[{s}] {s}\n", .{ loc.asSlice(), msg.asSlice() }) catch unreachable;
}

export fn roc_memset(dst: [*]u8, value: u8, size: usize) callconv(.C) void {
return @memset(dst[0..size], value);
}
Expand Down Expand Up @@ -83,12 +102,3 @@ comptime {
@export(roc_getppid_windows_stub, .{ .name = "roc_getppid", .linkage = .Strong });
}
}

export fn roc_panic(c_ptr: *anyopaque, tag_id: u32) callconv(.C) void {
_ = tag_id;

const stderr = std.io.getStdErr().writer();
const msg = @as([*:0]const u8, @ptrCast(c_ptr));
stderr.print("Application crashed with message\n\n {s}\n\nShutting down\n", .{msg}) catch unreachable;
std.process.exit(1);
}

0 comments on commit 162e2f1

Please sign in to comment.