Merge remote-tracking branch 'remotes/origin/master' into remove-str-trailing-nulls
This commit is contained in:
commit
ee59aacac4
73 changed files with 1740 additions and 1109 deletions
|
|
@ -13,9 +13,9 @@
|
|||
use c_str::ToCStr;
|
||||
use cast::transmute;
|
||||
use libc::{c_char, c_uchar, c_void, size_t, uintptr_t, c_int};
|
||||
use option::{Some, None};
|
||||
use str;
|
||||
use sys;
|
||||
use rt::{context, OldTaskContext};
|
||||
use rt::task::Task;
|
||||
use rt::local::Local;
|
||||
use rt::borrowck;
|
||||
|
|
@ -57,16 +57,13 @@ pub fn fail_bounds_check(file: *c_char, line: size_t,
|
|||
|
||||
#[lang="malloc"]
|
||||
pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
|
||||
match context() {
|
||||
OldTaskContext => {
|
||||
return rustrt::rust_upcall_malloc_noswitch(td, size);
|
||||
// XXX: Unsafe borrow for speed. Lame.
|
||||
match Local::try_unsafe_borrow::<Task>() {
|
||||
Some(task) => {
|
||||
(*task).heap.alloc(td as *c_void, size as uint) as *c_char
|
||||
}
|
||||
_ => {
|
||||
let mut alloc = ::ptr::null();
|
||||
do Local::borrow::<Task,()> |task| {
|
||||
alloc = task.heap.alloc(td as *c_void, size as uint) as *c_char;
|
||||
}
|
||||
return alloc;
|
||||
None => {
|
||||
rustrt::rust_upcall_malloc_noswitch(td, size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ pub unsafe fn atomically<U>(f: &fn() -> U) -> U {
|
|||
use rt::task::Task;
|
||||
use task::rt;
|
||||
use rt::local::Local;
|
||||
use rt::{context, OldTaskContext, TaskContext};
|
||||
use rt::{context, OldTaskContext};
|
||||
|
||||
match context() {
|
||||
OldTaskContext => {
|
||||
|
|
@ -296,17 +296,23 @@ pub unsafe fn atomically<U>(f: &fn() -> U) -> U {
|
|||
rt::rust_task_allow_kill(t);
|
||||
}
|
||||
}
|
||||
TaskContext => {
|
||||
let t = Local::unsafe_borrow::<Task>();
|
||||
do (|| {
|
||||
(*t).death.inhibit_yield();
|
||||
f()
|
||||
}).finally {
|
||||
(*t).death.allow_yield();
|
||||
_ => {
|
||||
let t = Local::try_unsafe_borrow::<Task>();
|
||||
match t {
|
||||
Some(t) => {
|
||||
do (|| {
|
||||
(*t).death.inhibit_yield();
|
||||
f()
|
||||
}).finally {
|
||||
(*t).death.allow_yield();
|
||||
}
|
||||
}
|
||||
None => {
|
||||
// FIXME(#3095): As in unkillable().
|
||||
f()
|
||||
}
|
||||
}
|
||||
}
|
||||
// FIXME(#3095): As in unkillable().
|
||||
_ => f()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue