Get tests passing

Add roc_dbg to some platforms.
Also start updating some roc_panic impls.
This commit is contained in:
Brendan Hansknecht 2023-11-29 16:18:22 -08:00
parent e6cc43492a
commit f5fb01fd53
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
17 changed files with 191 additions and 47 deletions

View file

@ -36,6 +36,7 @@ extern "C" {
) -> *mut c_void;
pub fn roc_dealloc(ptr: *mut c_void, alignment: u32);
pub fn roc_panic(c_ptr: *mut c_void, tag_id: u32);
pub fn roc_dbg(loc: *mut c_void, msg: *mut c_void);
pub fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void;
}

View file

@ -32,18 +32,14 @@ pub unsafe extern "C" fn roc_dealloc(c_ptr: *mut c_void, _alignment: u32) {
#[cfg(test)]
#[no_mangle]
pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
use std::ffi::CStr;
use std::os::raw::c_char;
pub unsafe extern "C" fn roc_panic(msg: *mut roc_std::RocStr, _tag_id: u32) {
panic!("roc_panic during test: {}", &*msg);
}
match tag_id {
0 => {
let c_str = CStr::from_ptr(c_ptr as *const c_char);
let string = c_str.to_str().unwrap();
panic!("roc_panic during test: {string}");
}
_ => todo!(),
}
#[cfg(test)]
#[no_mangle]
pub unsafe extern "C" fn roc_dbg(loc: *mut roc_std::RocStr, msg: *mut roc_std::RocStr) {
eprintln!("[{}] {}", &*loc, &*msg);
}
#[cfg(test)]