From 576e36e674d645cd4682cf2df43fb25c3d1a71d4 Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Sun, 23 Mar 2014 11:37:31 +0100 Subject: [PATCH] Register new snapshots --- src/driver/driver.rs | 4 - src/libarena/lib.rs | 1 - src/libcollections/lib.rs | 1 - src/libgreen/lib.rs | 1 - src/libnative/lib.rs | 1 - src/librand/lib.rs | 1 - src/librustc/lib.rs | 1 - src/librustuv/lib.rs | 1 - src/libserialize/lib.rs | 1 - src/libstd/intrinsics.rs | 83 --- src/libstd/kinds.rs | 10 - src/libstd/lib.rs | 4 - src/libstd/sync/atomics_stage0.rs | 930 ------------------------------ src/libstd/sync/mod.rs | 4 - src/libstd/ty.rs | 11 - src/libsync/arc.rs | 5 +- src/libsync/lib.rs | 1 - src/libsyntax/lib.rs | 1 - src/libterm/lib.rs | 1 - src/libuuid/lib.rs | 4 - src/snapshots.txt | 8 + 21 files changed, 9 insertions(+), 1065 deletions(-) delete mode 100644 src/libstd/sync/atomics_stage0.rs diff --git a/src/driver/driver.rs b/src/driver/driver.rs index bd7096cda03..5fd08793ce7 100644 --- a/src/driver/driver.rs +++ b/src/driver/driver.rs @@ -8,10 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[no_uv]; // remove this after stage0 -#[allow(attribute_usage)]; // remove this after stage0 -extern crate native; // remove this after stage0 - #[cfg(rustdoc)] extern crate this = "rustdoc"; diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index bba81e5118c..94e340368fe 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -24,7 +24,6 @@ html_root_url = "http://static.rust-lang.org/doc/master")]; #[allow(missing_doc)]; #[feature(managed_boxes)]; -#[allow(deprecated_owned_vector)]; // NOTE: remove after stage0 extern crate collections; diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index ec57173ff19..fba85b05231 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -21,7 +21,6 @@ html_root_url = "http://static.rust-lang.org/doc/master")]; #[feature(macro_rules, managed_boxes, default_type_params, phase)]; -#[allow(deprecated_owned_vector)]; // NOTE: remove after stage0 extern crate rand; diff --git a/src/libgreen/lib.rs b/src/libgreen/lib.rs index 926b9028a7a..d586d08bd0d 100644 --- a/src/libgreen/lib.rs +++ b/src/libgreen/lib.rs @@ -174,7 +174,6 @@ // NB this does *not* include globs, please keep it that way. #[feature(macro_rules, phase)]; #[allow(visible_private_types)]; -#[allow(deprecated_owned_vector)]; // NOTE: remove after stage0 #[cfg(test)] #[phase(syntax, link)] extern crate log; extern crate rand; diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs index afe440cc1e0..da8f2ea139d 100644 --- a/src/libnative/lib.rs +++ b/src/libnative/lib.rs @@ -50,7 +50,6 @@ html_root_url = "http://static.rust-lang.org/doc/master")]; #[deny(unused_result, unused_must_use)]; #[allow(non_camel_case_types)]; -#[allow(deprecated_owned_vector)]; // NOTE: remove after stage0 // NB this crate explicitly does *not* allow glob imports, please seriously // consider whether they're needed before adding that feature here (the diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 1d0070ea477..357363597d9 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -71,7 +71,6 @@ println!("{:?}", tuple_ptr) html_root_url = "http://static.rust-lang.org/doc/master")]; #[feature(macro_rules, managed_boxes, phase)]; -#[allow(deprecated_owned_vector)]; // NOTE: remove after stage0 #[cfg(test)] #[phase(syntax, link)] extern crate log; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index b3e40bd71f3..6aff1530104 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -30,7 +30,6 @@ This API is completely unstable and subject to change. #[allow(deprecated)]; #[feature(macro_rules, globs, struct_variant, managed_boxes, quote, default_type_params, phase)]; -#[allow(deprecated_owned_vector)]; // NOTE: remove after stage0 extern crate flate; extern crate arena; diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index 42ccdaf9562..82ca84190f7 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.rs @@ -42,7 +42,6 @@ via `close` and `delete` methods. #[feature(macro_rules)]; #[deny(unused_result, unused_must_use)]; #[allow(visible_private_types)]; -#[allow(deprecated_owned_vector)]; // NOTE: remove after stage0 #[cfg(test)] extern crate green; #[cfg(test)] extern crate realrustuv = "rustuv"; diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index ad2e741f782..8a5829da9d6 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -22,7 +22,6 @@ Core encoding and decoding interfaces. html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://static.rust-lang.org/doc/master")]; #[feature(macro_rules, managed_boxes, default_type_params, phase)]; -#[allow(deprecated_owned_vector)]; // NOTE: remove after stage0 // test harness access #[cfg(test)] diff --git a/src/libstd/intrinsics.rs b/src/libstd/intrinsics.rs index 95607bd8f79..78e3df4b6f8 100644 --- a/src/libstd/intrinsics.rs +++ b/src/libstd/intrinsics.rs @@ -164,90 +164,7 @@ pub trait TyVisitor { fn visit_self(&mut self) -> bool; } -#[cfg(stage0)] -extern "rust-intrinsic" { - pub fn atomic_cxchg(dst: &mut T, old: T, src: T) -> T; - pub fn atomic_cxchg_acq(dst: &mut T, old: T, src: T) -> T; - pub fn atomic_cxchg_rel(dst: &mut T, old: T, src: T) -> T; - pub fn atomic_cxchg_acqrel(dst: &mut T, old: T, src: T) -> T; - pub fn atomic_cxchg_relaxed(dst: &mut T, old: T, src: T) -> T; - pub fn atomic_load(src: &T) -> T; - pub fn atomic_load_acq(src: &T) -> T; - pub fn atomic_load_relaxed(src: &T) -> T; - - pub fn atomic_store(dst: &mut T, val: T); - pub fn atomic_store_rel(dst: &mut T, val: T); - pub fn atomic_store_relaxed(dst: &mut T, val: T); - - pub fn atomic_xchg(dst: &mut T, src: T) -> T; - pub fn atomic_xchg_acq(dst: &mut T, src: T) -> T; - pub fn atomic_xchg_rel(dst: &mut T, src: T) -> T; - pub fn atomic_xchg_acqrel(dst: &mut T, src: T) -> T; - pub fn atomic_xchg_relaxed(dst: &mut T, src: T) -> T; - - pub fn atomic_xadd(dst: &mut T, src: T) -> T; - pub fn atomic_xadd_acq(dst: &mut T, src: T) -> T; - pub fn atomic_xadd_rel(dst: &mut T, src: T) -> T; - pub fn atomic_xadd_acqrel(dst: &mut T, src: T) -> T; - pub fn atomic_xadd_relaxed(dst: &mut T, src: T) -> T; - - pub fn atomic_xsub(dst: &mut T, src: T) -> T; - pub fn atomic_xsub_acq(dst: &mut T, src: T) -> T; - pub fn atomic_xsub_rel(dst: &mut T, src: T) -> T; - pub fn atomic_xsub_acqrel(dst: &mut T, src: T) -> T; - pub fn atomic_xsub_relaxed(dst: &mut T, src: T) -> T; - - pub fn atomic_and(dst: &mut T, src: T) -> T; - pub fn atomic_and_acq(dst: &mut T, src: T) -> T; - pub fn atomic_and_rel(dst: &mut T, src: T) -> T; - pub fn atomic_and_acqrel(dst: &mut T, src: T) -> T; - pub fn atomic_and_relaxed(dst: &mut T, src: T) -> T; - - pub fn atomic_nand(dst: &mut T, src: T) -> T; - pub fn atomic_nand_acq(dst: &mut T, src: T) -> T; - pub fn atomic_nand_rel(dst: &mut T, src: T) -> T; - pub fn atomic_nand_acqrel(dst: &mut T, src: T) -> T; - pub fn atomic_nand_relaxed(dst: &mut T, src: T) -> T; - - pub fn atomic_or(dst: &mut T, src: T) -> T; - pub fn atomic_or_acq(dst: &mut T, src: T) -> T; - pub fn atomic_or_rel(dst: &mut T, src: T) -> T; - pub fn atomic_or_acqrel(dst: &mut T, src: T) -> T; - pub fn atomic_or_relaxed(dst: &mut T, src: T) -> T; - - pub fn atomic_xor(dst: &mut T, src: T) -> T; - pub fn atomic_xor_acq(dst: &mut T, src: T) -> T; - pub fn atomic_xor_rel(dst: &mut T, src: T) -> T; - pub fn atomic_xor_acqrel(dst: &mut T, src: T) -> T; - pub fn atomic_xor_relaxed(dst: &mut T, src: T) -> T; - - pub fn atomic_max(dst: &mut T, src: T) -> T; - pub fn atomic_max_acq(dst: &mut T, src: T) -> T; - pub fn atomic_max_rel(dst: &mut T, src: T) -> T; - pub fn atomic_max_acqrel(dst: &mut T, src: T) -> T; - pub fn atomic_max_relaxed(dst: &mut T, src: T) -> T; - - pub fn atomic_min(dst: &mut T, src: T) -> T; - pub fn atomic_min_acq(dst: &mut T, src: T) -> T; - pub fn atomic_min_rel(dst: &mut T, src: T) -> T; - pub fn atomic_min_acqrel(dst: &mut T, src: T) -> T; - pub fn atomic_min_relaxed(dst: &mut T, src: T) -> T; - - pub fn atomic_umin(dst: &mut T, src: T) -> T; - pub fn atomic_umin_acq(dst: &mut T, src: T) -> T; - pub fn atomic_umin_rel(dst: &mut T, src: T) -> T; - pub fn atomic_umin_acqrel(dst: &mut T, src: T) -> T; - pub fn atomic_umin_relaxed(dst: &mut T, src: T) -> T; - - pub fn atomic_umax(dst: &mut T, src: T) -> T; - pub fn atomic_umax_acq(dst: &mut T, src: T) -> T; - pub fn atomic_umax_rel(dst: &mut T, src: T) -> T; - pub fn atomic_umax_acqrel(dst: &mut T, src: T) -> T; - pub fn atomic_umax_relaxed(dst: &mut T, src: T) -> T; -} - -#[cfg(not(stage0))] extern "rust-intrinsic" { // NB: These intrinsics take unsafe pointers because they mutate aliased diff --git a/src/libstd/kinds.rs b/src/libstd/kinds.rs index c0a442a6141..2ce41a33c29 100644 --- a/src/libstd/kinds.rs +++ b/src/libstd/kinds.rs @@ -41,16 +41,6 @@ pub trait Pod { } /// Types that can be safely shared between threads, hence thread-safe. -#[cfg(stage0)] -pub trait Share { - // Empty -} - -#[cfg(stage0)] -impl Share for T {} - -/// Types that can be safely shared between threads, hence thread-safe. -#[cfg(not(stage0))] #[lang="share"] pub trait Share { // Empty diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 8a890d0293c..021a932fc8b 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -58,7 +58,6 @@ #[no_std]; #[deny(missing_doc)]; -#[allow(deprecated_owned_vector)]; // NOTE: remove after stage0 // When testing libstd, bring in libuv as the I/O backend so tests can print // things and all of the std::io tests have an I/O interface to run on top @@ -78,9 +77,6 @@ #[cfg(test)] pub use cmp = realstd::cmp; #[cfg(test)] pub use ty = realstd::ty; -#[cfg(stage0)] -pub use vec_ng = vec; - // Run tests with libgreen instead of libnative. // // FIXME: This egregiously hacks around starting the test runner in a different diff --git a/src/libstd/sync/atomics_stage0.rs b/src/libstd/sync/atomics_stage0.rs deleted file mode 100644 index b501972532d..00000000000 --- a/src/libstd/sync/atomics_stage0.rs +++ /dev/null @@ -1,930 +0,0 @@ -// Copyright 2012-2013 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Atomic types -//! -//! Atomic types provide primitive shared-memory communication between -//! threads, and are the building blocks of other concurrent -//! types. -//! -//! This module defines atomic versions of a select number of primitive -//! types, including `AtomicBool`, `AtomicInt`, `AtomicUint`, and `AtomicOption`. -//! Atomic types present operations that, when used correctly, synchronize -//! updates between threads. -//! -//! Each method takes an `Ordering` which represents the strength of -//! the memory barrier for that operation. These orderings are the -//! same as [C++11 atomic orderings][1]. -//! -//! [1]: http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync -//! -//! Atomic variables are safe to share between threads (they implement `Share`) -//! but they do not themselves provide the mechanism for sharing. The most -//! common way to share an atomic variable is to put it into an `Arc` (an -//! atomically-reference-counted shared pointer). -//! -//! Most atomic types may be stored in static variables, initialized using -//! the provided static initializers like `INIT_ATOMIC_BOOL`. Atomic statics -//! are often used for lazy global initialization. -//! -//! -//! # Examples -//! -//! A simple spinlock: -//! -//! ```ignore -//! # // FIXME: Needs PR #12430 -//! extern crate sync; -//! -//! use sync::Arc; -//! use std::sync::atomics::{AtomicUint, SeqCst}; -//! use std::task::deschedule; -//! -//! fn main() { -//! let spinlock = Arc::new(AtomicUint::new(1)); -//! -//! let spinlock_clone = spinlock.clone(); -//! spawn(proc() { -//! spinlock_clone.store(0, SeqCst); -//! }); -//! -//! // Wait for the other task to release the lock -//! while spinlock.load(SeqCst) != 0 { -//! // Since tasks may not be preemptive (if they are green threads) -//! // yield to the scheduler to let the other task run. Low level -//! // concurrent code needs to take into account Rust's two threading -//! // models. -//! deschedule(); -//! } -//! } -//! ``` -//! -//! Transferring a heap object with `AtomicOption`: -//! -//! ```ignore -//! # // FIXME: Needs PR #12430 -//! extern crate sync; -//! -//! use sync::Arc; -//! use std::sync::atomics::{AtomicOption, SeqCst}; -//! -//! fn main() { -//! struct BigObject; -//! -//! let shared_big_object = Arc::new(AtomicOption::empty()); -//! -//! let shared_big_object_clone = shared_big_object.clone(); -//! spawn(proc() { -//! let unwrapped_big_object = shared_big_object_clone.take(SeqCst); -//! if unwrapped_big_object.is_some() { -//! println!("got a big object from another task"); -//! } else { -//! println!("other task hasn't sent big object yet"); -//! } -//! }); -//! -//! shared_big_object.swap(~BigObject, SeqCst); -//! } -//! ``` -//! -//! Keep a global count of live tasks: -//! -//! ``` -//! use std::sync::atomics::{AtomicUint, SeqCst, INIT_ATOMIC_UINT}; -//! -//! static mut GLOBAL_TASK_COUNT: AtomicUint = INIT_ATOMIC_UINT; -//! -//! unsafe { -//! let old_task_count = GLOBAL_TASK_COUNT.fetch_add(1, SeqCst); -//! println!("live tasks: {}", old_task_count + 1); -//! } -//! ``` - -#[allow(missing_doc)]; - -use intrinsics; -use cast; -use std::kinds::marker; -use option::{Option,Some,None}; -use ops::Drop; -use ty::Unsafe; - -/// An atomic boolean type. -pub struct AtomicBool { - priv v: Unsafe, - priv nopod: marker::NoPod -} - -/// A signed atomic integer type, supporting basic atomic arithmetic operations -pub struct AtomicInt { - priv v: Unsafe, - priv nopod: marker::NoPod -} - -/// An unsigned atomic integer type, supporting basic atomic arithmetic operations -pub struct AtomicUint { - priv v: Unsafe, - priv nopod: marker::NoPod -} - -/// An unsigned atomic integer type that is forced to be 64-bits. This does not -/// support all operations. -pub struct AtomicU64 { - priv v: Unsafe, - priv nopod: marker::NoPod -} - -/// An unsafe atomic pointer. Only supports basic atomic operations -pub struct AtomicPtr { - priv p: Unsafe, - priv nopod: marker::NoPod -} - -/// An atomic, nullable unique pointer -/// -/// This can be used as the concurrency primitive for operations that transfer -/// owned heap objects across tasks. -#[unsafe_no_drop_flag] -pub struct AtomicOption { - priv p: Unsafe, -} - -/// Atomic memory orderings -/// -/// Memory orderings limit the ways that both the compiler and CPU may reorder -/// instructions around atomic operations. At its most restrictive, -/// "sequentially consistent" atomics allow neither reads nor writes -/// to be moved either before or after the atomic operation; on the other end -/// "relaxed" atomics allow all reorderings. -/// -/// Rust's memory orderings are the same as in C++[1]. -/// -/// [1]: http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync -pub enum Ordering { - /// No ordering constraints, only atomic operations - Relaxed, - /// When coupled with a store, all previous writes become visible - /// to another thread that performs a load with `Acquire` ordering - /// on the same value - Release, - /// When coupled with a load, all subsequent loads will see data - /// written before a store with `Release` ordering on the same value - /// in another thread - Acquire, - /// When coupled with a load, uses `Acquire` ordering, and with a store - /// `Release` ordering - AcqRel, - /// Like `AcqRel` with the additional guarantee that all threads see all - /// sequentially consistent operations in the same order. - SeqCst -} - -/// An `AtomicBool` initialized to `false` -pub static INIT_ATOMIC_BOOL : AtomicBool = AtomicBool { v: Unsafe{value: 0, - marker1: marker::InvariantType}, - nopod: marker::NoPod }; -/// An `AtomicInt` initialized to `0` -pub static INIT_ATOMIC_INT : AtomicInt = AtomicInt { v: Unsafe{value: 0, - marker1: marker::InvariantType}, - nopod: marker::NoPod }; -/// An `AtomicUint` initialized to `0` -pub static INIT_ATOMIC_UINT : AtomicUint = AtomicUint { v: Unsafe{value: 0, - marker1: marker::InvariantType}, - nopod: marker::NoPod }; -/// An `AtomicU64` initialized to `0` -pub static INIT_ATOMIC_U64 : AtomicU64 = AtomicU64 { v: Unsafe{value: 0, - marker1: marker::InvariantType}, - nopod: marker::NoPod }; - - -// NB: Needs to be -1 (0b11111111...) to make fetch_nand work correctly -static UINT_TRUE: uint = -1; - -impl AtomicBool { - /// Create a new `AtomicBool` - pub fn new(v: bool) -> AtomicBool { - let val = if v { UINT_TRUE } else { 0 }; - AtomicBool { v: Unsafe::new(val), nopod: marker::NoPod } - } - - /// Load the value - #[inline] - pub fn load(&self, order: Ordering) -> bool { - unsafe { atomic_load(&*self.v.get(), order) > 0 } - } - - /// Store the value - #[inline] - pub fn store(&mut self, val: bool, order: Ordering) { - let val = if val { UINT_TRUE } else { 0 }; - - unsafe { atomic_store(&mut *self.v.get(), val, order); } - } - - /// Store a value, returning the old value - #[inline] - pub fn swap(&mut self, val: bool, order: Ordering) -> bool { - let val = if val { UINT_TRUE } else { 0 }; - - unsafe { atomic_swap(&mut *self.v.get(), val, order) > 0 } - } - - /// If the current value is the same as expected, store a new value - /// - /// Compare the current value with `old`; if they are the same then - /// replace the current value with `new`. Return the previous value. - /// If the return value is equal to `old` then the value was updated. - /// - /// # Examples - /// - /// ```ignore - /// # // FIXME: Needs PR #12430 - /// extern crate sync; - /// - /// use sync::Arc; - /// use std::sync::atomics::{AtomicBool, SeqCst}; - /// - /// fn main() { - /// let spinlock = Arc::new(AtomicBool::new(false)); - /// let spinlock_clone = spin_lock.clone(); - /// - /// spawn(proc() { - /// with_lock(&spinlock, || println!("task 1 in lock")); - /// }); - /// - /// spawn(proc() { - /// with_lock(&spinlock_clone, || println!("task 2 in lock")); - /// }); - /// } - /// - /// fn with_lock(spinlock: &Arc, f: || -> ()) { - /// // CAS loop until we are able to replace `false` with `true` - /// while spinlock.compare_and_swap(false, true, SeqCst) == false { - /// // Since tasks may not be preemptive (if they are green threads) - /// // yield to the scheduler to let the other task run. Low level - /// // concurrent code needs to take into account Rust's two threading - /// // models. - /// deschedule(); - /// } - /// - /// // Now we have the spinlock - /// f(); - /// - /// // Release the lock - /// spinlock.store(false); - /// } - /// ``` - #[inline] - pub fn compare_and_swap(&mut self, old: bool, new: bool, order: Ordering) -> bool { - let old = if old { UINT_TRUE } else { 0 }; - let new = if new { UINT_TRUE } else { 0 }; - - unsafe { atomic_compare_and_swap(&mut *self.v.get(), old, new, order) > 0 } - } - - /// A logical "and" operation - /// - /// Performs a logical "and" operation on the current value and the - /// argument `val`, and sets the new value to the result. - /// Returns the previous value. - /// - /// # Examples - /// - /// ``` - /// use std::sync::atomics::{AtomicBool, SeqCst}; - /// - /// let mut foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_and(false, SeqCst)); - /// assert_eq!(false, foo.load(SeqCst)); - /// - /// let mut foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_and(true, SeqCst)); - /// assert_eq!(true, foo.load(SeqCst)); - /// - /// let mut foo = AtomicBool::new(false); - /// assert_eq!(false, foo.fetch_and(false, SeqCst)); - /// assert_eq!(false, foo.load(SeqCst)); - /// ``` - #[inline] - pub fn fetch_and(&mut self, val: bool, order: Ordering) -> bool { - let val = if val { UINT_TRUE } else { 0 }; - - unsafe { atomic_and(&mut *self.v.get(), val, order) > 0 } - } - - /// A logical "nand" operation - /// - /// Performs a logical "nand" operation on the current value and the - /// argument `val`, and sets the new value to the result. - /// Returns the previous value. - /// - /// # Examples - /// - /// ``` - /// use std::sync::atomics::{AtomicBool, SeqCst}; - /// - /// let mut foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_nand(false, SeqCst)); - /// assert_eq!(true, foo.load(SeqCst)); - /// - /// let mut foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_nand(true, SeqCst)); - /// assert_eq!(0, foo.load(SeqCst) as int); - /// assert_eq!(false, foo.load(SeqCst)); - /// - /// let mut foo = AtomicBool::new(false); - /// assert_eq!(false, foo.fetch_nand(false, SeqCst)); - /// assert_eq!(true, foo.load(SeqCst)); - /// ``` - #[inline] - pub fn fetch_nand(&mut self, val: bool, order: Ordering) -> bool { - let val = if val { UINT_TRUE } else { 0 }; - - unsafe { atomic_nand(&mut *self.v.get(), val, order) > 0 } - } - - /// A logical "or" operation - /// - /// Performs a logical "or" operation on the current value and the - /// argument `val`, and sets the new value to the result. - /// Returns the previous value. - /// - /// # Examples - /// - /// ``` - /// use std::sync::atomics::{AtomicBool, SeqCst}; - /// - /// let mut foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_or(false, SeqCst)); - /// assert_eq!(true, foo.load(SeqCst)); - /// - /// let mut foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_or(true, SeqCst)); - /// assert_eq!(true, foo.load(SeqCst)); - /// - /// let mut foo = AtomicBool::new(false); - /// assert_eq!(false, foo.fetch_or(false, SeqCst)); - /// assert_eq!(false, foo.load(SeqCst)); - /// ``` - #[inline] - pub fn fetch_or(&mut self, val: bool, order: Ordering) -> bool { - let val = if val { UINT_TRUE } else { 0 }; - - unsafe { atomic_or(&mut *self.v.get(), val, order) > 0 } - } - - /// A logical "xor" operation - /// - /// Performs a logical "xor" operation on the current value and the - /// argument `val`, and sets the new value to the result. - /// Returns the previous value. - /// - /// # Examples - /// - /// ``` - /// use std::sync::atomics::{AtomicBool, SeqCst}; - /// - /// let mut foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_xor(false, SeqCst)); - /// assert_eq!(true, foo.load(SeqCst)); - /// - /// let mut foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_xor(true, SeqCst)); - /// assert_eq!(false, foo.load(SeqCst)); - /// - /// let mut foo = AtomicBool::new(false); - /// assert_eq!(false, foo.fetch_xor(false, SeqCst)); - /// assert_eq!(false, foo.load(SeqCst)); - /// ``` - #[inline] - pub fn fetch_xor(&mut self, val: bool, order: Ordering) -> bool { - let val = if val { UINT_TRUE } else { 0 }; - - unsafe { atomic_xor(&mut *self.v.get(), val, order) > 0 } - } -} - -impl AtomicInt { - /// Create a new `AtomicInt` - pub fn new(v: int) -> AtomicInt { - AtomicInt {v: Unsafe::new(v), nopod: marker::NoPod} - } - - /// Load the value - #[inline] - pub fn load(&self, order: Ordering) -> int { - unsafe { atomic_load(&*self.v.get(), order) } - } - - /// Store the value - #[inline] - pub fn store(&mut self, val: int, order: Ordering) { - unsafe { atomic_store(&mut *self.v.get(), val, order); } - } - - /// Store a value, returning the old value - #[inline] - pub fn swap(&mut self, val: int, order: Ordering) -> int { - unsafe { atomic_swap(&mut *self.v.get(), val, order) } - } - - /// If the current value is the same as expected, store a new value - /// - /// Compare the current value with `old`; if they are the same then - /// replace the current value with `new`. Return the previous value. - /// If the return value is equal to `old` then the value was updated. - #[inline] - pub fn compare_and_swap(&mut self, old: int, new: int, order: Ordering) -> int { - unsafe { atomic_compare_and_swap(&mut *self.v.get(), old, new, order) } - } - - /// Add to the current value, returning the previous - /// - /// # Examples - /// - /// ``` - /// use std::sync::atomics::{AtomicInt, SeqCst}; - /// - /// let mut foo = AtomicInt::new(0); - /// assert_eq!(0, foo.fetch_add(10, SeqCst)); - /// assert_eq!(10, foo.load(SeqCst)); - /// ``` - #[inline] - pub fn fetch_add(&mut self, val: int, order: Ordering) -> int { - unsafe { atomic_add(&mut *self.v.get(), val, order) } - } - - /// Subtract from the current value, returning the previous - /// - /// # Examples - /// - /// ``` - /// use std::sync::atomics::{AtomicInt, SeqCst}; - /// - /// let mut foo = AtomicInt::new(0); - /// assert_eq!(0, foo.fetch_sub(10, SeqCst)); - /// assert_eq!(-10, foo.load(SeqCst)); - /// ``` - #[inline] - pub fn fetch_sub(&mut self, val: int, order: Ordering) -> int { - unsafe { atomic_sub(&mut *self.v.get(), val, order) } - } -} - -// temporary workaround -// it causes link failure on MIPS target -// libgcc doesn't implement 64-bit atomic operations for MIPS32 -#[cfg(not(target_arch = "mips"))] -impl AtomicU64 { - pub fn new(v: u64) -> AtomicU64 { - AtomicU64 { v: Unsafe::new(v), nopod: marker::NoPod } - } - - #[inline] - pub fn load(&self, order: Ordering) -> u64 { - unsafe { atomic_load(&*self.v.get(), order) } - } - - #[inline] - pub fn store(&mut self, val: u64, order: Ordering) { - unsafe { atomic_store(&mut *self.v.get(), val, order); } - } - - #[inline] - pub fn swap(&mut self, val: u64, order: Ordering) -> u64 { - unsafe { atomic_swap(&mut *self.v.get(), val, order) } - } - - #[inline] - pub fn compare_and_swap(&mut self, old: u64, new: u64, order: Ordering) -> u64 { - unsafe { atomic_compare_and_swap(&mut *self.v.get(), old, new, order) } - } - - #[inline] - pub fn fetch_add(&mut self, val: u64, order: Ordering) -> u64 { - unsafe { atomic_add(&mut *self.v.get(), val, order) } - } - - #[inline] - pub fn fetch_sub(&mut self, val: u64, order: Ordering) -> u64 { - unsafe { atomic_sub(&mut *self.v.get(), val, order) } - } -} - -impl AtomicUint { - /// Create a new `AtomicUint` - pub fn new(v: uint) -> AtomicUint { - AtomicUint { v: Unsafe::new(v), nopod: marker::NoPod } - } - - /// Load the value - #[inline] - pub fn load(&self, order: Ordering) -> uint { - unsafe { atomic_load(&*self.v.get(), order) } - } - - /// Store the value - #[inline] - pub fn store(&mut self, val: uint, order: Ordering) { - unsafe { atomic_store(&mut *self.v.get(), val, order); } - } - - /// Store a value, returning the old value - #[inline] - pub fn swap(&mut self, val: uint, order: Ordering) -> uint { - unsafe { atomic_swap(&mut *self.v.get(), val, order) } - } - - /// If the current value is the same as expected, store a new value - /// - /// Compare the current value with `old`; if they are the same then - /// replace the current value with `new`. Return the previous value. - /// If the return value is equal to `old` then the value was updated. - #[inline] - pub fn compare_and_swap(&mut self, old: uint, new: uint, order: Ordering) -> uint { - unsafe { atomic_compare_and_swap(&mut *self.v.get(), old, new, order) } - } - - /// Add to the current value, returning the previous - /// - /// # Examples - /// - /// ``` - /// use std::sync::atomics::{AtomicUint, SeqCst}; - /// - /// let mut foo = AtomicUint::new(0); - /// assert_eq!(0, foo.fetch_add(10, SeqCst)); - /// assert_eq!(10, foo.load(SeqCst)); - /// ``` - #[inline] - pub fn fetch_add(&mut self, val: uint, order: Ordering) -> uint { - unsafe { atomic_add(&mut *self.v.get(), val, order) } - } - - /// Subtract from the current value, returning the previous - /// - /// # Examples - /// - /// ``` - /// use std::sync::atomics::{AtomicUint, SeqCst}; - /// - /// let mut foo = AtomicUint::new(10); - /// assert_eq!(10, foo.fetch_sub(10, SeqCst)); - /// assert_eq!(0, foo.load(SeqCst)); - /// ``` - #[inline] - pub fn fetch_sub(&mut self, val: uint, order: Ordering) -> uint { - unsafe { atomic_sub(&mut *self.v.get(), val, order) } - } -} - -impl AtomicPtr { - /// Create a new `AtomicPtr` - pub fn new(p: *mut T) -> AtomicPtr { - AtomicPtr { p: Unsafe::new(p as uint), nopod: marker::NoPod } - } - - /// Load the value - #[inline] - pub fn load(&self, order: Ordering) -> *mut T { - unsafe { - atomic_load(&*self.p.get(), order) as *mut T - } - } - - /// Store the value - #[inline] - pub fn store(&mut self, ptr: *mut T, order: Ordering) { - unsafe { atomic_store(&mut *self.p.get(), ptr as uint, order); } - } - - /// Store a value, returning the old value - #[inline] - pub fn swap(&mut self, ptr: *mut T, order: Ordering) -> *mut T { - unsafe { atomic_swap(&mut *self.p.get(), ptr as uint, order) as *mut T } - } - - /// If the current value is the same as expected, store a new value - /// - /// Compare the current value with `old`; if they are the same then - /// replace the current value with `new`. Return the previous value. - /// If the return value is equal to `old` then the value was updated. - #[inline] - pub fn compare_and_swap(&mut self, old: *mut T, new: *mut T, order: Ordering) -> *mut T { - unsafe { - atomic_compare_and_swap(&mut *self.p.get(), old as uint, - new as uint, order) as *mut T - } - } -} - -impl AtomicOption { - /// Create a new `AtomicOption` - pub fn new(p: ~T) -> AtomicOption { - unsafe { AtomicOption { p: Unsafe::new(cast::transmute(p)) } } - } - - /// Create a new `AtomicOption` that doesn't contain a value - pub fn empty() -> AtomicOption { AtomicOption { p: Unsafe::new(0) } } - - /// Store a value, returning the old value - #[inline] - pub fn swap(&mut self, val: ~T, order: Ordering) -> Option<~T> { - unsafe { - let val = cast::transmute(val); - - let p = atomic_swap(&mut *self.p.get(), val, order); - if p as uint == 0 { - None - } else { - Some(cast::transmute(p)) - } - } - } - - /// Remove the value, leaving the `AtomicOption` empty. - #[inline] - pub fn take(&mut self, order: Ordering) -> Option<~T> { - unsafe { self.swap(cast::transmute(0), order) } - } - - /// Replace an empty value with a non-empty value. - /// - /// Succeeds if the option is `None` and returns `None` if so. If - /// the option was already `Some`, returns `Some` of the rejected - /// value. - #[inline] - pub fn fill(&mut self, val: ~T, order: Ordering) -> Option<~T> { - unsafe { - let val = cast::transmute(val); - let expected = cast::transmute(0); - let oldval = atomic_compare_and_swap(&mut *self.p.get(), expected, val, order); - if oldval == expected { - None - } else { - Some(cast::transmute(val)) - } - } - } - - /// Returns `true` if the `AtomicOption` is empty. - /// - /// Be careful: The caller must have some external method of ensuring the - /// result does not get invalidated by another task after this returns. - #[inline] - pub fn is_empty(&mut self, order: Ordering) -> bool { - unsafe { atomic_load(&*self.p.get(), order) as uint == 0 } - } -} - -#[unsafe_destructor] -impl Drop for AtomicOption { - fn drop(&mut self) { - let _ = self.take(SeqCst); - } -} - -#[inline] -pub unsafe fn atomic_store(dst: &mut T, val: T, order:Ordering) { - match order { - Release => intrinsics::atomic_store_rel(dst, val), - Relaxed => intrinsics::atomic_store_relaxed(dst, val), - _ => intrinsics::atomic_store(dst, val) - } -} - -#[inline] -pub unsafe fn atomic_load(dst: &T, order:Ordering) -> T { - match order { - Acquire => intrinsics::atomic_load_acq(dst), - Relaxed => intrinsics::atomic_load_relaxed(dst), - _ => intrinsics::atomic_load(dst) - } -} - -#[inline] -pub unsafe fn atomic_swap(dst: &mut T, val: T, order: Ordering) -> T { - match order { - Acquire => intrinsics::atomic_xchg_acq(dst, val), - Release => intrinsics::atomic_xchg_rel(dst, val), - AcqRel => intrinsics::atomic_xchg_acqrel(dst, val), - Relaxed => intrinsics::atomic_xchg_relaxed(dst, val), - _ => intrinsics::atomic_xchg(dst, val) - } -} - -/// Returns the old value (like __sync_fetch_and_add). -#[inline] -pub unsafe fn atomic_add(dst: &mut T, val: T, order: Ordering) -> T { - match order { - Acquire => intrinsics::atomic_xadd_acq(dst, val), - Release => intrinsics::atomic_xadd_rel(dst, val), - AcqRel => intrinsics::atomic_xadd_acqrel(dst, val), - Relaxed => intrinsics::atomic_xadd_relaxed(dst, val), - _ => intrinsics::atomic_xadd(dst, val) - } -} - -/// Returns the old value (like __sync_fetch_and_sub). -#[inline] -pub unsafe fn atomic_sub(dst: &mut T, val: T, order: Ordering) -> T { - match order { - Acquire => intrinsics::atomic_xsub_acq(dst, val), - Release => intrinsics::atomic_xsub_rel(dst, val), - AcqRel => intrinsics::atomic_xsub_acqrel(dst, val), - Relaxed => intrinsics::atomic_xsub_relaxed(dst, val), - _ => intrinsics::atomic_xsub(dst, val) - } -} - -#[inline] -pub unsafe fn atomic_compare_and_swap(dst:&mut T, old:T, new:T, order: Ordering) -> T { - match order { - Acquire => intrinsics::atomic_cxchg_acq(dst, old, new), - Release => intrinsics::atomic_cxchg_rel(dst, old, new), - AcqRel => intrinsics::atomic_cxchg_acqrel(dst, old, new), - Relaxed => intrinsics::atomic_cxchg_relaxed(dst, old, new), - _ => intrinsics::atomic_cxchg(dst, old, new), - } -} - -#[inline] -pub unsafe fn atomic_and(dst: &mut T, val: T, order: Ordering) -> T { - match order { - Acquire => intrinsics::atomic_and_acq(dst, val), - Release => intrinsics::atomic_and_rel(dst, val), - AcqRel => intrinsics::atomic_and_acqrel(dst, val), - Relaxed => intrinsics::atomic_and_relaxed(dst, val), - _ => intrinsics::atomic_and(dst, val) - } -} - -#[inline] -pub unsafe fn atomic_nand(dst: &mut T, val: T, order: Ordering) -> T { - match order { - Acquire => intrinsics::atomic_nand_acq(dst, val), - Release => intrinsics::atomic_nand_rel(dst, val), - AcqRel => intrinsics::atomic_nand_acqrel(dst, val), - Relaxed => intrinsics::atomic_nand_relaxed(dst, val), - _ => intrinsics::atomic_nand(dst, val) - } -} - - -#[inline] -pub unsafe fn atomic_or(dst: &mut T, val: T, order: Ordering) -> T { - match order { - Acquire => intrinsics::atomic_or_acq(dst, val), - Release => intrinsics::atomic_or_rel(dst, val), - AcqRel => intrinsics::atomic_or_acqrel(dst, val), - Relaxed => intrinsics::atomic_or_relaxed(dst, val), - _ => intrinsics::atomic_or(dst, val) - } -} - - -#[inline] -pub unsafe fn atomic_xor(dst: &mut T, val: T, order: Ordering) -> T { - match order { - Acquire => intrinsics::atomic_xor_acq(dst, val), - Release => intrinsics::atomic_xor_rel(dst, val), - AcqRel => intrinsics::atomic_xor_acqrel(dst, val), - Relaxed => intrinsics::atomic_xor_relaxed(dst, val), - _ => intrinsics::atomic_xor(dst, val) - } -} - - -/// An atomic fence. -/// -/// A fence 'A' which has `Release` ordering semantics, synchronizes with a -/// fence 'B' with (at least) `Acquire` semantics, if and only if there exists -/// atomic operations X and Y, both operating on some atomic object 'M' such -/// that A is sequenced before X, Y is synchronized before B and Y observers -/// the change to M. This provides a happens-before dependence between A and B. -/// -/// Atomic operations with `Release` or `Acquire` semantics can also synchronize -/// with a fence. -/// -/// A fence with has `SeqCst` ordering, in addition to having both `Acquire` and -/// `Release` semantics, participates in the global program order of the other -/// `SeqCst` operations and/or fences. -/// -/// Accepts `Acquire`, `Release`, `AcqRel` and `SeqCst` orderings. -/// -/// # Failure -/// -/// Fails if `order` is `Relaxed` -#[inline] -pub fn fence(order: Ordering) { - unsafe { - match order { - Acquire => intrinsics::atomic_fence_acq(), - Release => intrinsics::atomic_fence_rel(), - AcqRel => intrinsics::atomic_fence_acqrel(), - SeqCst => intrinsics::atomic_fence(), - Relaxed => fail!("there is no such thing as a relaxed fence") - } - } -} - -#[cfg(test)] -mod test { - use option::*; - use super::*; - - #[test] - fn bool_() { - let mut a = AtomicBool::new(false); - assert_eq!(a.compare_and_swap(false, true, SeqCst), false); - assert_eq!(a.compare_and_swap(false, true, SeqCst), true); - - a.store(false, SeqCst); - assert_eq!(a.compare_and_swap(false, true, SeqCst), false); - } - - #[test] - fn option_empty() { - let mut option: AtomicOption<()> = AtomicOption::empty(); - assert!(option.is_empty(SeqCst)); - } - - #[test] - fn option_swap() { - let mut p = AtomicOption::new(~1); - let a = ~2; - - let b = p.swap(a, SeqCst); - - assert_eq!(b, Some(~1)); - assert_eq!(p.take(SeqCst), Some(~2)); - } - - #[test] - fn option_take() { - let mut p = AtomicOption::new(~1); - - assert_eq!(p.take(SeqCst), Some(~1)); - assert_eq!(p.take(SeqCst), None); - - let p2 = ~2; - p.swap(p2, SeqCst); - - assert_eq!(p.take(SeqCst), Some(~2)); - } - - #[test] - fn option_fill() { - let mut p = AtomicOption::new(~1); - assert!(p.fill(~2, SeqCst).is_some()); // should fail; shouldn't leak! - assert_eq!(p.take(SeqCst), Some(~1)); - - assert!(p.fill(~2, SeqCst).is_none()); // shouldn't fail - assert_eq!(p.take(SeqCst), Some(~2)); - } - - #[test] - fn bool_and() { - let mut a = AtomicBool::new(true); - assert_eq!(a.fetch_and(false, SeqCst),true); - assert_eq!(a.load(SeqCst),false); - } - - static mut S_BOOL : AtomicBool = INIT_ATOMIC_BOOL; - static mut S_INT : AtomicInt = INIT_ATOMIC_INT; - static mut S_UINT : AtomicUint = INIT_ATOMIC_UINT; - - #[test] - fn static_init() { - unsafe { - assert!(!S_BOOL.load(SeqCst)); - assert!(S_INT.load(SeqCst) == 0); - assert!(S_UINT.load(SeqCst) == 0); - } - } - - #[test] - fn different_sizes() { - unsafe { - let mut slot = 0u16; - assert_eq!(super::atomic_swap(&mut slot, 1, SeqCst), 0); - - let mut slot = 0u8; - assert_eq!(super::atomic_compare_and_swap(&mut slot, 1, 2, SeqCst), 0); - - let mut slot = 0u32; - assert_eq!(super::atomic_load(&mut slot, SeqCst), 0); - - let mut slot = 0u64; - super::atomic_store(&mut slot, 2, SeqCst); - } - } -} - diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs index 994d12b34e5..3213c538152 100644 --- a/src/libstd/sync/mod.rs +++ b/src/libstd/sync/mod.rs @@ -16,10 +16,6 @@ //! other types of concurrent primitives. pub mod arc; -#[cfg(stage0)] -#[path = "atomics_stage0.rs"] -pub mod atomics; -#[cfg(not(stage0))] pub mod atomics; pub mod deque; pub mod mpmc_bounded_queue; diff --git a/src/libstd/ty.rs b/src/libstd/ty.rs index 344235053f3..ae8be25205d 100644 --- a/src/libstd/ty.rs +++ b/src/libstd/ty.rs @@ -45,7 +45,6 @@ use kinds::marker; /// /// **NOTE:** Unsafe fields are public to allow static initializers. It is not recommended /// to access its fields directly, `get` should be used instead. -#[cfg(not(stage0))] #[lang="unsafe"] pub struct Unsafe { /// Wrapped value @@ -55,16 +54,6 @@ pub struct Unsafe { marker1: marker::InvariantType } -/// Unsafe type for stage0 -#[cfg(stage0)] -pub struct Unsafe { - /// Wrapped value - value: T, - - /// Invariance marker - marker1: marker::InvariantType -} - impl Unsafe { /// Static constructor diff --git a/src/libsync/arc.rs b/src/libsync/arc.rs index 57187e27323..0bc3b121a88 100644 --- a/src/libsync/arc.rs +++ b/src/libsync/arc.rs @@ -50,13 +50,10 @@ use sync; use sync::{Mutex, RWLock}; use std::cast; -use std::kinds::marker; +use std::kinds::{Share, marker}; use std::sync::arc::UnsafeArc; use std::task; -#[cfg(stage0)] -use std::kinds::Share; - /// As sync::condvar, a mechanism for unlock-and-descheduling and /// signaling, for use with the Arc types. pub struct ArcCondvar<'a> { diff --git a/src/libsync/lib.rs b/src/libsync/lib.rs index 5e97b92e738..70874a029ac 100644 --- a/src/libsync/lib.rs +++ b/src/libsync/lib.rs @@ -20,7 +20,6 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://static.rust-lang.org/doc/master")]; #[feature(phase)]; -#[allow(deprecated_owned_vector)]; // NOTE: remove after stage0 #[cfg(test)] #[phase(syntax, link)] extern crate log; diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 70fb96e4c5f..4de17dc598b 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -28,7 +28,6 @@ This API is completely unstable and subject to change. #[feature(macro_rules, globs, managed_boxes, default_type_params, phase, quote)]; -#[allow(deprecated_owned_vector)]; // NOTE: remove after stage0 #[allow(deprecated)]; extern crate serialize; diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index 3148c9233ff..126790bd46a 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -20,7 +20,6 @@ html_root_url = "http://static.rust-lang.org/doc/master")]; #[feature(macro_rules)]; -#[allow(deprecated_owned_vector)]; // NOTE: remove after stage0 extern crate collections; diff --git a/src/libuuid/lib.rs b/src/libuuid/lib.rs index 47602bfcdf2..3338c3a3009 100644 --- a/src/libuuid/lib.rs +++ b/src/libuuid/lib.rs @@ -64,10 +64,6 @@ Examples of string representations: #[feature(default_type_params)]; -// NOTE remove the following two attributes after the next snapshot. -#[allow(unrecognized_lint)]; -#[allow(default_type_param_usage)]; - // test harness access #[cfg(test)] extern crate test; diff --git a/src/snapshots.txt b/src/snapshots.txt index 77c1cc68b17..f7f1c2d6aa3 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -1,3 +1,11 @@ +S 2014-03-22 94e4e91 + freebsd-x86_64 7793127e1b9ad22cb2e020f9bb01f34526cc4656 + linux-i386 aa53699d32d7acb86a6447f988c4ac73ac310bab + linux-x86_64 7ca5d5bfeec8d05ee3503bb48e4c5f6d75a6b49c + macos-i386 bc33e8fabe4d95848e91f5648268a6cc974d5468 + macos-x86_64 99da3ba5ec8924ccc0ad1fc17e2e04d1c29fccd0 + winnt-i386 578102567096d97b353b291076bdfa1e9da62513 + S 2014-03-19 4ca51ae freebsd-x86_64 3059005ca4ee2972bb705313bfb7848e859a20cd linux-i386 8907cd4ce8b8301d70a6bbc0100c955444270c19