diff options
| author | Aaron Turon <aturon@mozilla.com> | 2014-12-06 18:34:37 -0800 |
|---|---|---|
| committer | Aaron Turon <aturon@mozilla.com> | 2014-12-18 23:31:51 -0800 |
| commit | 43ae4b3301cc0605839778ecf59effb32b752e33 (patch) | |
| tree | aa111f5adc1eaa1e996847e1437d1b1b40821ce0 /src/libstd/sys | |
| parent | 14c1a103bc3f78721df1dc860a75a477c8275e3a (diff) | |
| download | rust-43ae4b3301cc0605839778ecf59effb32b752e33.tar.gz rust-43ae4b3301cc0605839778ecf59effb32b752e33.zip | |
Fallout from new thread API
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/common/backtrace.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/common/helper_thread.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sys/common/mod.rs | 1 | ||||
| -rw-r--r-- | src/libstd/sys/common/thread_info.rs | 15 | ||||
| -rw-r--r-- | src/libstd/sys/common/thread_local.rs | 1 | ||||
| -rw-r--r-- | src/libstd/sys/unix/backtrace.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/unix/stack_overflow.rs | 32 | ||||
| -rw-r--r-- | src/libstd/sys/windows/stack_overflow.rs | 7 |
8 files changed, 25 insertions, 41 deletions
diff --git a/src/libstd/sys/common/backtrace.rs b/src/libstd/sys/common/backtrace.rs index 0c03060b314..38dc516bf3d 100644 --- a/src/libstd/sys/common/backtrace.rs +++ b/src/libstd/sys/common/backtrace.rs @@ -9,7 +9,7 @@ // except according to those terms. use io::{IoResult, Writer}; -use iter::Iterator; +use iter::{Iterator, IteratorExt}; use option::{Some, None}; use result::{Ok, Err}; use str::{StrPrelude, from_str}; diff --git a/src/libstd/sys/common/helper_thread.rs b/src/libstd/sys/common/helper_thread.rs index ef0181b72b0..8aa09d9bd30 100644 --- a/src/libstd/sys/common/helper_thread.rs +++ b/src/libstd/sys/common/helper_thread.rs @@ -28,7 +28,7 @@ use sync::{StaticMutex, StaticCondvar}; use rt; use sys::helper_signal; -use task; +use thread::Thread; /// A structure for management of a helper thread. /// @@ -82,7 +82,11 @@ impl<M: Send> Helper<M> { *self.signal.get() = send as uint; let t = f(); +<<<<<<< HEAD task::spawn(move |:| { +======= + Thread::spawn(proc() { +>>>>>>> Fallout from new thread API helper(receive, rx, t); let _g = self.lock.lock(); *self.shutdown.get() = true; diff --git a/src/libstd/sys/common/mod.rs b/src/libstd/sys/common/mod.rs index aeee4cf01cd..dc0ad08cdbe 100644 --- a/src/libstd/sys/common/mod.rs +++ b/src/libstd/sys/common/mod.rs @@ -27,6 +27,7 @@ pub mod net; pub mod rwlock; pub mod stack; pub mod thread; +pub mod thread_info; pub mod thread_local; // common error constructors diff --git a/src/libstd/sys/common/thread_info.rs b/src/libstd/sys/common/thread_info.rs index f88fd49ab99..0612448cfa0 100644 --- a/src/libstd/sys/common/thread_info.rs +++ b/src/libstd/sys/common/thread_info.rs @@ -33,11 +33,11 @@ impl ThreadInfo { *c.borrow_mut() = Some(ThreadInfo { stack_bounds: (0, 0), stack_guard: 0, - unwinder: false, - thread: Thread::new(None), + unwinding: false, + thread: NewThread::new(None), }) } - f(c.borrow_mut().as_ref().unwrap()) + f(c.borrow_mut().as_mut().unwrap()) }) } } @@ -47,28 +47,25 @@ pub fn current_thread() -> Thread { } pub fn panicking() -> bool { - ThreadInfo::with(|info| info.unwinder.unwinding()) + ThreadInfo::with(|info| info.unwinding) } pub fn stack_guard() -> uint { ThreadInfo::with(|info| info.stack_guard) } -pub fn unwinding() -> bool { - ThreadInfo::with(|info| info.unwinder.unwinding) -} - pub fn set_unwinding(unwinding: bool) { ThreadInfo::with(|info| info.unwinding = unwinding) } pub fn set(stack_bounds: (uint, uint), stack_guard: uint, thread: Thread) { THREAD_INFO.with(|c| assert!(c.borrow().is_none())); + let mut thread_opt = Some(thread); // option dance THREAD_INFO.with(|c| *c.borrow_mut() = Some(ThreadInfo{ stack_bounds: stack_bounds, stack_guard: stack_guard, unwinding: false, - thread: thread, + thread: thread_opt.take().unwrap(), })); } diff --git a/src/libstd/sys/common/thread_local.rs b/src/libstd/sys/common/thread_local.rs index c3bf5cfc301..fe7a7d8d037 100644 --- a/src/libstd/sys/common/thread_local.rs +++ b/src/libstd/sys/common/thread_local.rs @@ -58,7 +58,6 @@ use prelude::*; -use rt; use sync::atomic::{mod, AtomicUint}; use sync::{Mutex, Once, ONCE_INIT}; diff --git a/src/libstd/sys/unix/backtrace.rs b/src/libstd/sys/unix/backtrace.rs index 2b36ece0e4b..5256e2cc809 100644 --- a/src/libstd/sys/unix/backtrace.rs +++ b/src/libstd/sys/unix/backtrace.rs @@ -141,7 +141,7 @@ pub fn write(w: &mut Writer) -> IoResult<()> { struct Context<'a> { idx: int, - writer: &'a mut Writer+'a, + writer: &'a mut (Writer+'a), last_error: Option<IoError>, } diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs index 73b98f762b4..340f9514241 100644 --- a/src/libstd/sys/unix/stack_overflow.rs +++ b/src/libstd/sys/unix/stack_overflow.rs @@ -45,8 +45,6 @@ mod imp { use self::signal::{siginfo, sigaction, SIGBUS, SIG_DFL, SA_SIGINFO, SA_ONSTACK, sigaltstack, SIGSTKSZ}; - use rt::local::Local; - use rt::task::Task; use libc; use libc::funcs::posix88::mman::{mmap, munmap}; use libc::consts::os::posix88::{SIGSEGV, @@ -56,20 +54,12 @@ mod imp { MAP_ANON, MAP_FAILED}; + use sys_common::thread_info; + // This is initialized in init() and only read from after static mut PAGE_SIZE: uint = 0; - // get_task_info is called from an exception / signal handler. - // It returns the guard page of the current task or 0 if that - // guard page doesn't exist. None is returned if there's currently - // no local task. - unsafe fn get_task_guard_page() -> Option<uint> { - let task: Option<*mut Task> = Local::try_unsafe_borrow(); - task.map(|task| (&*task).stack_guard().unwrap_or(0)) - } - - #[no_stack_check] unsafe extern fn signal_handler(signum: libc::c_int, info: *mut siginfo, @@ -89,20 +79,16 @@ mod imp { // We're calling into functions with stack checks stack::record_sp_limit(0); - match get_task_guard_page() { - Some(guard) => { - let addr = (*info).si_addr as uint; + let guard = thread_info::stack_guard(); + let addr = (*info).si_addr as uint; - if guard == 0 || addr < guard - PAGE_SIZE || addr >= guard { - term(signum); - } + if guard == 0 || addr < guard - PAGE_SIZE || addr >= guard { + term(signum); + } - report_overflow(); + report_overflow(); - intrinsics::abort() - } - None => term(signum) - } + intrinsics::abort() } static mut MAIN_ALTSTACK: *mut libc::c_void = 0 as *mut libc::c_void; diff --git a/src/libstd/sys/windows/stack_overflow.rs b/src/libstd/sys/windows/stack_overflow.rs index e3d96a054f4..63b5b6f5863 100644 --- a/src/libstd/sys/windows/stack_overflow.rs +++ b/src/libstd/sys/windows/stack_overflow.rs @@ -8,15 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rt::local::Local; -use rt::task::Task; use rt::util::report_overflow; use core::prelude::*; use ptr; use mem; use libc; use libc::types::os::arch::extra::{LPVOID, DWORD, LONG, BOOL}; -use sys_common::stack; +use sys_common::{stack, thread_info}; pub struct Handler { _data: *mut libc::c_void @@ -37,8 +35,7 @@ impl Drop for Handler { // guard page doesn't exist. None is returned if there's currently // no local task. unsafe fn get_task_guard_page() -> Option<uint> { - let task: Option<*mut Task> = Local::try_unsafe_borrow(); - task.map(|task| (&*task).stack_guard().unwrap_or(0)) + thread_info::stack_guard() } // This is initialized in init() and only read from after |
