change raw_vec to raw_block to avoid clashes with liballoc package

This commit is contained in:
Mark Thom
2020-02-13 20:05:46 -07:00
parent 1c4e2c0ed6
commit 5f51e264f2
3 changed files with 18 additions and 18 deletions

View File

@@ -19,7 +19,7 @@ pub mod machine_errors;
pub mod machine_indices; pub mod machine_indices;
pub(super) mod machine_state; pub(super) mod machine_state;
pub mod modules; pub mod modules;
mod raw_vec; mod raw_block;
mod stack; mod stack;
pub(super) mod term_expansion; pub(super) mod term_expansion;
pub mod toplevel; pub mod toplevel;

View File

@@ -4,32 +4,32 @@ use std::alloc;
use std::mem; use std::mem;
use std::ptr; use std::ptr;
pub(crate) trait RawVecTraits { pub(crate) trait RawBlockTraits {
fn init_size() -> usize; fn init_size() -> usize;
fn align() -> usize; fn align() -> usize;
fn base_offset(base: *const u8) -> *const u8; fn base_offset(base: *const u8) -> *const u8;
} }
pub(crate) struct RawVec<T: RawVecTraits> { pub(crate) struct RawBlock<T: RawBlockTraits> {
pub(crate) size: usize, pub(crate) size: usize,
pub(crate) base: *const u8, pub(crate) base: *const u8,
pub(crate) top: *const u8, pub(crate) top: *const u8,
_marker: PhantomData<T>, _marker: PhantomData<T>,
} }
impl<T: RawVecTraits> RawVec<T> { impl<T: RawBlockTraits> RawBlock<T> {
pub(crate) pub(crate)
fn new() -> Self { fn new() -> Self {
let mut vec = RawVec { size: 0, let mut block = RawBlock { size: 0,
base: ptr::null(), base: ptr::null(),
top: ptr::null(), top: ptr::null(),
_marker: PhantomData }; _marker: PhantomData };
unsafe { unsafe {
vec.grow(); block.grow();
} }
vec block
} }
pub(crate) pub(crate)
@@ -51,8 +51,8 @@ impl<T: RawVecTraits> RawVec<T> {
} }
} }
fn empty_vec() -> Self { fn empty_block() -> Self {
RawVec { size: 0, RawBlock { size: 0,
base: ptr::null(), base: ptr::null(),
top: ptr::null(), top: ptr::null(),
_marker: PhantomData } _marker: PhantomData }
@@ -61,7 +61,7 @@ impl<T: RawVecTraits> RawVec<T> {
#[inline] #[inline]
pub(crate) pub(crate)
fn take(&mut self) -> Self { fn take(&mut self) -> Self {
mem::replace(self, Self::empty_vec()) mem::replace(self, Self::empty_block())
} }

View File

@@ -1,5 +1,5 @@
use crate::prolog::machine::machine_indices::*; use crate::prolog::machine::machine_indices::*;
use crate::prolog::machine::raw_vec::*; use crate::prolog::machine::raw_block::*;
use core::marker::PhantomData; use core::marker::PhantomData;
@@ -9,7 +9,7 @@ use std::ptr;
struct StackTraits {} struct StackTraits {}
impl RawVecTraits for StackTraits { impl RawBlockTraits for StackTraits {
#[inline] #[inline]
fn init_size() -> usize { fn init_size() -> usize {
10 * 1024 * 1024 10 * 1024 * 1024
@@ -36,7 +36,7 @@ const fn prelude_size<Prelude>() -> usize {
} }
pub struct Stack { pub struct Stack {
buf: RawVec<StackTraits>, buf: RawBlock<StackTraits>,
_marker: PhantomData<Addr>, _marker: PhantomData<Addr>,
} }
@@ -194,7 +194,7 @@ impl OrFrame {
impl Stack { impl Stack {
pub fn new() -> Self { pub fn new() -> Self {
Stack { buf: RawVec::new(), _marker: PhantomData } Stack { buf: RawBlock::new(), _marker: PhantomData }
} }
pub fn allocate_and_frame(&mut self, num_cells: usize) -> usize { pub fn allocate_and_frame(&mut self, num_cells: usize) -> usize {
@@ -215,7 +215,7 @@ impl Stack {
let e = self.buf.top as usize - self.buf.base as usize; let e = self.buf.top as usize - self.buf.base as usize;
self.buf.top = new_top; self.buf.top = new_top;
e e
} }
} }