mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
Add dummy roc_alloc in roc_docs_cli for Windows
This commit is contained in:
parent
7caca140b0
commit
6bae249a71
3 changed files with 41 additions and 0 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -3592,6 +3592,7 @@ name = "roc_docs_cli"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap 3.2.11",
|
"clap 3.2.11",
|
||||||
|
"libc",
|
||||||
"roc_docs",
|
"roc_docs",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -19,3 +19,6 @@ bench = false
|
||||||
[dependencies]
|
[dependencies]
|
||||||
roc_docs = { path = "../docs" }
|
roc_docs = { path = "../docs" }
|
||||||
clap = { version = "3.1.15", default-features = false, features = ["std", "color", "suggestions", "derive"] }
|
clap = { version = "3.1.15", default-features = false, features = ["std", "color", "suggestions", "derive"] }
|
||||||
|
|
||||||
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
libc = "0.2.106"
|
||||||
|
|
|
@ -48,3 +48,40 @@ fn roc_files_recursive<P: AsRef<Path>>(
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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(windows)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use windows_roc_platform_functions::*;
|
||||||
|
|
||||||
|
#[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