get minimal roc_dbg working

This commit is contained in:
Brendan Hansknecht 2023-11-29 10:42:55 -08:00
parent b7f72eff86
commit 3d6c140a30
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
6 changed files with 69 additions and 29 deletions

View file

@ -20,6 +20,13 @@ extern fn roc_realloc(c_ptr: *anyopaque, new_size: usize, old_size: usize, align
// This should never be passed a null pointer.
extern fn roc_dealloc(c_ptr: *anyopaque, alignment: u32) callconv(.C) void;
extern fn roc_dbg(file_path: *anyopaque, message: *anyopaque) callconv(.C) void;
// Since roc_dbg is never used by the builtins, we need at export a function that uses it to stop DCE.
pub fn test_dbg(file_path: *anyopaque, message: *anyopaque) callconv(.C) void {
roc_dbg(file_path, message);
}
extern fn kill(pid: c_int, sig: c_int) c_int;
extern fn shm_open(name: *const i8, oflag: c_int, mode: c_uint) c_int;
extern fn mmap(addr: ?*anyopaque, length: c_uint, prot: c_int, flags: c_int, fd: c_int, offset: c_uint) *anyopaque;
@ -40,6 +47,11 @@ fn testing_roc_mmap(addr: ?*anyopaque, length: c_uint, prot: c_int, flags: c_int
return mmap(addr, length, prot, flags, fd, offset);
}
fn testing_roc_dbg(file_path: *anyopaque, message: *anyopaque) callconv(.C) void {
_ = message;
_ = file_path;
}
comptime {
// During tests, use the testing allocators to satisfy these functions.
if (builtin.is_test) {
@ -47,6 +59,7 @@ comptime {
@export(testing_roc_realloc, .{ .name = "roc_realloc", .linkage = .Strong });
@export(testing_roc_dealloc, .{ .name = "roc_dealloc", .linkage = .Strong });
@export(testing_roc_panic, .{ .name = "roc_panic", .linkage = .Strong });
@export(testing_roc_dbg, .{ .name = "roc_dbg", .linkage = .Strong });
if (builtin.os.tag == .macos or builtin.os.tag == .linux) {
@export(testing_roc_getppid, .{ .name = "roc_getppid", .linkage = .Strong });