Register new snapshots

Also convert a number of `static mut` to just a plain old `static` and remove
some unsafe blocks.
This commit is contained in:
Alex Crichton
2014-10-10 21:59:10 -07:00
parent 1add4dedc1
commit dae48a07f3
36 changed files with 107 additions and 307 deletions

View File

@@ -928,29 +928,6 @@ impl<S: Str> Add<S, String> for String {
} }
} }
#[cfg(stage0)]
impl ops::Slice<uint, str> for String {
#[inline]
fn as_slice_<'a>(&'a self) -> &'a str {
self.as_slice()
}
#[inline]
fn slice_from_<'a>(&'a self, from: &uint) -> &'a str {
self[][*from..]
}
#[inline]
fn slice_to_<'a>(&'a self, to: &uint) -> &'a str {
self[][..*to]
}
#[inline]
fn slice_<'a>(&'a self, from: &uint, to: &uint) -> &'a str {
self[][*from..*to]
}
}
#[cfg(not(stage0))]
impl ops::Slice<uint, str> for String { impl ops::Slice<uint, str> for String {
#[inline] #[inline]
fn as_slice_<'a>(&'a self) -> &'a str { fn as_slice_<'a>(&'a self) -> &'a str {

View File

@@ -389,15 +389,6 @@ macro_rules! bound {
impl<T> TrieMap<T> { impl<T> TrieMap<T> {
// If `upper` is true then returns upper_bound else returns lower_bound. // If `upper` is true then returns upper_bound else returns lower_bound.
#[cfg(stage0)]
#[inline]
fn bound<'a>(&'a self, key: uint, upper: bool) -> Entries<'a, T> {
bound!(Entries, self = self,
key = key, is_upper = upper,
slice_from = slice_from_, iter = iter,
mutability = )
}
#[cfg(not(stage0))]
#[inline] #[inline]
fn bound<'a>(&'a self, key: uint, upper: bool) -> Entries<'a, T> { fn bound<'a>(&'a self, key: uint, upper: bool) -> Entries<'a, T> {
bound!(Entries, self = self, bound!(Entries, self = self,
@@ -440,15 +431,6 @@ impl<T> TrieMap<T> {
self.bound(key, true) self.bound(key, true)
} }
// If `upper` is true then returns upper_bound else returns lower_bound. // If `upper` is true then returns upper_bound else returns lower_bound.
#[cfg(stage0)]
#[inline]
fn bound_mut<'a>(&'a mut self, key: uint, upper: bool) -> MutEntries<'a, T> {
bound!(MutEntries, self = self,
key = key, is_upper = upper,
slice_from = slice_from_mut_, iter = iter_mut,
mutability = mut)
}
#[cfg(not(stage0))]
#[inline] #[inline]
fn bound_mut<'a>(&'a mut self, key: uint, upper: bool) -> MutEntries<'a, T> { fn bound_mut<'a>(&'a mut self, key: uint, upper: bool) -> MutEntries<'a, T> {
bound!(MutEntries, self = self, bound!(MutEntries, self = self,

View File

@@ -461,28 +461,6 @@ impl<T> Index<uint,T> for Vec<T> {
} }
}*/ }*/
#[cfg(stage0)]
impl<T> ops::Slice<uint, [T]> for Vec<T> {
#[inline]
fn as_slice_<'a>(&'a self) -> &'a [T] {
self.as_slice()
}
#[inline]
fn slice_from_<'a>(&'a self, start: &uint) -> &'a [T] {
self.as_slice().slice_from_(start)
}
#[inline]
fn slice_to_<'a>(&'a self, end: &uint) -> &'a [T] {
self.as_slice().slice_to_(end)
}
#[inline]
fn slice_<'a>(&'a self, start: &uint, end: &uint) -> &'a [T] {
self.as_slice().slice_(start, end)
}
}
#[cfg(not(stage0))]
impl<T> ops::Slice<uint, [T]> for Vec<T> { impl<T> ops::Slice<uint, [T]> for Vec<T> {
#[inline] #[inline]
fn as_slice_<'a>(&'a self) -> &'a [T] { fn as_slice_<'a>(&'a self) -> &'a [T] {
@@ -504,28 +482,6 @@ impl<T> ops::Slice<uint, [T]> for Vec<T> {
} }
} }
#[cfg(stage0)]
impl<T> ops::SliceMut<uint, [T]> for Vec<T> {
#[inline]
fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {
self.as_mut_slice()
}
#[inline]
fn slice_from_mut_<'a>(&'a mut self, start: &uint) -> &'a mut [T] {
self.as_mut_slice().slice_from_mut_(start)
}
#[inline]
fn slice_to_mut_<'a>(&'a mut self, end: &uint) -> &'a mut [T] {
self.as_mut_slice().slice_to_mut_(end)
}
#[inline]
fn slice_mut_<'a>(&'a mut self, start: &uint, end: &uint) -> &'a mut [T] {
self.as_mut_slice().slice_mut_(start, end)
}
}
#[cfg(not(stage0))]
impl<T> ops::SliceMut<uint, [T]> for Vec<T> { impl<T> ops::SliceMut<uint, [T]> for Vec<T> {
#[inline] #[inline]
fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] { fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {

View File

@@ -254,7 +254,6 @@ extern "rust-intrinsic" {
/// enabling further optimizations. /// enabling further optimizations.
/// ///
/// NB: This is very different from the `unreachable!()` macro! /// NB: This is very different from the `unreachable!()` macro!
#[cfg(not(stage0))]
pub fn unreachable() -> !; pub fn unreachable() -> !;
/// Execute a breakpoint trap, for inspection by a debugger. /// Execute a breakpoint trap, for inspection by a debugger.

View File

@@ -711,7 +711,6 @@ pub trait IndexMut<Index, Result> {
* } * }
* ``` * ```
*/ */
#[cfg(not(stage0))]
#[lang="slice"] #[lang="slice"]
pub trait Slice<Idx, Sized? Result> for Sized? { pub trait Slice<Idx, Sized? Result> for Sized? {
/// The method for the slicing operation foo[] /// The method for the slicing operation foo[]
@@ -723,21 +722,6 @@ pub trait Slice<Idx, Sized? Result> for Sized? {
/// The method for the slicing operation foo[from..to] /// The method for the slicing operation foo[from..to]
fn slice_or_fail<'a>(&'a self, from: &Idx, to: &Idx) -> &'a Result; fn slice_or_fail<'a>(&'a self, from: &Idx, to: &Idx) -> &'a Result;
} }
#[cfg(stage0)]
/**
*
*/
#[lang="slice"]
pub trait Slice<Idx, Sized? Result> for Sized? {
/// The method for the slicing operation foo[]
fn as_slice_<'a>(&'a self) -> &'a Result;
/// The method for the slicing operation foo[from..]
fn slice_from_<'a>(&'a self, from: &Idx) -> &'a Result;
/// The method for the slicing operation foo[..to]
fn slice_to_<'a>(&'a self, to: &Idx) -> &'a Result;
/// The method for the slicing operation foo[from..to]
fn slice_<'a>(&'a self, from: &Idx, to: &Idx) -> &'a Result;
}
/** /**
* *
@@ -776,7 +760,6 @@ pub trait Slice<Idx, Sized? Result> for Sized? {
* } * }
* ``` * ```
*/ */
#[cfg(not(stage0))]
#[lang="slice_mut"] #[lang="slice_mut"]
pub trait SliceMut<Idx, Sized? Result> for Sized? { pub trait SliceMut<Idx, Sized? Result> for Sized? {
/// The method for the slicing operation foo[] /// The method for the slicing operation foo[]
@@ -788,21 +771,7 @@ pub trait SliceMut<Idx, Sized? Result> for Sized? {
/// The method for the slicing operation foo[from..to] /// The method for the slicing operation foo[from..to]
fn slice_or_fail_mut<'a>(&'a mut self, from: &Idx, to: &Idx) -> &'a mut Result; fn slice_or_fail_mut<'a>(&'a mut self, from: &Idx, to: &Idx) -> &'a mut Result;
} }
#[cfg(stage0)]
/**
*
*/
#[lang="slice_mut"]
pub trait SliceMut<Idx, Sized? Result> for Sized? {
/// The method for the slicing operation foo[mut]
fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Result;
/// The method for the slicing operation foo[mut from..]
fn slice_from_mut_<'a>(&'a mut self, from: &Idx) -> &'a mut Result;
/// The method for the slicing operation foo[mut ..to]
fn slice_to_mut_<'a>(&'a mut self, to: &Idx) -> &'a mut Result;
/// The method for the slicing operation foo[mut from..to]
fn slice_mut_<'a>(&'a mut self, from: &Idx, to: &Idx) -> &'a mut Result;
}
/** /**
* *
* The `Deref` trait is used to specify the functionality of dereferencing * The `Deref` trait is used to specify the functionality of dereferencing

View File

@@ -488,7 +488,6 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] {
#[cfg(not(stage0))]
impl<T> ops::Slice<uint, [T]> for [T] { impl<T> ops::Slice<uint, [T]> for [T] {
#[inline] #[inline]
fn as_slice_<'a>(&'a self) -> &'a [T] { fn as_slice_<'a>(&'a self) -> &'a [T] {
@@ -516,36 +515,7 @@ impl<T> ops::Slice<uint, [T]> for [T] {
} }
} }
} }
#[cfg(stage0)]
impl<T> ops::Slice<uint, [T]> for [T] {
#[inline]
fn as_slice_<'a>(&'a self) -> &'a [T] {
self
}
#[inline]
fn slice_from_<'a>(&'a self, start: &uint) -> &'a [T] {
self.slice_(start, &self.len())
}
#[inline]
fn slice_to_<'a>(&'a self, end: &uint) -> &'a [T] {
self.slice_(&0, end)
}
#[inline]
fn slice_<'a>(&'a self, start: &uint, end: &uint) -> &'a [T] {
assert!(*start <= *end);
assert!(*end <= self.len());
unsafe {
transmute(RawSlice {
data: self.as_ptr().offset(*start as int),
len: (*end - *start)
})
}
}
}
#[cfg(not(stage0))]
impl<T> ops::SliceMut<uint, [T]> for [T] { impl<T> ops::SliceMut<uint, [T]> for [T] {
#[inline] #[inline]
fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] { fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {
@@ -574,35 +544,6 @@ impl<T> ops::SliceMut<uint, [T]> for [T] {
} }
} }
} }
#[cfg(stage0)]
impl<T> ops::SliceMut<uint, [T]> for [T] {
#[inline]
fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {
self
}
#[inline]
fn slice_from_mut_<'a>(&'a mut self, start: &uint) -> &'a mut [T] {
let len = &self.len();
self.slice_mut_(start, len)
}
#[inline]
fn slice_to_mut_<'a>(&'a mut self, end: &uint) -> &'a mut [T] {
self.slice_mut_(&0, end)
}
#[inline]
fn slice_mut_<'a>(&'a mut self, start: &uint, end: &uint) -> &'a mut [T] {
assert!(*start <= *end);
assert!(*end <= self.len());
unsafe {
transmute(RawSlice {
data: self.as_ptr().offset(*start as int),
len: (*end - *start)
})
}
}
}
/// Extension methods for slices such that their elements are /// Extension methods for slices such that their elements are
/// mutable. /// mutable.

View File

@@ -1164,29 +1164,6 @@ pub mod traits {
fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) } fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) }
} }
#[cfg(stage0)]
impl ops::Slice<uint, str> for str {
#[inline]
fn as_slice_<'a>(&'a self) -> &'a str {
self
}
#[inline]
fn slice_from_<'a>(&'a self, from: &uint) -> &'a str {
self.slice_from(*from)
}
#[inline]
fn slice_to_<'a>(&'a self, to: &uint) -> &'a str {
self.slice_to(*to)
}
#[inline]
fn slice_<'a>(&'a self, from: &uint, to: &uint) -> &'a str {
self.slice(*from, *to)
}
}
#[cfg(not(stage0))]
impl ops::Slice<uint, str> for str { impl ops::Slice<uint, str> for str {
#[inline] #[inline]
fn as_slice_<'a>(&'a self) -> &'a str { fn as_slice_<'a>(&'a self) -> &'a str {

View File

@@ -69,15 +69,13 @@ fn int_xor() {
assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f); assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f);
} }
static mut S_BOOL : AtomicBool = INIT_ATOMIC_BOOL; static S_BOOL : AtomicBool = INIT_ATOMIC_BOOL;
static mut S_INT : AtomicInt = INIT_ATOMIC_INT; static S_INT : AtomicInt = INIT_ATOMIC_INT;
static mut S_UINT : AtomicUint = INIT_ATOMIC_UINT; static S_UINT : AtomicUint = INIT_ATOMIC_UINT;
#[test] #[test]
fn static_init() { fn static_init() {
unsafe {
assert!(!S_BOOL.load(SeqCst)); assert!(!S_BOOL.load(SeqCst));
assert!(S_INT.load(SeqCst) == 0); assert!(S_INT.load(SeqCst) == 0);
assert!(S_UINT.load(SeqCst) == 0); assert!(S_UINT.load(SeqCst) == 0);
}
} }

View File

@@ -335,7 +335,7 @@ impl SchedPool {
/// This will configure the pool according to the `config` parameter, and /// This will configure the pool according to the `config` parameter, and
/// initially run `main` inside the pool of schedulers. /// initially run `main` inside the pool of schedulers.
pub fn new(config: PoolConfig) -> SchedPool { pub fn new(config: PoolConfig) -> SchedPool {
static mut POOL_ID: AtomicUint = INIT_ATOMIC_UINT; static POOL_ID: AtomicUint = INIT_ATOMIC_UINT;
let PoolConfig { let PoolConfig {
threads: nscheds, threads: nscheds,
@@ -349,7 +349,7 @@ impl SchedPool {
threads: vec![], threads: vec![],
handles: vec![], handles: vec![],
stealers: vec![], stealers: vec![],
id: unsafe { POOL_ID.fetch_add(1, SeqCst) }, id: POOL_ID.fetch_add(1, SeqCst),
sleepers: SleeperList::new(), sleepers: SleeperList::new(),
stack_pool: StackPool::new(), stack_pool: StackPool::new(),
deque_pool: deque::BufferPool::new(), deque_pool: deque::BufferPool::new(),

View File

@@ -1458,7 +1458,7 @@ mod test {
#[test] #[test]
fn test_spawn_sched_blocking() { fn test_spawn_sched_blocking() {
use std::rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT}; use std::rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT; static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
// Testing that a task in one scheduler can block in foreign code // Testing that a task in one scheduler can block in foreign code
// without affecting other schedulers // without affecting other schedulers

View File

@@ -158,8 +158,8 @@ impl StackPool {
} }
fn max_cached_stacks() -> uint { fn max_cached_stacks() -> uint {
static mut AMT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT; static AMT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
match unsafe { AMT.load(atomic::SeqCst) } { match AMT.load(atomic::SeqCst) {
0 => {} 0 => {}
n => return n - 1, n => return n - 1,
} }
@@ -169,7 +169,7 @@ fn max_cached_stacks() -> uint {
let amt = amt.unwrap_or(10); let amt = amt.unwrap_or(10);
// 0 is our sentinel value, so ensure that we'll never see 0 after // 0 is our sentinel value, so ensure that we'll never see 0 after
// initialization has run // initialization has run
unsafe { AMT.store(amt + 1, atomic::SeqCst); } AMT.store(amt + 1, atomic::SeqCst);
return amt; return amt;
} }

View File

@@ -348,8 +348,8 @@ pub struct LogLocation {
/// module's log statement should be emitted or not. /// module's log statement should be emitted or not.
#[doc(hidden)] #[doc(hidden)]
pub fn mod_enabled(level: u32, module: &str) -> bool { pub fn mod_enabled(level: u32, module: &str) -> bool {
static mut INIT: Once = ONCE_INIT; static INIT: Once = ONCE_INIT;
unsafe { INIT.doit(init); } INIT.doit(init);
// It's possible for many threads are in this function, only one of them // It's possible for many threads are in this function, only one of them
// will perform the global initialization, but all of them will need to check // will perform the global initialization, but all of them will need to check

View File

@@ -55,8 +55,8 @@ pub struct Helper<M> {
pub initialized: UnsafeCell<bool>, pub initialized: UnsafeCell<bool>,
} }
macro_rules! helper_init( (static mut $name:ident: Helper<$m:ty>) => ( macro_rules! helper_init( (static $name:ident: Helper<$m:ty>) => (
static mut $name: Helper<$m> = Helper { static $name: Helper<$m> = Helper {
lock: ::std::rt::mutex::NATIVE_MUTEX_INIT, lock: ::std::rt::mutex::NATIVE_MUTEX_INIT,
chan: ::std::cell::UnsafeCell { value: 0 as *mut Sender<$m> }, chan: ::std::cell::UnsafeCell { value: 0 as *mut Sender<$m> },
signal: ::std::cell::UnsafeCell { value: 0 }, signal: ::std::cell::UnsafeCell { value: 0 },

View File

@@ -1063,7 +1063,7 @@ mod os {
unsafe { unsafe {
use std::rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT}; use std::rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
static mut INITIALIZED: bool = false; static mut INITIALIZED: bool = false;
static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT; static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
let _guard = LOCK.lock(); let _guard = LOCK.lock();
if !INITIALIZED { if !INITIALIZED {

View File

@@ -28,7 +28,7 @@ use super::util;
#[cfg(unix)] use io::helper_thread::Helper; #[cfg(unix)] use io::helper_thread::Helper;
#[cfg(unix)] #[cfg(unix)]
helper_init!(static mut HELPER: Helper<Req>) helper_init!(static HELPER: Helper<Req>)
/** /**
* A value representing a child process. * A value representing a child process.
@@ -988,7 +988,7 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult<rtio::ProcessExit> {
// The actual communication between the helper thread and this thread is // The actual communication between the helper thread and this thread is
// quite simple, just a channel moving data around. // quite simple, just a channel moving data around.
unsafe { HELPER.boot(register_sigchld, waitpid_helper) } HELPER.boot(register_sigchld, waitpid_helper);
match waitpid_nowait(pid) { match waitpid_nowait(pid) {
Some(ret) => return Ok(ret), Some(ret) => return Ok(ret),
@@ -996,7 +996,7 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult<rtio::ProcessExit> {
} }
let (tx, rx) = channel(); let (tx, rx) = channel();
unsafe { HELPER.send(NewChild(pid, tx, deadline)); } HELPER.send(NewChild(pid, tx, deadline));
return match rx.recv_opt() { return match rx.recv_opt() {
Ok(e) => Ok(e), Ok(e) => Ok(e),
Err(()) => Err(util::timeout("wait timed out")), Err(()) => Err(util::timeout("wait timed out")),

View File

@@ -59,7 +59,7 @@ use io::c;
use io::file::FileDesc; use io::file::FileDesc;
use io::helper_thread::Helper; use io::helper_thread::Helper;
helper_init!(static mut HELPER: Helper<Req>) helper_init!(static HELPER: Helper<Req>)
pub struct Timer { pub struct Timer {
id: uint, id: uint,
@@ -204,10 +204,10 @@ impl Timer {
pub fn new() -> IoResult<Timer> { pub fn new() -> IoResult<Timer> {
// See notes above regarding using int return value // See notes above regarding using int return value
// instead of () // instead of ()
unsafe { HELPER.boot(|| {}, helper); } HELPER.boot(|| {}, helper);
static mut ID: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT; static ID: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
let id = unsafe { ID.fetch_add(1, atomic::Relaxed) }; let id = ID.fetch_add(1, atomic::Relaxed);
Ok(Timer { Ok(Timer {
id: id, id: id,
inner: Some(box Inner { inner: Some(box Inner {
@@ -237,7 +237,7 @@ impl Timer {
Some(i) => i, Some(i) => i,
None => { None => {
let (tx, rx) = channel(); let (tx, rx) = channel();
unsafe { HELPER.send(RemoveTimer(self.id, tx)); } HELPER.send(RemoveTimer(self.id, tx));
rx.recv() rx.recv()
} }
} }
@@ -262,7 +262,7 @@ impl rtio::RtioTimer for Timer {
inner.interval = msecs; inner.interval = msecs;
inner.target = now + msecs; inner.target = now + msecs;
unsafe { HELPER.send(NewTimer(inner)); } HELPER.send(NewTimer(inner));
} }
fn period(&mut self, msecs: u64, cb: Box<rtio::Callback + Send>) { fn period(&mut self, msecs: u64, cb: Box<rtio::Callback + Send>) {
@@ -274,7 +274,7 @@ impl rtio::RtioTimer for Timer {
inner.interval = msecs; inner.interval = msecs;
inner.target = now + msecs; inner.target = now + msecs;
unsafe { HELPER.send(NewTimer(inner)); } HELPER.send(NewTimer(inner));
} }
} }

View File

@@ -28,7 +28,7 @@ use std::comm;
use io::helper_thread::Helper; use io::helper_thread::Helper;
helper_init!(static mut HELPER: Helper<Req>) helper_init!(static HELPER: Helper<Req>)
pub struct Timer { pub struct Timer {
obj: libc::HANDLE, obj: libc::HANDLE,
@@ -104,7 +104,7 @@ pub fn now() -> u64 {
impl Timer { impl Timer {
pub fn new() -> IoResult<Timer> { pub fn new() -> IoResult<Timer> {
unsafe { HELPER.boot(|| {}, helper) } HELPER.boot(|| {}, helper);
let obj = unsafe { let obj = unsafe {
imp::CreateWaitableTimerA(ptr::null_mut(), 0, ptr::null()) imp::CreateWaitableTimerA(ptr::null_mut(), 0, ptr::null())
@@ -126,7 +126,7 @@ impl Timer {
if !self.on_worker { return } if !self.on_worker { return }
let (tx, rx) = channel(); let (tx, rx) = channel();
unsafe { HELPER.send(RemoveTimer(self.obj, tx)) } HELPER.send(RemoveTimer(self.obj, tx));
rx.recv(); rx.recv();
self.on_worker = false; self.on_worker = false;
@@ -158,7 +158,7 @@ impl rtio::RtioTimer for Timer {
ptr::null_mut(), 0) ptr::null_mut(), 0)
}, 1); }, 1);
unsafe { HELPER.send(NewTimer(self.obj, cb, true)) } HELPER.send(NewTimer(self.obj, cb, true));
self.on_worker = true; self.on_worker = true;
} }
@@ -172,7 +172,7 @@ impl rtio::RtioTimer for Timer {
ptr::null_mut(), ptr::null_mut(), 0) ptr::null_mut(), ptr::null_mut(), 0)
}, 1); }, 1);
unsafe { HELPER.send(NewTimer(self.obj, cb, false)) } HELPER.send(NewTimer(self.obj, cb, false));
self.on_worker = true; self.on_worker = true;
} }
} }

View File

@@ -936,7 +936,7 @@ pub fn run_assembler(sess: &Session, outputs: &OutputFilenames) {
unsafe fn configure_llvm(sess: &Session) { unsafe fn configure_llvm(sess: &Session) {
use std::sync::{Once, ONCE_INIT}; use std::sync::{Once, ONCE_INIT};
static mut INIT: Once = ONCE_INIT; static INIT: Once = ONCE_INIT;
// Copy what clang does by turning on loop vectorization at O2 and // Copy what clang does by turning on loop vectorization at O2 and
// slp vectorization at O3 // slp vectorization at O3

View File

@@ -3035,7 +3035,7 @@ pub fn trans_crate<'tcx>(analysis: CrateAnalysis<'tcx>)
// Before we touch LLVM, make sure that multithreading is enabled. // Before we touch LLVM, make sure that multithreading is enabled.
unsafe { unsafe {
use std::sync::{Once, ONCE_INIT}; use std::sync::{Once, ONCE_INIT};
static mut INIT: Once = ONCE_INIT; static INIT: Once = ONCE_INIT;
static mut POISONED: bool = false; static mut POISONED: bool = false;
INIT.doit(|| { INIT.doit(|| {
if llvm::LLVMStartMultithreaded() != 1 { if llvm::LLVMStartMultithreaded() != 1 {

View File

@@ -54,8 +54,8 @@ mod imp {
use mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT}; use mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
static mut global_args_ptr: uint = 0; static mut GLOBAL_ARGS_PTR: uint = 0;
static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT; static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
pub unsafe fn init(argc: int, argv: *const *const u8) { pub unsafe fn init(argc: int, argv: *const *const u8) {
let args = load_argc_and_argv(argc, argv); let args = load_argc_and_argv(argc, argv);
@@ -64,7 +64,7 @@ mod imp {
pub unsafe fn cleanup() { pub unsafe fn cleanup() {
rtassert!(take().is_some()); rtassert!(take().is_some());
lock.destroy(); LOCK.destroy();
} }
pub fn take() -> Option<Vec<Vec<u8>>> { pub fn take() -> Option<Vec<Vec<u8>>> {
@@ -92,13 +92,13 @@ mod imp {
fn with_lock<T>(f: || -> T) -> T { fn with_lock<T>(f: || -> T) -> T {
unsafe { unsafe {
let _guard = lock.lock(); let _guard = LOCK.lock();
f() f()
} }
} }
fn get_global_ptr() -> *mut Option<Box<Vec<Vec<u8>>>> { fn get_global_ptr() -> *mut Option<Box<Vec<Vec<u8>>>> {
unsafe { mem::transmute(&global_args_ptr) } unsafe { mem::transmute(&GLOBAL_ARGS_PTR) }
} }
unsafe fn load_argc_and_argv(argc: int, argv: *const *const u8) -> Vec<Vec<u8>> { unsafe fn load_argc_and_argv(argc: int, argv: *const *const u8) -> Vec<Vec<u8>> {

View File

@@ -24,8 +24,8 @@ use exclusive::Exclusive;
type Queue = Exclusive<Vec<proc():Send>>; type Queue = Exclusive<Vec<proc():Send>>;
static mut QUEUE: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT; static QUEUE: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
static mut RUNNING: atomic::AtomicBool = atomic::INIT_ATOMIC_BOOL; static RUNNING: atomic::AtomicBool = atomic::INIT_ATOMIC_BOOL;
pub fn init() { pub fn init() {
let state: Box<Queue> = box Exclusive::new(Vec::new()); let state: Box<Queue> = box Exclusive::new(Vec::new());

View File

@@ -23,8 +23,8 @@ use core::ops::Drop;
use mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT}; use mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
static mut TASK_COUNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT; static TASK_COUNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
static mut TASK_LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT; static TASK_LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
pub struct Token { _private: () } pub struct Token { _private: () }
@@ -35,7 +35,7 @@ impl Drop for Token {
/// Increment the number of live tasks, returning a token which will decrement /// Increment the number of live tasks, returning a token which will decrement
/// the count when dropped. /// the count when dropped.
pub fn increment() -> Token { pub fn increment() -> Token {
let _ = unsafe { TASK_COUNT.fetch_add(1, atomic::SeqCst) }; let _ = TASK_COUNT.fetch_add(1, atomic::SeqCst);
Token { _private: () } Token { _private: () }
} }

View File

@@ -36,7 +36,7 @@
//! use std::rt::mutex::{NativeMutex, StaticNativeMutex, NATIVE_MUTEX_INIT}; //! use std::rt::mutex::{NativeMutex, StaticNativeMutex, NATIVE_MUTEX_INIT};
//! //!
//! // Use a statically initialized mutex //! // Use a statically initialized mutex
//! static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT; //! static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
//! //!
//! unsafe { //! unsafe {
//! let _guard = LOCK.lock(); //! let _guard = LOCK.lock();
@@ -109,7 +109,7 @@ impl StaticNativeMutex {
/// ///
/// ```rust /// ```rust
/// use std::rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT}; /// use std::rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
/// static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT; /// static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
/// unsafe { /// unsafe {
/// let _guard = LOCK.lock(); /// let _guard = LOCK.lock();
/// // critical section... /// // critical section...
@@ -655,7 +655,7 @@ mod test {
#[test] #[test]
fn smoke_lock() { fn smoke_lock() {
static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT; static lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
unsafe { unsafe {
let _guard = lock.lock(); let _guard = lock.lock();
} }
@@ -663,7 +663,7 @@ mod test {
#[test] #[test]
fn smoke_cond() { fn smoke_cond() {
static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT; static lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
unsafe { unsafe {
let guard = lock.lock(); let guard = lock.lock();
let t = Thread::start(proc() { let t = Thread::start(proc() {
@@ -679,7 +679,7 @@ mod test {
#[test] #[test]
fn smoke_lock_noguard() { fn smoke_lock_noguard() {
static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT; static lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
unsafe { unsafe {
lock.lock_noguard(); lock.lock_noguard();
lock.unlock_noguard(); lock.unlock_noguard();
@@ -688,7 +688,7 @@ mod test {
#[test] #[test]
fn smoke_cond_noguard() { fn smoke_cond_noguard() {
static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT; static lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
unsafe { unsafe {
lock.lock_noguard(); lock.lock_noguard();
let t = Thread::start(proc() { let t = Thread::start(proc() {

View File

@@ -92,7 +92,7 @@ pub type Callback = fn(msg: &Any + Send, file: &'static str, line: uint);
// //
// For more information, see below. // For more information, see below.
const MAX_CALLBACKS: uint = 16; const MAX_CALLBACKS: uint = 16;
static mut CALLBACKS: [atomic::AtomicUint, ..MAX_CALLBACKS] = static CALLBACKS: [atomic::AtomicUint, ..MAX_CALLBACKS] =
[atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT, [atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
@@ -101,7 +101,7 @@ static mut CALLBACKS: [atomic::AtomicUint, ..MAX_CALLBACKS] =
atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT]; atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT];
static mut CALLBACK_CNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT; static CALLBACK_CNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
impl Unwinder { impl Unwinder {
pub fn new() -> Unwinder { pub fn new() -> Unwinder {
@@ -560,7 +560,7 @@ fn begin_unwind_inner(msg: Box<Any + Send>, file_line: &(&'static str, uint)) ->
// so we just chalk it up to a race condition and move on to the next // so we just chalk it up to a race condition and move on to the next
// callback. Additionally, CALLBACK_CNT may briefly be higher than // callback. Additionally, CALLBACK_CNT may briefly be higher than
// MAX_CALLBACKS, so we're sure to clamp it as necessary. // MAX_CALLBACKS, so we're sure to clamp it as necessary.
let callbacks = unsafe { let callbacks = {
let amt = CALLBACK_CNT.load(atomic::SeqCst); let amt = CALLBACK_CNT.load(atomic::SeqCst);
CALLBACKS[..cmp::min(amt, MAX_CALLBACKS)] CALLBACKS[..cmp::min(amt, MAX_CALLBACKS)]
}; };

View File

@@ -230,11 +230,11 @@ pub mod dl {
pub fn check_for_errors_in<T>(f: || -> T) -> Result<T, String> { pub fn check_for_errors_in<T>(f: || -> T) -> Result<T, String> {
use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT}; use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT; static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
unsafe { unsafe {
// dlerror isn't thread safe, so we need to lock around this entire // dlerror isn't thread safe, so we need to lock around this entire
// sequence // sequence
let _guard = lock.lock(); let _guard = LOCK.lock();
let _old_error = dlerror(); let _old_error = dlerror();
let result = f(); let result = f();

View File

@@ -38,14 +38,14 @@ impl TempDir {
return TempDir::new_in(&os::make_absolute(tmpdir), suffix); return TempDir::new_in(&os::make_absolute(tmpdir), suffix);
} }
static mut CNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT; static CNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
let mut attempts = 0u; let mut attempts = 0u;
loop { loop {
let filename = let filename =
format!("rs-{}-{}-{}", format!("rs-{}-{}-{}",
unsafe { libc::getpid() }, unsafe { libc::getpid() },
unsafe { CNT.fetch_add(1, atomic::SeqCst) }, CNT.fetch_add(1, atomic::SeqCst),
suffix); suffix);
let p = tmpdir.join(filename); let p = tmpdir.join(filename);
match fs::mkdir(&p, io::USER_RWX) { match fs::mkdir(&p, io::USER_RWX) {

View File

@@ -20,22 +20,20 @@ use sync::atomic::{AtomicUint, INIT_ATOMIC_UINT, Relaxed};
/// Get a port number, starting at 9600, for use in tests /// Get a port number, starting at 9600, for use in tests
pub fn next_test_port() -> u16 { pub fn next_test_port() -> u16 {
static mut next_offset: AtomicUint = INIT_ATOMIC_UINT; static NEXT_OFFSET: AtomicUint = INIT_ATOMIC_UINT;
unsafe { base_port() + NEXT_OFFSET.fetch_add(1, Relaxed) as u16
base_port() + next_offset.fetch_add(1, Relaxed) as u16
}
} }
/// Get a temporary path which could be the location of a unix socket /// Get a temporary path which could be the location of a unix socket
pub fn next_test_unix() -> Path { pub fn next_test_unix() -> Path {
static mut COUNT: AtomicUint = INIT_ATOMIC_UINT; static COUNT: AtomicUint = INIT_ATOMIC_UINT;
// base port and pid are an attempt to be unique between multiple // base port and pid are an attempt to be unique between multiple
// test-runners of different configurations running on one // test-runners of different configurations running on one
// buildbot, the count is to be unique within this executable. // buildbot, the count is to be unique within this executable.
let string = format!("rust-test-unix-path-{}-{}-{}", let string = format!("rust-test-unix-path-{}-{}-{}",
base_port(), base_port(),
unsafe {libc::getpid()}, unsafe {libc::getpid()},
unsafe {COUNT.fetch_add(1, Relaxed)}); COUNT.fetch_add(1, Relaxed));
if cfg!(unix) { if cfg!(unix) {
os::tmpdir().join(string) os::tmpdir().join(string)
} else { } else {

View File

@@ -192,10 +192,10 @@ Serialize access through a global lock.
fn with_env_lock<T>(f: || -> T) -> T { fn with_env_lock<T>(f: || -> T) -> T {
use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT}; use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT; static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
unsafe { unsafe {
let _guard = lock.lock(); let _guard = LOCK.lock();
f() f()
} }
} }
@@ -1073,7 +1073,7 @@ pub fn last_os_error() -> String {
error_string(errno() as uint) error_string(errno() as uint)
} }
static mut EXIT_STATUS: AtomicInt = INIT_ATOMIC_INT; static EXIT_STATUS: AtomicInt = INIT_ATOMIC_INT;
/** /**
* Sets the process exit code * Sets the process exit code
@@ -1086,13 +1086,13 @@ static mut EXIT_STATUS: AtomicInt = INIT_ATOMIC_INT;
* Note that this is not synchronized against modifications of other threads. * Note that this is not synchronized against modifications of other threads.
*/ */
pub fn set_exit_status(code: int) { pub fn set_exit_status(code: int) {
unsafe { EXIT_STATUS.store(code, SeqCst) } EXIT_STATUS.store(code, SeqCst)
} }
/// Fetches the process's current exit code. This defaults to 0 and can change /// Fetches the process's current exit code. This defaults to 0 and can change
/// by calling `set_exit_status`. /// by calling `set_exit_status`.
pub fn get_exit_status() -> int { pub fn get_exit_status() -> int {
unsafe { EXIT_STATUS.load(SeqCst) } EXIT_STATUS.load(SeqCst)
} }
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]

