mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
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:
parent
175115ee4e
commit
bfd8187d97
5 changed files with 125 additions and 1 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue