Revert "Add __cxa_throw to utils"

This reverts commit 23f4802b8773043bd0bb32cdf2f235d023a38050.
This commit is contained in:
Richard Feldman 2021-05-22 23:06:28 -04:00
parent b02ae3794f
commit 2a68c0c2cd

View File

@ -1,10 +1,6 @@
const std = @import("std");
const always_inline = std.builtin.CallOptions.Modifier.always_inline;
// Throwing an exception, from libc++
// https://github.com/llvm-mirror/libcxxabi/blob/ce3db128f9e4d6d19d1cdbe39bb45fcc64a5adb0/src/cxa_exception.cpp#L230
extern fn __cxa_throw(thrown_exception: *c_void, type_info: *c_void, dest: *c_void) callconv(.C) void;
// If allocation fails, this must cxa_throw - it must not return a null pointer!
extern fn roc_alloc(alignment: usize, size: usize) callconv(.C) *c_void;
@ -17,17 +13,12 @@ extern fn roc_dealloc(alignment: usize, c_ptr: *c_void) callconv(.C) void;
comptime {
if (std.builtin.is_test) {
@export(testing_cxa_throw, .{ .name = "__cxa_throw", .linkage = .Strong });
@export(testing_roc_alloc, .{ .name = "roc_alloc", .linkage = .Strong });
@export(testing_roc_realloc, .{ .name = "roc_realloc", .linkage = .Strong });
@export(testing_roc_dealloc, .{ .name = "roc_dealloc", .linkage = .Strong });
}
}
fn testing_cxa_throw(thrown_exception: *c_void, type_info: *c_void, dest: *c_void) callconv(.C) void {
std.debug.panic("An exception was thrown during this test!");
}
fn testing_roc_alloc(alignment: usize, size: usize) callconv(.C) *c_void {
return @ptrCast(*c_void, std.testing.allocator.alloc(u8, size) catch unreachable);
}