View File

@@ -28,20 +28,18 @@ pub use self::imp::write;
// For now logging is turned off by default, and this function checks to see // For now logging is turned off by default, and this function checks to see
// whether the magical environment variable is present to see if it's turned on. // whether the magical environment variable is present to see if it's turned on.
pub fn log_enabled() -> bool { pub fn log_enabled() -> bool {
static mut ENABLED: atomic::AtomicInt = atomic::INIT_ATOMIC_INT; static ENABLED: atomic::AtomicInt = atomic::INIT_ATOMIC_INT;
unsafe {
match ENABLED.load(atomic::SeqCst) { match ENABLED.load(atomic::SeqCst) {
1 => return false, 1 => return false,
2 => return true, 2 => return true,
_ => {} _ => {}
} }
}
let val = match os::getenv("RUST_BACKTRACE") { let val = match os::getenv("RUST_BACKTRACE") {
Some(..) => 2, Some(..) => 2,
None => 1, None => 1,
}; };
unsafe { ENABLED.store(val, atomic::SeqCst); } ENABLED.store(val, atomic::SeqCst);
val == 2 val == 2
} }
@@ -268,7 +266,7 @@ mod imp {
// while it doesn't requires lock for work as everything is // while it doesn't requires lock for work as everything is
// local, it still displays much nicer backtraces when a // local, it still displays much nicer backtraces when a
// couple of tasks fail simultaneously // couple of tasks fail simultaneously
static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT; static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
let _g = unsafe { LOCK.lock() }; let _g = unsafe { LOCK.lock() };
try!(writeln!(w, "stack backtrace:")); try!(writeln!(w, "stack backtrace:"));
@@ -301,7 +299,7 @@ mod imp {
// is semi-reasonable in terms of printing anyway, and we know that all // is semi-reasonable in terms of printing anyway, and we know that all
// I/O done here is blocking I/O, not green I/O, so we don't have to // I/O done here is blocking I/O, not green I/O, so we don't have to
// worry about this being a native vs green mutex. // worry about this being a native vs green mutex.
static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT; static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
let _g = unsafe { LOCK.lock() }; let _g = unsafe { LOCK.lock() };
try!(writeln!(w, "stack backtrace:")); try!(writeln!(w, "stack backtrace:"));
@@ -931,7 +929,7 @@ mod imp {
pub fn write(w: &mut Writer) -> IoResult<()> { pub fn write(w: &mut Writer) -> IoResult<()> {
// According to windows documentation, all dbghelp functions are // According to windows documentation, all dbghelp functions are
// single-threaded. // single-threaded.
static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT; static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
let _g = unsafe { LOCK.lock() }; let _g = unsafe { LOCK.lock() };
// Open up dbghelp.dll, we don't link to it explicitly because it can't // Open up dbghelp.dll, we don't link to it explicitly because it can't

View File

@@ -41,8 +41,8 @@ pub fn limit_thread_creation_due_to_osx_and_valgrind() -> bool {
} }
pub fn min_stack() -> uint { pub fn min_stack() -> uint {
static mut MIN: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT; static MIN: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
match unsafe { MIN.load(atomic::SeqCst) } { match MIN.load(atomic::SeqCst) {
0 => {} 0 => {}
n => return n - 1, n => return n - 1,
} }
@@ -50,7 +50,7 @@ pub fn min_stack() -> uint {
let amt = amt.unwrap_or(2 * 1024 * 1024); let amt = amt.unwrap_or(2 * 1024 * 1024);
// 0 is our sentinel value, so ensure that we'll never see 0 after // 0 is our sentinel value, so ensure that we'll never see 0 after
// initialization has run // initialization has run
unsafe { MIN.store(amt + 1, atomic::SeqCst); } MIN.store(amt + 1, atomic::SeqCst);
return amt; return amt;
} }

View File

@@ -93,12 +93,10 @@
//! ``` //! ```
//! use std::sync::atomic::{AtomicUint, SeqCst, INIT_ATOMIC_UINT}; //! use std::sync::atomic::{AtomicUint, SeqCst, INIT_ATOMIC_UINT};
//! //!
//! static mut GLOBAL_TASK_COUNT: AtomicUint = INIT_ATOMIC_UINT; //! static GLOBAL_TASK_COUNT: AtomicUint = INIT_ATOMIC_UINT;
//! //!
//! unsafe {
//! let old_task_count = GLOBAL_TASK_COUNT.fetch_add(1, SeqCst); //! let old_task_count = GLOBAL_TASK_COUNT.fetch_add(1, SeqCst);
//! println!("live tasks: {}", old_task_count + 1); //! println!("live tasks: {}", old_task_count + 1);
//! }
//! ``` //! ```
#![allow(deprecated)] #![allow(deprecated)]

View File

@@ -545,8 +545,8 @@ mod tests {
fn stress() { fn stress() {
static AMT: int = 100000; static AMT: int = 100000;
static NTHREADS: int = 8; static NTHREADS: int = 8;
static mut DONE: AtomicBool = INIT_ATOMIC_BOOL; static DONE: AtomicBool = INIT_ATOMIC_BOOL;
static mut HITS: AtomicUint = INIT_ATOMIC_UINT; static HITS: AtomicUint = INIT_ATOMIC_UINT;
let pool = BufferPool::<int>::new(); let pool = BufferPool::<int>::new();
let (w, s) = pool.deque(); let (w, s) = pool.deque();
@@ -604,7 +604,7 @@ mod tests {
fn no_starvation() { fn no_starvation() {
static AMT: int = 10000; static AMT: int = 10000;
static NTHREADS: int = 4; static NTHREADS: int = 4;
static mut DONE: AtomicBool = INIT_ATOMIC_BOOL; static DONE: AtomicBool = INIT_ATOMIC_BOOL;
let pool = BufferPool::<(int, uint)>::new(); let pool = BufferPool::<(int, uint)>::new();
let (w, s) = pool.deque(); let (w, s) = pool.deque();

View File

@@ -127,9 +127,9 @@ enum Flavor {
/// ```rust /// ```rust
/// use sync::mutex::{StaticMutex, MUTEX_INIT}; /// use sync::mutex::{StaticMutex, MUTEX_INIT};
/// ///
/// static mut LOCK: StaticMutex = MUTEX_INIT; /// static LOCK: StaticMutex = MUTEX_INIT;
/// ///
/// unsafe { /// {
/// let _g = LOCK.lock(); /// let _g = LOCK.lock();
/// // do some productive work /// // do some productive work
/// } /// }
@@ -536,7 +536,7 @@ mod test {
#[test] #[test]
fn smoke_static() { fn smoke_static() {
static mut m: StaticMutex = MUTEX_INIT; static m: StaticMutex = MUTEX_INIT;
unsafe { unsafe {
drop(m.lock()); drop(m.lock());
drop(m.lock()); drop(m.lock());
@@ -546,7 +546,7 @@ mod test {
#[test] #[test]
fn lots_and_lots() { fn lots_and_lots() {
static mut m: StaticMutex = MUTEX_INIT; static m: StaticMutex = MUTEX_INIT;
static mut CNT: uint = 0; static mut CNT: uint = 0;
static M: uint = 1000; static M: uint = 1000;
static N: uint = 3; static N: uint = 3;

View File

@@ -30,13 +30,11 @@ use mutex::{StaticMutex, MUTEX_INIT};
/// ```rust /// ```rust
/// use sync::one::{Once, ONCE_INIT}; /// use sync::one::{Once, ONCE_INIT};
/// ///
/// static mut START: Once = ONCE_INIT; /// static START: Once = ONCE_INIT;
/// ///
/// unsafe {
/// START.doit(|| { /// START.doit(|| {
/// // run initialization here /// // run initialization here
/// }); /// });
/// }
/// ``` /// ```
pub struct Once { pub struct Once {
mutex: StaticMutex, mutex: StaticMutex,
@@ -128,17 +126,17 @@ mod test {
#[test] #[test]
fn smoke_once() { fn smoke_once() {
static mut o: Once = ONCE_INIT; static o: Once = ONCE_INIT;
let mut a = 0i; let mut a = 0i;
unsafe { o.doit(|| a += 1); } o.doit(|| a += 1);
assert_eq!(a, 1); assert_eq!(a, 1);
unsafe { o.doit(|| a += 1); } o.doit(|| a += 1);
assert_eq!(a, 1); assert_eq!(a, 1);
} }
#[test] #[test]
fn stampede_once() { fn stampede_once() {
static mut o: Once = ONCE_INIT; static o: Once = ONCE_INIT;
static mut run: bool = false; static mut run: bool = false;
let (tx, rx) = channel(); let (tx, rx) = channel();

View File

@@ -192,7 +192,7 @@ pub fn precise_time_ns() -> u64 {
fn os_precise_time_ns() -> u64 { fn os_precise_time_ns() -> u64 {
static mut TIMEBASE: libc::mach_timebase_info = libc::mach_timebase_info { numer: 0, static mut TIMEBASE: libc::mach_timebase_info = libc::mach_timebase_info { numer: 0,
denom: 0 }; denom: 0 };
static mut ONCE: std::sync::Once = std::sync::ONCE_INIT; static ONCE: std::sync::Once = std::sync::ONCE_INIT;
unsafe { unsafe {
ONCE.doit(|| { ONCE.doit(|| {
imp::mach_timebase_info(&mut TIMEBASE); imp::mach_timebase_info(&mut TIMEBASE);

View File

@@ -1,3 +1,12 @@
S 2014-10-10 78a7676
freebsd-x86_64 511061af382e2e837a6d615823e1a952e8281483
linux-i386 0644637db852db8a6c603ded0531ccaa60291bd3
linux-x86_64 656b8c23fbb97794e85973aca725a4b9cd07b29e
macos-i386 e4d9709fcfe485fcca00f0aa1fe456e2f164ed96
macos-x86_64 6b1aa5a441965da87961be81950e8663eadba377
winnt-i386 b87f8f040adb464e9f8455a37de8582e9e2c8cf3
winnt-x86_64 b883264902ac0585a80175ba27dc141f5c4f8618
S 2014-10-04 749ff5e S 2014-10-04 749ff5e
freebsd-x86_64 f39d94487d29b3d48217b1295ad2cda8c941e694 freebsd-x86_64 f39d94487d29b3d48217b1295ad2cda8c941e694
linux-i386 555aca74f9a268f80cab2df1147dc6406403e9e4 linux-i386 555aca74f9a268f80cab2df1147dc6406403e9e4