Merge remote-tracking branch 'brson/io' into incoming

Conflicts:
	mk/rt.mk
	src/libcore/run.rs
This commit is contained in:
Brian Anderson 2013-05-02 20:51:56 -07:00
commit 6c478c7de8
42 changed files with 1399 additions and 347 deletions

View file

@ -17,6 +17,8 @@ use str;
use sys;
use unstable::exchange_alloc;
use cast::transmute;
use rt::{context, OldTaskContext};
use rt::local_services::borrow_local_services;
#[allow(non_camel_case_types)]
pub type rust_task = c_void;
@ -88,19 +90,58 @@ pub unsafe fn exchange_free(ptr: *c_char) {
#[lang="malloc"]
#[inline(always)]
#[cfg(stage0)] // For some reason this isn't working on windows in stage0
pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
return rustrt::rust_upcall_malloc_noswitch(td, size);
}
#[lang="malloc"]
#[inline(always)]
#[cfg(not(stage0))]
pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
match context() {
OldTaskContext => {
return rustrt::rust_upcall_malloc_noswitch(td, size);
}
_ => {
let mut alloc = ::ptr::null();
do borrow_local_services |srv| {
alloc = srv.heap.alloc(td as *c_void, size as uint) as *c_char;
}
return alloc;
}
}
}
// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
// inside a landing pad may corrupt the state of the exception handler. If a
// problem occurs, call exit instead.
#[lang="free"]
#[inline(always)]
#[cfg(stage0)]
pub unsafe fn local_free(ptr: *c_char) {
rustrt::rust_upcall_free_noswitch(ptr);
}
// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
// inside a landing pad may corrupt the state of the exception handler. If a
// problem occurs, call exit instead.
#[lang="free"]
#[inline(always)]
#[cfg(not(stage0))]
pub unsafe fn local_free(ptr: *c_char) {
match context() {
OldTaskContext => {
rustrt::rust_upcall_free_noswitch(ptr);
}
_ => {
do borrow_local_services |srv| {
srv.heap.free(ptr as *c_void);
}
}
}
}
#[lang="borrow_as_imm"]
#[inline(always)]
pub unsafe fn borrow_as_imm(a: *u8) {