#[cfg(test)]
mod tests {
+ extern crate rustrt;
+
use std::cell::Cell;
use std::default::Default;
use std::mem;
#[test]
fn test_swap_remove_noncopyable() {
// Tests that we don't accidentally run destructors twice.
- let mut v = vec![rt::exclusive::Exclusive::new(()),
- rt::exclusive::Exclusive::new(()),
- rt::exclusive::Exclusive::new(())];
+ let mut v = vec![rustrt::exclusive::Exclusive::new(()),
+ rustrt::exclusive::Exclusive::new(()),
+ rustrt::exclusive::Exclusive::new(())];
let mut _e = v.swap_remove(0);
assert_eq!(v.len(), 2);
_e = v.swap_remove(1);
#[cfg(test)]
mod test {
+ extern crate rustrt;
+
use std::prelude::*;
- use std::rt::thread::Thread;
+ use rustrt::thread::Thread;
use super::*;
use task::Task;
//! # Example
//!
//! ```rust
-//! use std::rt::mutex::{NativeMutex, StaticNativeMutex, NATIVE_MUTEX_INIT};
+//! use rustrt::mutex::{NativeMutex, StaticNativeMutex, NATIVE_MUTEX_INIT};
//!
//! // Use a statically initialized mutex
//! static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
/// # Example
///
/// ```rust
- /// use std::rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
+ /// use rustrt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
/// static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
/// unsafe {
/// let _guard = LOCK.lock();
/// # Example
///
/// ```rust
- /// use std::rt::mutex::NativeMutex;
+ /// use rustrt::mutex::NativeMutex;
/// unsafe {
/// let mut lock = NativeMutex::new();
///
#[cfg(test)]
mod test {
+ extern crate rustrt;
+
use std::prelude::*;
use std::mem::drop;
use super::{StaticNativeMutex, NATIVE_MUTEX_INIT};
- use std::rt::thread::Thread;
+ use rustrt::thread::Thread;
#[test]
fn smoke_lock() {
#[cfg(test)]
mod test {
+ extern crate rustrt;
+
use super::*;
use std::prelude::*;
use std::task;
#[test]
#[should_fail]
fn test_begin_unwind() {
- use std::rt::unwind::begin_unwind;
+ use rustrt::unwind::begin_unwind;
begin_unwind("cause", &(file!(), line!()))
}
}
pub fn check_for_errors_in<T>(f: || -> T) -> Result<T, String> {
- use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
+ use rustrt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
unsafe {
// dlerror isn't thread safe, so we need to lock around this entire
use option::{Some, None};
use result::Ok;
use rt::backtrace;
-use rt::{Stderr, Stdio};
+use rustrt::{Stderr, Stdio};
use rustrt::local::Local;
use rustrt::task::Task;
use str::Str;
use boxed::Box;
use sys::{fs, tty};
use result::{Ok, Err};
-use rt;
-use rt::local::Local;
-use rt::task::Task;
+use rustrt;
+use rustrt::local::Local;
+use rustrt::task::Task;
use slice::SlicePrelude;
use str::StrPrelude;
use uint;
local_stdout.replace(Some(my_stdout));
result
} else {
- let mut io = rt::Stdout;
+ let mut io = rustrt::Stdout;
f(&mut io as &mut Writer)
};
match result {
pub use core::option;
pub use alloc::boxed;
-
pub use alloc::rc;
pub use core_collections::slice;
#[path = "sys/common/mod.rs"] mod sys_common;
-mod rt;
+pub mod rt;
mod failure;
// A curious inner-module that's not exported that contains the binding
Serialize access through a global lock.
*/
fn with_env_lock<T>(f: || -> T) -> T {
- use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
+ use rustrt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
target_os = "freebsd",
target_os = "dragonfly"))]
fn real_args_as_bytes() -> Vec<Vec<u8>> {
- use rt;
+ use rustrt;
- match rt::args::clone() {
+ match rustrt::args::clone() {
Some(args) => args,
None => panic!("process arguments not initialized")
}
use mem;
use option::{Some, None, Option};
use result::{Ok, Err};
- use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
+ use rustrt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
/// As always - iOS on arm uses SjLj exceptions and
/// _Unwind_Backtrace is even not available there. Still,
use option::{Some, None};
use path::Path;
use result::{Ok, Err};
- use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
+ use rustrt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
use slice::SlicePrelude;
use str::StrPrelude;
use dynamic_lib::DynamicLibrary;
// Reexport functionality from librustrt and other crates underneath the
// standard library which work together to create the entire runtime.
pub use alloc::heap;
-pub use rustrt::{task, local, mutex, exclusive, stack, args, thread};
-pub use rustrt::{Stdio, Stdout, Stderr, begin_unwind, begin_unwind_fmt};
-pub use rustrt::{at_exit, unwind, DEFAULT_ERROR_CODE};
+pub use rustrt::{begin_unwind, begin_unwind_fmt, at_exit};
// Simple backtrace functionality (to print on panic)
pub mod backtrace;
#[allow(experimental)]
pub fn init(argc: int, argv: *const *const u8) {
rustrt::init(argc, argv);
- unsafe { unwind::register(failure::on_fail); }
+ unsafe { rustrt::unwind::register(failure::on_fail); }
}
#[cfg(any(windows, android))]
init(argc, argv);
let mut exit_code = None;
let mut main = Some(main);
- let mut task = Task::new(Some((my_stack_bottom, my_stack_top)),
- Some(rt::thread::main_guard_page()));
+ let mut task = box Task::new(Some((my_stack_bottom, my_stack_top)),
+ Some(rustrt::thread::main_guard_page()));
task.name = Some(str::Slice("<main>"));
drop(task.run(|| {
unsafe {
- rt::stack::record_os_managed_stack_bounds(my_stack_bottom, my_stack_top);
+ rustrt::stack::record_os_managed_stack_bounds(my_stack_bottom, my_stack_top);
}
(main.take().unwrap())();
exit_code = Some(os::get_exit_status());
}).destroy());
unsafe { rt::cleanup(); }
// If the exit code wasn't set, then the task block must have panicked.
- return exit_code.unwrap_or(rt::DEFAULT_ERROR_CODE);
+ return exit_code.unwrap_or(rustrt::DEFAULT_ERROR_CODE);
}
/// One-time runtime cleanup.
use mem;
use rustrt::bookkeeping;
-use rt::mutex::StaticNativeMutex;
-use rt;
+use rustrt::mutex::StaticNativeMutex;
+use rustrt;
use cell::UnsafeCell;
use sys::helper_signal;
use prelude::*;
self.lock.lock().signal()
});
- rt::at_exit(proc() { self.shutdown() });
+ rustrt::at_exit(proc() { self.shutdown() });
*self.initialized.get() = true;
}
}
use mem;
use num::Int;
use ptr::{mod, null, null_mut};
-use rt::mutex;
+use rustrt::mutex;
use io::net::ip::{SocketAddr, IpAddr, Ipv4Addr, Ipv6Addr};
use io::net::addrinfo;
use io::{IoResult, IoError};
macro_rules! helper_init( (static $name:ident: Helper<$m:ty>) => (
static $name: Helper<$m> = Helper {
- lock: ::rt::mutex::NATIVE_MUTEX_INIT,
+ lock: ::rustrt::mutex::NATIVE_MUTEX_INIT,
chan: ::cell::UnsafeCell { value: 0 as *mut Sender<$m> },
signal: ::cell::UnsafeCell { value: 0 },
initialized: ::cell::UnsafeCell { value: false },
use libc;
use c_str::CString;
use mem;
-use rt::mutex;
+use rustrt::mutex;
use sync::atomic;
use io::{mod, IoResult, IoError};
use prelude::*;
macro_rules! helper_init( (static $name:ident: Helper<$m:ty>) => (
static $name: Helper<$m> = Helper {
- lock: ::rt::mutex::NATIVE_MUTEX_INIT,
+ lock: ::rustrt::mutex::NATIVE_MUTEX_INIT,
chan: ::cell::UnsafeCell { value: 0 as *mut Sender<$m> },
signal: ::cell::UnsafeCell { value: 0 },
initialized: ::cell::UnsafeCell { value: false },
use mem;
use ptr;
use sync::atomic;
-use rt::mutex;
+use rustrt::mutex;
use io::{mod, IoError, IoResult};
use prelude::*;
use option::{None, Some, Option};
use boxed::Box;
use result::Result;
-use rt::local::Local;
-use rt::task;
-use rt::task::Task;
+use rustrt::local::Local;
+use rustrt::task;
+use rustrt::task::Task;
use str::{Str, SendStr, IntoMaybeOwned};
use string::{String, ToString};
use sync::Future;
stack_size: stack_size,
};
if stdout.is_some() || stderr.is_some() {
- spawner.spawn(opts, proc() {
+ Task::spawn(opts, proc() {
let _ = stdout.map(stdio::set_stdout);
let _ = stderr.map(stdio::set_stderr);
f();
})
} else {
- spawner.spawn(opts, f)
+ Task::spawn(opts, f)
}
}
/// Read the name of the current task.
#[stable]
pub fn name() -> Option<String> {
- use rt::task::Task;
+ use rustrt::task::Task;
let task = Local::borrow(None::<Task>);
match task.name {
/// Yield control to the task scheduler.
#[unstable = "Name will change."]
pub fn deschedule() {
- use rt::task::Task;
+ use rustrt::task::Task;
Task::yield_now();
}
/// destructor that is run while unwinding the stack after a call to `panic!()`).
#[unstable = "May move to a different module."]
pub fn failing() -> bool {
- use rt::task::Task;
+ use rustrt::task::Task;
Local::borrow(None::<Task>).unwinder.unwinding()
}
mod $name {
#![allow(unused_imports)]
+ extern crate rustrt;
+
use std::prelude::*;
use comm::*;
})
test!(fn sends_off_the_runtime() {
- use std::rt::thread::Thread;
+ use rustrt::thread::Thread;
let (tx, rx) = channel();
let t = Thread::start(proc() {
})
test!(fn try_recvs_off_the_runtime() {
- use std::rt::thread::Thread;
+ use rustrt::thread::Thread;
let (tx, rx) = channel();
let (cdone, pdone) = channel();
})
test!(fn try_recvs_off_the_runtime() {
- use std::rt::thread::Thread;
+ use rustrt::thread::Thread;
let (tx, rx) = sync_channel::<()>(0);
let (cdone, pdone) = channel();
use super::{Data, BufferPool, Abort, Empty, Worker, Stealer};
use std::mem;
- use std::rt::thread::Thread;
+ use rustrt::thread::Thread;
use std::rand;
use std::rand::Rng;
use atomic::{AtomicBool, INIT_ATOMIC_BOOL, SeqCst,
// except according to those terms.
extern crate libc;
+extern crate rustrt;
use std::mem;
-use std::rt::thread::Thread;
+use rustrt::thread::Thread;
#[link(name = "rust_test_helpers")]
extern {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+extern crate rustrt;
+
pub fn main() {
unsafe {
- let x = Some(::std::rt::exclusive::Exclusive::new(true));
+ let x = Some(::rustrt::exclusive::Exclusive::new(true));
match x {
Some(ref z) if *z.lock() => {
assert!(*z.lock());
+++ /dev/null
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// ignore-android (FIXME #11419)
-
-extern crate native;
-
-static mut set: bool = false;
-
-#[start]
-fn start(argc: int, argv: *const *const u8) -> int {
- // make sure that native::start always waits for all children to finish
- native::start(argc, argv, proc() {
- spawn(proc() {
- unsafe { set = true; }
- });
- });
-
- // if we didn't set the global, then return a nonzero code
- if unsafe {set} {0} else {1}
-}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+extern crate rustrt;
struct Point {x: int, y: int, z: int}
pub fn main() {
unsafe {
- let x = Some(::std::rt::exclusive::Exclusive::new(true));
+ let x = Some(::rustrt::exclusive::Exclusive::new(true));
match x {
Some(ref z) if *z.lock() => {
assert!(*z.lock());