mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
add libc functions to the linker crate, so we can run tests on windows
This commit is contained in:
parent
a3ee6b22af
commit
249901c73c
3 changed files with 41 additions and 0 deletions
|
@ -399,3 +399,42 @@ macro_rules! dbg_hex {
|
|||
($($crate::dbg_hex!($val)),+,)
|
||||
};
|
||||
}
|
||||
|
||||
// These functions don't end up in the final Roc binary but Windows linker needs a definition inside the crate.
|
||||
// On Windows, there seems to be less dead-code-elimination than on Linux or MacOS, or maybe it's done later.
|
||||
#[cfg(test)]
|
||||
#[cfg(windows)]
|
||||
#[allow(unused_imports)]
|
||||
use windows_roc_platform_functions::*;
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(windows)]
|
||||
mod windows_roc_platform_functions {
|
||||
use core::ffi::c_void;
|
||||
|
||||
/// # Safety
|
||||
/// The Roc application needs this.
|
||||
#[no_mangle]
|
||||
pub unsafe fn roc_alloc(size: usize, _alignment: u32) -> *mut c_void {
|
||||
libc::malloc(size)
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
/// The Roc application needs this.
|
||||
#[no_mangle]
|
||||
pub unsafe fn roc_realloc(
|
||||
c_ptr: *mut c_void,
|
||||
new_size: usize,
|
||||
_old_size: usize,
|
||||
_alignment: u32,
|
||||
) -> *mut c_void {
|
||||
libc::realloc(c_ptr, new_size)
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
/// The Roc application needs this.
|
||||
#[no_mangle]
|
||||
pub unsafe fn roc_dealloc(c_ptr: *mut c_void, _alignment: u32) {
|
||||
libc::free(c_ptr)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue