Try to specify roc_alloc etc in example Rust hosts

...but they're all broken for other reasons, so who knows
if it actually worked?
This commit is contained in:
Richard Feldman 2021-05-22 23:24:40 -04:00
parent 175115ee4e
commit bfd8187d97
5 changed files with 125 additions and 1 deletions

View file

@ -4,6 +4,7 @@ use roc_std::alloca;
use roc_std::RocCallResult;
use roc_std::RocStr;
use std::alloc::Layout;
use std::ffi::c_void;
use std::time::SystemTime;
extern "C" {
@ -26,6 +27,30 @@ extern "C" {
#[link_name = "roc__mainForHost_1_Fx_result_size"]
fn size_Fx_result() -> i64;
fn malloc(size: usize) -> *mut c_void;
fn realloc(c_ptr: *mut c_void, size: usize) -> *mut c_void;
fn free(c_ptr: *mut c_void);
}
#[no_mangle]
pub unsafe fn roc_alloc(_alignment: usize, size: usize) -> *mut c_void {
return malloc(size);
}
#[no_mangle]
pub unsafe fn roc_realloc(
_alignment: usize,
c_ptr: *mut c_void,
_old_size: usize,
new_size: usize,
) -> *mut c_void {
return realloc(c_ptr, new_size);
}
#[no_mangle]
pub unsafe fn roc_dealloc(_alignment: usize, c_ptr: *mut c_void) {
return free(c_ptr);
}
#[no_mangle]