mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +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
|
// addresses from the OS which will be lazily translated into
|
||||||
// physical memory one 4096-byte page at a time, once we actually
|
// physical memory one 4096-byte page at a time, once we actually
|
||||||
// try to read or write in that page's address range.
|
// 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};
|
use libc::{MAP_ANONYMOUS, MAP_PRIVATE, PROT_READ, PROT_WRITE};
|
||||||
|
|
||||||
libc::mmap(
|
libc::mmap(
|
||||||
|
@ -118,10 +119,11 @@ impl Pool {
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
#[cfg(windows)]{
|
#[cfg(windows)]
|
||||||
use winapi::um::memoryapi::{VirtualAlloc};
|
{
|
||||||
|
use winapi::um::memoryapi::VirtualAlloc;
|
||||||
|
use winapi::um::winnt::PAGE_READWRITE;
|
||||||
use winapi::um::winnt::{MEM_COMMIT, MEM_RESERVE};
|
use winapi::um::winnt::{MEM_COMMIT, MEM_RESERVE};
|
||||||
use winapi::um::winnt::{PAGE_READWRITE};
|
|
||||||
|
|
||||||
VirtualAlloc(
|
VirtualAlloc(
|
||||||
std::ptr::null_mut(),
|
std::ptr::null_mut(),
|
||||||
|
@ -244,20 +246,22 @@ impl<T> std::ops::IndexMut<NodeId<T>> for Pool {
|
||||||
impl Drop for Pool {
|
impl Drop for Pool {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
#[cfg(unix)]{
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
libc::munmap(
|
libc::munmap(
|
||||||
self.nodes as *mut c_void,
|
self.nodes as *mut c_void,
|
||||||
NODE_BYTES * self.capacity as usize,
|
NODE_BYTES * self.capacity as usize,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
#[cfg(windows)]{
|
#[cfg(windows)]
|
||||||
use winapi::um::memoryapi::{VirtualFree};
|
{
|
||||||
use winapi::um::winnt::{MEM_RELEASE};
|
use winapi::um::memoryapi::VirtualFree;
|
||||||
|
use winapi::um::winnt::MEM_RELEASE;
|
||||||
|
|
||||||
VirtualFree(
|
VirtualFree(
|
||||||
self.nodes as *mut c_void,
|
self.nodes as *mut c_void,
|
||||||
NODE_BYTES * self.capacity as usize,
|
NODE_BYTES * self.capacity as usize,
|
||||||
MEM_RELEASE
|
MEM_RELEASE,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,7 @@ fn check_cmd_output(
|
||||||
let out = if cmd_str.contains("cfold") {
|
let out = if cmd_str.contains("cfold") {
|
||||||
let child = thread::Builder::new()
|
let child = thread::Builder::new()
|
||||||
.stack_size(CFOLD_STACK_SIZE)
|
.stack_size(CFOLD_STACK_SIZE)
|
||||||
.spawn(
|
.spawn(move || run_cmd(&cmd_str, &[stdin_str], &[]))
|
||||||
move|| {run_cmd(&cmd_str, &[stdin_str], &[])}
|
|
||||||
)
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
child.join().unwrap()
|
child.join().unwrap()
|
||||||
|
@ -55,7 +53,6 @@ fn check_cmd_output(
|
||||||
run_cmd(&cmd_str, &[stdin_str], &[])
|
run_cmd(&cmd_str, &[stdin_str], &[])
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if !&out.stdout.ends_with(expected_ending) {
|
if !&out.stdout.ends_with(expected_ending) {
|
||||||
panic!(
|
panic!(
|
||||||
"expected output to end with {:?} but instead got {:#?}",
|
"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>>) {
|
pub fn bench_nqueens<T: Measurement>(bench_group_opt: Option<&mut BenchmarkGroup<T>>) {
|
||||||
exec_bench_w_input(
|
exec_bench_w_input(
|
||||||
&example_file("benchmarks", "NQueens.roc"),
|
&example_file("benchmarks", "NQueens.roc"),
|
||||||
|
|
|
@ -383,8 +383,7 @@ fn can_annotation_help(
|
||||||
As(
|
As(
|
||||||
loc_inner,
|
loc_inner,
|
||||||
_spaces,
|
_spaces,
|
||||||
alias_header
|
alias_header @ TypeHeader {
|
||||||
@ TypeHeader {
|
|
||||||
name,
|
name,
|
||||||
vars: loc_vars,
|
vars: loc_vars,
|
||||||
},
|
},
|
||||||
|
|
|
@ -366,9 +366,7 @@ fn preprocess_impl(
|
||||||
Some(section) => {
|
Some(section) => {
|
||||||
let file_offset = match section.compressed_file_range() {
|
let file_offset = match section.compressed_file_range() {
|
||||||
Ok(
|
Ok(
|
||||||
range
|
range @ CompressedFileRange {
|
||||||
@
|
|
||||||
CompressedFileRange {
|
|
||||||
format: CompressionFormat::None,
|
format: CompressionFormat::None,
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
|
@ -493,9 +491,7 @@ fn preprocess_impl(
|
||||||
for sec in text_sections {
|
for sec in text_sections {
|
||||||
let (file_offset, compressed) = match sec.compressed_file_range() {
|
let (file_offset, compressed) = match sec.compressed_file_range() {
|
||||||
Ok(
|
Ok(
|
||||||
range
|
range @ CompressedFileRange {
|
||||||
@
|
|
||||||
CompressedFileRange {
|
|
||||||
format: CompressionFormat::None,
|
format: CompressionFormat::None,
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
|
@ -625,9 +621,7 @@ fn preprocess_impl(
|
||||||
};
|
};
|
||||||
let dyn_offset = match dyn_sec.compressed_file_range() {
|
let dyn_offset = match dyn_sec.compressed_file_range() {
|
||||||
Ok(
|
Ok(
|
||||||
range
|
range @ CompressedFileRange {
|
||||||
@
|
|
||||||
CompressedFileRange {
|
|
||||||
format: CompressionFormat::None,
|
format: CompressionFormat::None,
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
|
@ -713,9 +707,7 @@ fn preprocess_impl(
|
||||||
};
|
};
|
||||||
let symtab_offset = match symtab_sec.compressed_file_range() {
|
let symtab_offset = match symtab_sec.compressed_file_range() {
|
||||||
Ok(
|
Ok(
|
||||||
range
|
range @ CompressedFileRange {
|
||||||
@
|
|
||||||
CompressedFileRange {
|
|
||||||
format: CompressionFormat::None,
|
format: CompressionFormat::None,
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
|
@ -737,9 +729,7 @@ fn preprocess_impl(
|
||||||
};
|
};
|
||||||
let dynsym_offset = match dynsym_sec.compressed_file_range() {
|
let dynsym_offset = match dynsym_sec.compressed_file_range() {
|
||||||
Ok(
|
Ok(
|
||||||
range
|
range @ CompressedFileRange {
|
||||||
@
|
|
||||||
CompressedFileRange {
|
|
||||||
format: CompressionFormat::None,
|
format: CompressionFormat::None,
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
|
@ -758,9 +748,7 @@ fn preprocess_impl(
|
||||||
{
|
{
|
||||||
match sec.compressed_file_range() {
|
match sec.compressed_file_range() {
|
||||||
Ok(
|
Ok(
|
||||||
range
|
range @ CompressedFileRange {
|
||||||
@
|
|
||||||
CompressedFileRange {
|
|
||||||
format: CompressionFormat::None,
|
format: CompressionFormat::None,
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,7 +12,6 @@ mod roc_str;
|
||||||
pub use roc_list::RocList;
|
pub use roc_list::RocList;
|
||||||
pub use roc_str::RocStr;
|
pub use roc_str::RocStr;
|
||||||
|
|
||||||
|
|
||||||
// A list of C functions that are being imported
|
// A list of C functions that are being imported
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -29,18 +28,22 @@ extern "C" {
|
||||||
#[cfg(windows)]
|
#[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.";
|
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)]
|
#[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)]
|
#[cfg(windows)]
|
||||||
pub fn roc_realloc(
|
pub fn roc_realloc(
|
||||||
_ptr: *mut c_void,
|
_ptr: *mut c_void,
|
||||||
_new_size: usize,
|
_new_size: usize,
|
||||||
_old_size: usize,
|
_old_size: usize,
|
||||||
_alignment: u32,
|
_alignment: u32,
|
||||||
) -> *mut c_void {panic!("roc_realloc {}", ERR_MSG)}
|
) -> *mut c_void {
|
||||||
|
panic!("roc_realloc {}", ERR_MSG)
|
||||||
|
}
|
||||||
#[cfg(windows)]
|
#[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;
|
const REFCOUNT_1: isize = isize::MIN;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue