diff options
| author | bors <bors@rust-lang.org> | 2013-08-09 18:41:13 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-09 18:41:13 -0700 |
| commit | e81e81f234731a31fad9afdc2045bef3fbdf1109 (patch) | |
| tree | f15c93f7989462a768b7c333e6dec0445c62472d /src/libstd/rt | |
| parent | 6f6dce7bbcfb104a8a1e23b0b93d83cbb770f338 (diff) | |
| parent | b75915d0ca20c6d066a7368ad53491a55a5a57d2 (diff) | |
| download | rust-e81e81f234731a31fad9afdc2045bef3fbdf1109.tar.gz rust-e81e81f234731a31fad9afdc2045bef3fbdf1109.zip | |
auto merge of #8387 : brson/rust/nooldrt, r=brson
Diffstat (limited to 'src/libstd/rt')
| -rw-r--r-- | src/libstd/rt/borrowck.rs | 50 | ||||
| -rw-r--r-- | src/libstd/rt/env.rs | 41 | ||||
| -rw-r--r-- | src/libstd/rt/io/comm_adapters.rs | 3 | ||||
| -rw-r--r-- | src/libstd/rt/local_heap.rs | 31 | ||||
| -rw-r--r-- | src/libstd/rt/mod.rs | 33 | ||||
| -rw-r--r-- | src/libstd/rt/task.rs | 4 | ||||
| -rw-r--r-- | src/libstd/rt/uv/uvll.rs | 9 |
7 files changed, 17 insertions, 154 deletions
diff --git a/src/libstd/rt/borrowck.rs b/src/libstd/rt/borrowck.rs index dcfcc3a9fc6..afbb0fcb567 100644 --- a/src/libstd/rt/borrowck.rs +++ b/src/libstd/rt/borrowck.rs @@ -9,7 +9,7 @@ // except according to those terms. use cast::transmute; -use libc::{c_char, c_void, size_t, STDERR_FILENO}; +use libc::{c_char, size_t, STDERR_FILENO}; use io; use io::{Writer, WriterUtil}; use option::{Option, None, Some}; @@ -20,9 +20,6 @@ use sys; use unstable::raw; use vec::ImmutableVector; -#[allow(non_camel_case_types)] -type rust_task = c_void; - pub static FROZEN_BIT: uint = 1 << (uint::bits - 1); pub static MUT_BIT: uint = 1 << (uint::bits - 2); static ALL_BITS: uint = FROZEN_BIT | MUT_BIT; @@ -35,34 +32,12 @@ struct BorrowRecord { } fn try_take_task_borrow_list() -> Option<~[BorrowRecord]> { - unsafe { - let cur_task: *rust_task = rust_try_get_task(); - if cur_task.is_not_null() { - let ptr = rust_take_task_borrow_list(cur_task); - if ptr.is_null() { - None - } else { - let v: ~[BorrowRecord] = transmute(ptr); - Some(v) - } - } else { - None - } - } + // XXX + None } -fn swap_task_borrow_list(f: &fn(~[BorrowRecord]) -> ~[BorrowRecord]) { - unsafe { - let cur_task: *rust_task = rust_try_get_task(); - if cur_task.is_not_null() { - let mut borrow_list: ~[BorrowRecord] = { - let ptr = rust_take_task_borrow_list(cur_task); - if ptr.is_null() { ~[] } else { transmute(ptr) } - }; - borrow_list = f(borrow_list); - rust_set_task_borrow_list(cur_task, transmute(borrow_list)); - } - } +fn swap_task_borrow_list(_f: &fn(~[BorrowRecord]) -> ~[BorrowRecord]) { + // XXX } pub unsafe fn clear_task_borrow_list() { @@ -113,7 +88,8 @@ unsafe fn debug_borrow<T>(tag: &'static str, //! A useful debugging function that prints a pointer + tag + newline //! without allocating memory. - if ENABLE_DEBUG && ::rt::env::get().debug_borrow { + // XXX + if false { debug_borrow_slow(tag, p, old_bits, new_bits, filename, line); } @@ -269,15 +245,3 @@ pub unsafe fn check_not_borrowed(a: *u8, fail_borrowed(a, file, line); } } - - -extern { - #[rust_stack] - pub fn rust_take_task_borrow_list(task: *rust_task) -> *c_void; - - #[rust_stack] - pub fn rust_set_task_borrow_list(task: *rust_task, map: *c_void); - - #[rust_stack] - pub fn rust_try_get_task() -> *rust_task; -} diff --git a/src/libstd/rt/env.rs b/src/libstd/rt/env.rs index 6e671742fb6..3ca39acbfcd 100644 --- a/src/libstd/rt/env.rs +++ b/src/libstd/rt/env.rs @@ -11,50 +11,9 @@ //! Runtime environment settings use from_str::FromStr; -use libc::{size_t, c_char, c_int}; use option::{Some, None}; use os; -// OLD RT stuff - -pub struct Environment { - /// The number of threads to use by default - num_sched_threads: size_t, - /// The minimum size of a stack segment - min_stack_size: size_t, - /// The maximum amount of total stack per task before aborting - max_stack_size: size_t, - /// The default logging configuration - logspec: *c_char, - /// Record and report detailed information about memory leaks - detailed_leaks: bool, - /// Seed the random number generator - rust_seed: *c_char, - /// Poison allocations on free - poison_on_free: bool, - /// The argc value passed to main - argc: c_int, - /// The argv value passed to main - argv: **c_char, - /// Print GC debugging info (true if env var RUST_DEBUG_MEM is set) - debug_mem: bool, - /// Print GC debugging info (true if env var RUST_DEBUG_BORROW is set) - debug_borrow: bool, -} - -/// Get the global environment settings -/// # Safety Note -/// This will abort the process if run outside of task context -pub fn get() -> &Environment { - unsafe { rust_get_rt_env() } -} - -extern { - fn rust_get_rt_env() -> &Environment; -} - -// NEW RT stuff - // Note that these are all accessed without any synchronization. // They are expected to be initialized once then left alone. diff --git a/src/libstd/rt/io/comm_adapters.rs b/src/libstd/rt/io/comm_adapters.rs index 7e891f1718e..6a3e44b2a4d 100644 --- a/src/libstd/rt/io/comm_adapters.rs +++ b/src/libstd/rt/io/comm_adapters.rs @@ -8,7 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use prelude::*; +use option::Option; +use comm::{GenericPort, GenericChan}; use super::{Reader, Writer}; struct PortReader<P>; diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs index 8832597f40c..11afd03033a 100644 --- a/src/libstd/rt/local_heap.rs +++ b/src/libstd/rt/local_heap.rs @@ -13,9 +13,6 @@ use libc; use libc::{c_void, uintptr_t, size_t}; use ops::Drop; -use option::{Some, None}; -use rt; -use rt::OldTaskContext; use rt::local::Local; use rt::task::Task; use unstable::raw; @@ -87,32 +84,14 @@ impl Drop for LocalHeap { // A little compatibility function pub unsafe fn local_free(ptr: *libc::c_char) { - // XXX: Unsafe borrow for speed. Lame. - match Local::try_unsafe_borrow::<Task>() { - Some(task) => { - (*task).heap.free(ptr as *libc::c_void); - } - None => { - rust_upcall_free_noswitch(ptr); - - extern { - #[fast_ffi] - fn rust_upcall_free_noswitch(ptr: *libc::c_char); - } - } + do Local::borrow::<Task,()> |task| { + task.heap.free(ptr as *libc::c_void); } } pub fn live_allocs() -> *raw::Box<()> { - let region = match rt::context() { - OldTaskContext => { - unsafe { rust_current_boxed_region() } - } - _ => { - do Local::borrow::<Task, *BoxedRegion> |task| { - task.heap.boxed_region - } - } + let region = do Local::borrow::<Task, *BoxedRegion> |task| { + task.heap.boxed_region }; return unsafe { (*region).live_allocs }; @@ -140,8 +119,6 @@ extern { size: size_t) -> *OpaqueBox; #[fast_ffi] fn rust_boxed_region_free(region: *BoxedRegion, box: *OpaqueBox); - #[fast_ffi] - fn rust_current_boxed_region() -> *BoxedRegion; } #[cfg(test)] diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index be71bc651df..348345f61fc 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -120,7 +120,7 @@ mod context; /// Bindings to system threading libraries. mod thread; -/// The runtime configuration, read from environment variables +/// The runtime configuration, read from environment variables. pub mod env; /// The local, managed heap @@ -401,35 +401,6 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int { } } -/// Possible contexts in which Rust code may be executing. -/// Different runtime services are available depending on context. -/// Mostly used for determining if we're using the new scheduler -/// or the old scheduler. -#[deriving(Eq)] -pub enum RuntimeContext { - // Running in an old-style task - OldTaskContext, - // Not old task context - NewRtContext -} - -/// Determine the current RuntimeContext -pub fn context() -> RuntimeContext { - - use task::rt::rust_task; - - if unsafe { rust_try_get_task().is_not_null() } { - return OldTaskContext; - } else { - return NewRtContext; - } - - extern { - #[rust_stack] - pub fn rust_try_get_task() -> *rust_task; - } -} - pub fn in_sched_context() -> bool { unsafe { match Local::try_unsafe_borrow::<Task>() { @@ -456,4 +427,4 @@ pub fn in_green_task_context() -> bool { None => false } } -} \ No newline at end of file +} diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs index 364439a4526..b50e794cce0 100644 --- a/src/libstd/rt/task.rs +++ b/src/libstd/rt/task.rs @@ -515,8 +515,8 @@ mod test { do run_in_newsched_task { let (port, chan) = oneshot(); - send_one(chan, 10); - assert!(recv_one(port) == 10); + chan.send(10); + assert!(port.recv() == 10); } } diff --git a/src/libstd/rt/uv/uvll.rs b/src/libstd/rt/uv/uvll.rs index 07264839c35..a06247a1036 100644 --- a/src/libstd/rt/uv/uvll.rs +++ b/src/libstd/rt/uv/uvll.rs @@ -448,13 +448,6 @@ pub unsafe fn get_base_from_buf(buf: uv_buf_t) -> *u8 { pub unsafe fn get_len_from_buf(buf: uv_buf_t) -> size_t { return rust_uv_get_len_from_buf(buf); } -pub unsafe fn malloc_buf_base_of(suggested_size: size_t) -> *u8 { - return rust_uv_malloc_buf_base_of(suggested_size); -} -pub unsafe fn free_base_of_buf(buf: uv_buf_t) { - rust_uv_free_base_of_buf(buf); -} - pub unsafe fn get_last_err_info(uv_loop: *c_void) -> ~str { let err = last_error(uv_loop); let err_ptr = ptr::to_unsafe_ptr(&err); @@ -558,8 +551,6 @@ extern { repeat: libc::uint64_t) -> c_int; fn rust_uv_timer_stop(handle: *uv_timer_t) -> c_int; - fn rust_uv_malloc_buf_base_of(sug_size: size_t) -> *u8; - fn rust_uv_free_base_of_buf(buf: uv_buf_t); fn rust_uv_get_stream_handle_from_connect_req(connect_req: *uv_connect_t) -> *uv_stream_t; fn rust_uv_get_stream_handle_from_write_req(write_req: *uv_write_t) -> *uv_stream_t; fn rust_uv_get_loop_for_uv_handle(handle: *c_void) -> *c_void; |
