Skip to content

Rewrite boxed_region/memory_region in Rust #10094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 28, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions mk/rt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ RUNTIME_CXXS_$(1)_$(2) := \
rt/rust_upcall.cpp \
rt/rust_uv.cpp \
rt/miniz.cpp \
rt/memory_region.cpp \
rt/boxed_region.cpp \
rt/rust_android_dummy.cpp \
rt/rust_test_helpers.cpp

Expand Down
3 changes: 1 addition & 2 deletions src/libstd/at_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ pub mod raw {
use at_vec::capacity;
use cast;
use cast::{transmute, transmute_copy};
use libc;
use ptr;
use mem;
use uint;
Expand Down Expand Up @@ -250,7 +249,7 @@ pub mod raw {
use rt::task::Task;

do Local::borrow |task: &mut Task| {
task.heap.realloc(ptr as *libc::c_void, size) as *()
task.heap.realloc(ptr as *mut Box<()>, size) as *()
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#[doc(hidden)];

use libc::c_void;
use ptr::null;
use ptr;
use unstable::intrinsics::TyDesc;
use unstable::raw;

Expand All @@ -37,7 +37,7 @@ unsafe fn each_live_alloc(read_next_before: bool,
use rt::local_heap;

let mut box = local_heap::live_allocs();
while box != null() {
while box != ptr::mut_null() {
let next_before = (*box).next;
let uniq = (*box).ref_count == managed::RC_MANAGED_UNIQUE;

Expand Down
9 changes: 9 additions & 0 deletions src/libstd/rt/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use os;

static mut MIN_STACK: uint = 4000000;
static mut DEBUG_BORROW: bool = false;
static mut POISON_ON_FREE: bool = false;

pub fn init() {
unsafe {
Expand All @@ -33,6 +34,10 @@ pub fn init() {
Some(_) => DEBUG_BORROW = true,
None => ()
}
match os::getenv("RUST_POISON_ON_FREE") {
Some(_) => POISON_ON_FREE = true,
None => ()
}
}
}

Expand All @@ -43,3 +48,7 @@ pub fn min_stack() -> uint {
pub fn debug_borrow() -> bool {
unsafe { DEBUG_BORROW }
}

pub fn poison_on_free() -> bool {
unsafe { POISON_ON_FREE }
}
2 changes: 1 addition & 1 deletion src/libstd/rt/global_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extern {
}

#[inline]
fn get_box_size(body_size: uint, body_align: uint) -> uint {
pub fn get_box_size(body_size: uint, body_align: uint) -> uint {
let header_size = size_of::<raw::Box<()>>();
// FIXME (#2699): This alignment calculation is suspicious. Is it right?
let total_size = align_to(header_size, body_align) + body_size;
Expand Down
Loading