mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
fmt
This commit is contained in:
parent
6acd2f338b
commit
5f865a4a0c
6 changed files with 32 additions and 42 deletions
|
@ -106,7 +106,8 @@ impl Pool {
|
|||
// addresses from the OS which will be lazily translated into
|
||||
// physical memory one 4096-byte page at a time, once we actually
|
||||
// try to read or write in that page's address range.
|
||||
#[cfg(unix)]{
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use libc::{MAP_ANONYMOUS, MAP_PRIVATE, PROT_READ, PROT_WRITE};
|
||||
|
||||
libc::mmap(
|
||||
|
@ -118,10 +119,11 @@ impl Pool {
|
|||
0,
|
||||
)
|
||||
}
|
||||
#[cfg(windows)]{
|
||||
use winapi::um::memoryapi::{VirtualAlloc};
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use winapi::um::memoryapi::VirtualAlloc;
|
||||
use winapi::um::winnt::PAGE_READWRITE;
|
||||
use winapi::um::winnt::{MEM_COMMIT, MEM_RESERVE};
|
||||
use winapi::um::winnt::{PAGE_READWRITE};
|
||||
|
||||
VirtualAlloc(
|
||||
std::ptr::null_mut(),
|
||||
|
@ -244,20 +246,22 @@ impl<T> std::ops::IndexMut<NodeId<T>> for Pool {
|
|||
impl Drop for Pool {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
#[cfg(unix)]{
|
||||
#[cfg(unix)]
|
||||
{
|
||||
libc::munmap(
|
||||
self.nodes as *mut c_void,
|
||||
NODE_BYTES * self.capacity as usize,
|
||||
);
|
||||
}
|
||||
#[cfg(windows)]{
|
||||
use winapi::um::memoryapi::{VirtualFree};
|
||||
use winapi::um::winnt::{MEM_RELEASE};
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use winapi::um::memoryapi::VirtualFree;
|
||||
use winapi::um::winnt::MEM_RELEASE;
|
||||
|
||||
VirtualFree(
|
||||
self.nodes as *mut c_void,
|
||||
NODE_BYTES * self.capacity as usize,
|
||||
MEM_RELEASE
|
||||
MEM_RELEASE,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,12 +42,10 @@ fn check_cmd_output(
|
|||
.unwrap()
|
||||
.to_string();
|
||||
|
||||
let out= if cmd_str.contains("cfold") {
|
||||
let out = if cmd_str.contains("cfold") {
|
||||
let child = thread::Builder::new()
|
||||
.stack_size(CFOLD_STACK_SIZE)
|
||||
.spawn(
|
||||
move|| {run_cmd(&cmd_str, &[stdin_str], &[])}
|
||||
)
|
||||
.spawn(move || run_cmd(&cmd_str, &[stdin_str], &[]))
|
||||
.unwrap();
|
||||
|
||||
child.join().unwrap()
|
||||
|
@ -55,7 +53,6 @@ fn check_cmd_output(
|
|||
run_cmd(&cmd_str, &[stdin_str], &[])
|
||||
};
|
||||
|
||||
|
||||
if !&out.stdout.ends_with(expected_ending) {
|
||||
panic!(
|
||||
"expected output to end with {:?} but instead got {:#?}",
|
||||
|
@ -103,7 +100,6 @@ fn bench_cmd<T: Measurement>(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn bench_nqueens<T: Measurement>(bench_group_opt: Option<&mut BenchmarkGroup<T>>) {
|
||||
exec_bench_w_input(
|
||||
&example_file("benchmarks", "NQueens.roc"),
|
||||
|
|
|
@ -45,7 +45,7 @@ pub fn target_triple_str(target: &Triple) -> &'static str {
|
|||
architecture: Architecture::X86_64,
|
||||
operating_system: OperatingSystem::Windows,
|
||||
..
|
||||
}=> "x86_64-pc-windows-gnu",
|
||||
} => "x86_64-pc-windows-gnu",
|
||||
_ => panic!("TODO gracefully handle unsupported target: {:?}", target),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -383,8 +383,7 @@ fn can_annotation_help(
|
|||
As(
|
||||
loc_inner,
|
||||
_spaces,
|
||||
alias_header
|
||||
@ TypeHeader {
|
||||
alias_header @ TypeHeader {
|
||||
name,
|
||||
vars: loc_vars,
|
||||
},
|
||||
|
|
|
@ -366,9 +366,7 @@ fn preprocess_impl(
|
|||
Some(section) => {
|
||||
let file_offset = match section.compressed_file_range() {
|
||||
Ok(
|
||||
range
|
||||
@
|
||||
CompressedFileRange {
|
||||
range @ CompressedFileRange {
|
||||
format: CompressionFormat::None,
|
||||
..
|
||||
},
|
||||
|
@ -493,9 +491,7 @@ fn preprocess_impl(
|
|||
for sec in text_sections {
|
||||
let (file_offset, compressed) = match sec.compressed_file_range() {
|
||||
Ok(
|
||||
range
|
||||
@
|
||||
CompressedFileRange {
|
||||
range @ CompressedFileRange {
|
||||
format: CompressionFormat::None,
|
||||
..
|
||||
},
|
||||
|
@ -625,9 +621,7 @@ fn preprocess_impl(
|
|||
};
|
||||
let dyn_offset = match dyn_sec.compressed_file_range() {
|
||||
Ok(
|
||||
range
|
||||
@
|
||||
CompressedFileRange {
|
||||
range @ CompressedFileRange {
|
||||
format: CompressionFormat::None,
|
||||
..
|
||||
},
|
||||
|
@ -713,9 +707,7 @@ fn preprocess_impl(
|
|||
};
|
||||
let symtab_offset = match symtab_sec.compressed_file_range() {
|
||||
Ok(
|
||||
range
|
||||
@
|
||||
CompressedFileRange {
|
||||
range @ CompressedFileRange {
|
||||
format: CompressionFormat::None,
|
||||
..
|
||||
},
|
||||
|
@ -737,9 +729,7 @@ fn preprocess_impl(
|
|||
};
|
||||
let dynsym_offset = match dynsym_sec.compressed_file_range() {
|
||||
Ok(
|
||||
range
|
||||
@
|
||||
CompressedFileRange {
|
||||
range @ CompressedFileRange {
|
||||
format: CompressionFormat::None,
|
||||
..
|
||||
},
|
||||
|
@ -758,9 +748,7 @@ fn preprocess_impl(
|
|||
{
|
||||
match sec.compressed_file_range() {
|
||||
Ok(
|
||||
range
|
||||
@
|
||||
CompressedFileRange {
|
||||
range @ CompressedFileRange {
|
||||
format: CompressionFormat::None,
|
||||
..
|
||||
},
|
||||
|
|
|
@ -12,7 +12,6 @@ mod roc_str;
|
|||
pub use roc_list::RocList;
|
||||
pub use roc_str::RocStr;
|
||||
|
||||
|
||||
// A list of C functions that are being imported
|
||||
#[cfg(not(windows))]
|
||||
extern "C" {
|
||||
|
@ -29,18 +28,22 @@ extern "C" {
|
|||
#[cfg(windows)]
|
||||
const ERR_MSG: &str = "should not be called from within the repo. If you got this while running a roc app, the linker should have filled this function in, but it did not happen.";
|
||||
#[cfg(windows)]
|
||||
pub fn roc_alloc(_size: usize, _alignment: u32) -> *mut c_void {panic!("roc_alloc {}", ERR_MSG)}
|
||||
pub fn roc_alloc(_size: usize, _alignment: u32) -> *mut c_void {
|
||||
panic!("roc_alloc {}", ERR_MSG)
|
||||
}
|
||||
#[cfg(windows)]
|
||||
pub fn roc_realloc(
|
||||
_ptr: *mut c_void,
|
||||
_new_size: usize,
|
||||
_old_size: usize,
|
||||
_alignment: u32,
|
||||
) -> *mut c_void {panic!("roc_realloc {}", ERR_MSG)}
|
||||
) -> *mut c_void {
|
||||
panic!("roc_realloc {}", ERR_MSG)
|
||||
}
|
||||
#[cfg(windows)]
|
||||
pub fn roc_dealloc(_ptr: *mut c_void, _alignment: u32) {panic!("roc_dealloc {}", ERR_MSG)}
|
||||
|
||||
|
||||
pub fn roc_dealloc(_ptr: *mut c_void, _alignment: u32) {
|
||||
panic!("roc_dealloc {}", ERR_MSG)
|
||||
}
|
||||
|
||||
const REFCOUNT_1: isize = isize::MIN;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue