From 4d10bdc5b9fecee38abcad78a86e552a961b1a0a Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 15 Feb 2014 23:49:08 -0800 Subject: [PATCH 1/4] std: Move intrinsics to std::intrinsics. Issue #1457 --- src/libarena/lib.rs | 4 ++-- src/libgreen/macros.rs | 2 +- src/libnative/io/pipe_unix.rs | 2 +- src/libnative/io/pipe_win32.rs | 2 +- src/librustdoc/html/markdown.rs | 2 +- src/libstd/any.rs | 4 ++-- src/libstd/cast.rs | 2 +- src/libstd/{unstable => }/intrinsics.rs | 4 +++- src/libstd/lib.rs | 3 ++- src/libstd/local_data.rs | 2 +- src/libstd/mem.rs | 4 ++-- src/libstd/num/f32.rs | 2 +- src/libstd/num/f64.rs | 2 +- src/libstd/num/i16.rs | 2 +- src/libstd/num/i32.rs | 2 +- src/libstd/num/i64.rs | 2 +- src/libstd/num/i8.rs | 2 +- src/libstd/num/int.rs | 2 +- src/libstd/num/u16.rs | 2 +- src/libstd/num/u32.rs | 2 +- src/libstd/num/u64.rs | 2 +- src/libstd/num/u8.rs | 2 +- src/libstd/num/uint.rs | 2 +- src/libstd/ptr.rs | 2 +- src/libstd/reflect.rs | 2 +- src/libstd/repr.rs | 2 +- src/libstd/rt/global_heap.rs | 2 +- src/libstd/rt/unwind.rs | 2 +- src/libstd/rt/util.rs | 2 +- src/libstd/sync/atomics.rs | 2 +- src/libstd/unstable/mod.rs | 1 - src/libstd/unstable/stack.rs | 2 +- src/test/auxiliary/typeid-intrinsic.rs | 4 ++-- src/test/auxiliary/typeid-intrinsic2.rs | 4 ++-- src/test/bench/sudoku.rs | 2 +- src/test/compile-fail/forget-init-unsafe.rs | 2 +- src/test/run-make/volatile-intrinsics/main.rs | 2 +- src/test/run-pass/issue-6898.rs | 2 +- src/test/run-pass/reflect-visit-type.rs | 2 +- src/test/run-pass/tydesc-name.rs | 2 +- src/test/run-pass/typeid-intrinsic.rs | 4 ++-- 41 files changed, 49 insertions(+), 47 deletions(-) rename src/libstd/{unstable => }/intrinsics.rs (99%) diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 3f5c2686064..3cf89c3124c 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -37,8 +37,8 @@ use std::num; use std::kinds::marker; use std::rc::Rc; use std::rt::global_heap; -use std::unstable::intrinsics::{TyDesc, get_tydesc}; -use std::unstable::intrinsics; +use std::intrinsics::{TyDesc, get_tydesc}; +use std::intrinsics; use std::vec; // The way arena uses arrays is really deeply awful. The arrays are diff --git a/src/libgreen/macros.rs b/src/libgreen/macros.rs index ef2c77fc8e2..ab106138ae1 100644 --- a/src/libgreen/macros.rs +++ b/src/libgreen/macros.rs @@ -124,7 +124,7 @@ memory and partly incapable of presentation to others.", abort(); fn abort() -> ! { - use std::unstable::intrinsics; + use std::intrinsics; unsafe { intrinsics::abort() } } } diff --git a/src/libnative/io/pipe_unix.rs b/src/libnative/io/pipe_unix.rs index 64acdbf7f48..784d8650689 100644 --- a/src/libnative/io/pipe_unix.rs +++ b/src/libnative/io/pipe_unix.rs @@ -15,7 +15,7 @@ use std::libc; use std::mem; use std::rt::rtio; use std::sync::arc::UnsafeArc; -use std::unstable::intrinsics; +use std::intrinsics; use super::{IoResult, retry}; use super::file::{keep_going, fd_t}; diff --git a/src/libnative/io/pipe_win32.rs b/src/libnative/io/pipe_win32.rs index fc4fc0fa789..e5e9592eb5a 100644 --- a/src/libnative/io/pipe_win32.rs +++ b/src/libnative/io/pipe_win32.rs @@ -90,7 +90,7 @@ use std::os::win32::as_utf16_p; use std::ptr; use std::rt::rtio; use std::sync::arc::UnsafeArc; -use std::unstable::intrinsics; +use std::intrinsics; use super::IoResult; diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index af0a43efa14..4662742f25c 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -32,7 +32,7 @@ use std::io; use std::libc; use std::mem; use std::str; -use std::unstable::intrinsics; +use std::intrinsics; use std::vec; /// A unit struct which has the `fmt::Show` trait implemented. When diff --git a/src/libstd/any.rs b/src/libstd/any.rs index 3f14db14882..06ae20d60bc 100644 --- a/src/libstd/any.rs +++ b/src/libstd/any.rs @@ -25,8 +25,8 @@ use fmt; use option::{Option, Some, None}; use result::{Result, Ok, Err}; use to_str::ToStr; -use unstable::intrinsics::TypeId; -use unstable::intrinsics; +use intrinsics::TypeId; +use intrinsics; /// A type with no inhabitants pub enum Void { } diff --git a/src/libstd/cast.rs b/src/libstd/cast.rs index ffdd70a6c14..c2db0c78205 100644 --- a/src/libstd/cast.rs +++ b/src/libstd/cast.rs @@ -11,7 +11,7 @@ //! Unsafe casting functions use mem; -use unstable::intrinsics; +use intrinsics; use ptr::copy_nonoverlapping_memory; /// Casts the value at `src` to U. The two types must have the same length. diff --git a/src/libstd/unstable/intrinsics.rs b/src/libstd/intrinsics.rs similarity index 99% rename from src/libstd/unstable/intrinsics.rs rename to src/libstd/intrinsics.rs index c983d82563c..b386335a428 100644 --- a/src/libstd/unstable/intrinsics.rs +++ b/src/libstd/intrinsics.rs @@ -41,9 +41,11 @@ A quick refresher on memory ordering: */ +#[allow(missing_doc)]; + // This is needed to prevent duplicate lang item definitions. #[cfg(test)] -pub use realstd::unstable::intrinsics::{TyDesc, Opaque, TyVisitor, TypeId}; +pub use realstd::intrinsics::{TyDesc, Opaque, TyVisitor, TypeId}; pub type GlueFn = extern "Rust" fn(*i8); diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 6996cba42b4..46958974484 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -196,7 +196,8 @@ pub mod reflect; // Private APIs #[unstable] pub mod unstable; - +#[experimental] +pub mod intrinsics; /* For internal use, not exported */ diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs index 043da46ba5e..6b854daabda 100644 --- a/src/libstd/local_data.rs +++ b/src/libstd/local_data.rs @@ -281,7 +281,7 @@ fn get_with ! { - use std::unstable::intrinsics; + use intrinsics; unsafe { intrinsics::abort() } } diff --git a/src/libstd/mem.rs b/src/libstd/mem.rs index 11053f01ded..603f2b80eea 100644 --- a/src/libstd/mem.rs +++ b/src/libstd/mem.rs @@ -17,8 +17,8 @@ use cast; use ptr; -use unstable::intrinsics; -use unstable::intrinsics::{bswap16, bswap32, bswap64}; +use intrinsics; +use intrinsics::{bswap16, bswap32, bswap64}; /// Returns the size of a type in bytes. #[inline] diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index da3f2c1636f..7b1fe949199 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -20,7 +20,7 @@ use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal}; use num::{Zero, One, Bounded, strconv}; use num; use to_str; -use unstable::intrinsics; +use intrinsics; macro_rules! delegate( ( diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 24165cbef50..d5a571cdd23 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -21,7 +21,7 @@ use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal}; use num::{Zero, One, Bounded, strconv}; use num; use to_str; -use unstable::intrinsics; +use intrinsics; pub use cmp::{min, max}; diff --git a/src/libstd/num/i16.rs b/src/libstd/num/i16.rs index cbeff5d4aa2..141626ed98a 100644 --- a/src/libstd/num/i16.rs +++ b/src/libstd/num/i16.rs @@ -20,7 +20,7 @@ use num::{CheckedDiv, Zero, One, strconv}; use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; use str; -use unstable::intrinsics; +use intrinsics; int_module!(i16, 16) diff --git a/src/libstd/num/i32.rs b/src/libstd/num/i32.rs index 9afc1a14545..a43a6e6a288 100644 --- a/src/libstd/num/i32.rs +++ b/src/libstd/num/i32.rs @@ -20,7 +20,7 @@ use num::{CheckedDiv, Zero, One, strconv}; use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; use str; -use unstable::intrinsics; +use intrinsics; int_module!(i32, 32) diff --git a/src/libstd/num/i64.rs b/src/libstd/num/i64.rs index f1e9f5a4fdc..e8503d808a7 100644 --- a/src/libstd/num/i64.rs +++ b/src/libstd/num/i64.rs @@ -22,7 +22,7 @@ use num::{CheckedDiv, Zero, One, strconv}; use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; use str; -use unstable::intrinsics; +use intrinsics; int_module!(i64, 64) diff --git a/src/libstd/num/i8.rs b/src/libstd/num/i8.rs index e0e549b731a..9f857ff40ff 100644 --- a/src/libstd/num/i8.rs +++ b/src/libstd/num/i8.rs @@ -20,7 +20,7 @@ use num::{CheckedDiv, Zero, One, strconv}; use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; use str; -use unstable::intrinsics; +use intrinsics; int_module!(i8, 8) diff --git a/src/libstd/num/int.rs b/src/libstd/num/int.rs index d525639045e..6d1a50b724f 100644 --- a/src/libstd/num/int.rs +++ b/src/libstd/num/int.rs @@ -20,7 +20,7 @@ use num::{CheckedDiv, Zero, One, strconv}; use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; use str; -use unstable::intrinsics; +use intrinsics; #[cfg(target_word_size = "32")] int_module!(int, 32) #[cfg(target_word_size = "64")] int_module!(int, 64) diff --git a/src/libstd/num/u16.rs b/src/libstd/num/u16.rs index 770db889af5..da0293b3418 100644 --- a/src/libstd/num/u16.rs +++ b/src/libstd/num/u16.rs @@ -21,7 +21,7 @@ use num::{CheckedDiv, Zero, One, strconv}; use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; use str; -use unstable::intrinsics; +use intrinsics; uint_module!(u16, i16, 16) diff --git a/src/libstd/num/u32.rs b/src/libstd/num/u32.rs index 9e08ffed3b7..b103e18f701 100644 --- a/src/libstd/num/u32.rs +++ b/src/libstd/num/u32.rs @@ -21,7 +21,7 @@ use num::{CheckedDiv, Zero, One, strconv}; use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; use str; -use unstable::intrinsics; +use intrinsics; uint_module!(u32, i32, 32) diff --git a/src/libstd/num/u64.rs b/src/libstd/num/u64.rs index 17eebed967c..f7956f0128e 100644 --- a/src/libstd/num/u64.rs +++ b/src/libstd/num/u64.rs @@ -23,7 +23,7 @@ use num::{CheckedDiv, Zero, One, strconv}; use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; use str; -use unstable::intrinsics; +use intrinsics; uint_module!(u64, i64, 64) diff --git a/src/libstd/num/u8.rs b/src/libstd/num/u8.rs index 4aa34b6d880..e6ce9c72e96 100644 --- a/src/libstd/num/u8.rs +++ b/src/libstd/num/u8.rs @@ -21,7 +21,7 @@ use num::{CheckedDiv, Zero, One, strconv}; use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; use str; -use unstable::intrinsics; +use intrinsics; uint_module!(u8, i8, 8) diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs index 1811ebc7acc..a8c85787f7e 100644 --- a/src/libstd/num/uint.rs +++ b/src/libstd/num/uint.rs @@ -21,7 +21,7 @@ use num::{CheckedDiv, Zero, One, strconv}; use num::{ToStrRadix, FromStrRadix}; use option::{Option, Some, None}; use str; -use unstable::intrinsics; +use intrinsics; uint_module!(uint, int, ::int::BITS) diff --git a/src/libstd/ptr.rs b/src/libstd/ptr.rs index 193e9ea7052..86264c1ca55 100644 --- a/src/libstd/ptr.rs +++ b/src/libstd/ptr.rs @@ -17,7 +17,7 @@ use cmp::Equiv; use iter::{range, Iterator}; use mem; use option::{Option, Some, None}; -use unstable::intrinsics; +use intrinsics; #[cfg(not(test))] use cmp::{Eq, Ord}; diff --git a/src/libstd/reflect.rs b/src/libstd/reflect.rs index f88da60ae9b..5ee840748e6 100644 --- a/src/libstd/reflect.rs +++ b/src/libstd/reflect.rs @@ -16,7 +16,7 @@ Runtime type reflection #[allow(missing_doc)]; -use unstable::intrinsics::{Disr, Opaque, TyDesc, TyVisitor}; +use intrinsics::{Disr, Opaque, TyDesc, TyVisitor}; use mem; use unstable::raw; diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index 680ac112300..8e1a0714748 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -29,7 +29,7 @@ use result::{Ok, Err}; use str::StrSlice; use to_str::ToStr; use vec::OwnedVector; -use unstable::intrinsics::{Disr, Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc}; +use intrinsics::{Disr, Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc}; use unstable::raw; macro_rules! try( ($me:expr, $e:expr) => ( diff --git a/src/libstd/rt/global_heap.rs b/src/libstd/rt/global_heap.rs index 8128bb02148..191d57a58fc 100644 --- a/src/libstd/rt/global_heap.rs +++ b/src/libstd/rt/global_heap.rs @@ -10,7 +10,7 @@ use libc::{c_void, size_t, free, malloc, realloc}; use ptr::{RawPtr, mut_null}; -use unstable::intrinsics::abort; +use intrinsics::abort; use unstable::raw; use mem::size_of; diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs index ef8bd94c897..127859b4275 100644 --- a/src/libstd/rt/unwind.rs +++ b/src/libstd/rt/unwind.rs @@ -69,7 +69,7 @@ use rt::local::Local; use rt::task::Task; use str::Str; use task::TaskResult; -use unstable::intrinsics; +use intrinsics; use uw = self::libunwind; diff --git a/src/libstd/rt/util.rs b/src/libstd/rt/util.rs index 69e240f30bc..408f51f2017 100644 --- a/src/libstd/rt/util.rs +++ b/src/libstd/rt/util.rs @@ -143,7 +143,7 @@ memory and partly incapable of presentation to others.", abort(); fn abort() -> ! { - use std::unstable::intrinsics; + use intrinsics; unsafe { intrinsics::abort() } } } diff --git a/src/libstd/sync/atomics.rs b/src/libstd/sync/atomics.rs index 00ce07d747f..b4d465c0397 100644 --- a/src/libstd/sync/atomics.rs +++ b/src/libstd/sync/atomics.rs @@ -21,7 +21,7 @@ #[allow(missing_doc)]; -use unstable::intrinsics; +use intrinsics; use cast; use std::kinds::marker; use option::{Option,Some,None}; diff --git a/src/libstd/unstable/mod.rs b/src/libstd/unstable/mod.rs index 87870ef0331..d3dae938b34 100644 --- a/src/libstd/unstable/mod.rs +++ b/src/libstd/unstable/mod.rs @@ -16,7 +16,6 @@ use libc::uintptr_t; pub mod dynamic_lib; pub mod finally; -pub mod intrinsics; pub mod simd; #[cfg(not(test))] pub mod lang; diff --git a/src/libstd/unstable/stack.rs b/src/libstd/unstable/stack.rs index 90c7888973a..655c209fec8 100644 --- a/src/libstd/unstable/stack.rs +++ b/src/libstd/unstable/stack.rs @@ -40,7 +40,7 @@ pub extern "C" fn rust_stack_exhausted() { use rt::local::Local; use rt::task::Task; use str::Str; - use unstable::intrinsics; + use intrinsics; unsafe { // We're calling this function because the stack just ran out. We need diff --git a/src/test/auxiliary/typeid-intrinsic.rs b/src/test/auxiliary/typeid-intrinsic.rs index 9bb86737261..b6c35f48010 100644 --- a/src/test/auxiliary/typeid-intrinsic.rs +++ b/src/test/auxiliary/typeid-intrinsic.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::unstable::intrinsics; -use std::unstable::intrinsics::TypeId; +use std::intrinsics; +use std::intrinsics::TypeId; pub struct A; pub struct B(Option); diff --git a/src/test/auxiliary/typeid-intrinsic2.rs b/src/test/auxiliary/typeid-intrinsic2.rs index 9bb86737261..b6c35f48010 100644 --- a/src/test/auxiliary/typeid-intrinsic2.rs +++ b/src/test/auxiliary/typeid-intrinsic2.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::unstable::intrinsics; -use std::unstable::intrinsics::TypeId; +use std::intrinsics; +use std::intrinsics::TypeId; pub struct A; pub struct B(Option); diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 56390b70ab3..b77180e8e4c 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -18,7 +18,7 @@ use std::io; use std::io::stdio::StdReader; use std::io::BufferedReader; use std::os; -use std::unstable::intrinsics::cttz16; +use std::intrinsics::cttz16; use std::vec; // Computes a single solution to a given 9x9 sudoku diff --git a/src/test/compile-fail/forget-init-unsafe.rs b/src/test/compile-fail/forget-init-unsafe.rs index 9ad7a178fb1..12df0c71cc5 100644 --- a/src/test/compile-fail/forget-init-unsafe.rs +++ b/src/test/compile-fail/forget-init-unsafe.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::unstable::intrinsics::{init, forget}; +use std::intrinsics::{init, forget}; // Test that the `forget` and `init` intrinsics are really unsafe pub fn main() { diff --git a/src/test/run-make/volatile-intrinsics/main.rs b/src/test/run-make/volatile-intrinsics/main.rs index 5011a7540a7..6dffb53e4a3 100644 --- a/src/test/run-make/volatile-intrinsics/main.rs +++ b/src/test/run-make/volatile-intrinsics/main.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::unstable::intrinsics::{volatile_load, volatile_store}; +use std::intrinsics::{volatile_load, volatile_store}; pub fn main() { unsafe { diff --git a/src/test/run-pass/issue-6898.rs b/src/test/run-pass/issue-6898.rs index 48a02063c6d..9e6293216bc 100644 --- a/src/test/run-pass/issue-6898.rs +++ b/src/test/run-pass/issue-6898.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::unstable::intrinsics; +use std::intrinsics; /// Returns the size of a type pub fn size_of() -> uint { diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index 56db021e2bc..f81ddabf77c 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -10,7 +10,7 @@ #[feature(managed_boxes)]; -use std::unstable::intrinsics::{TyDesc, get_tydesc, visit_tydesc, TyVisitor, Disr, Opaque}; +use std::intrinsics::{TyDesc, get_tydesc, visit_tydesc, TyVisitor, Disr, Opaque}; struct MyVisitor { types: ~[~str], diff --git a/src/test/run-pass/tydesc-name.rs b/src/test/run-pass/tydesc-name.rs index ea337aae27b..b3835ad5cdf 100644 --- a/src/test/run-pass/tydesc-name.rs +++ b/src/test/run-pass/tydesc-name.rs @@ -10,7 +10,7 @@ // ignore-fast: check-fast screws up repr paths -use std::unstable::intrinsics::get_tydesc; +use std::intrinsics::get_tydesc; struct Foo { x: T diff --git a/src/test/run-pass/typeid-intrinsic.rs b/src/test/run-pass/typeid-intrinsic.rs index 2d5c1d100be..b8356cc0e44 100644 --- a/src/test/run-pass/typeid-intrinsic.rs +++ b/src/test/run-pass/typeid-intrinsic.rs @@ -16,8 +16,8 @@ extern crate other1 = "typeid-intrinsic"; extern crate other2 = "typeid-intrinsic2"; use std::hash_old::Hash; -use std::unstable::intrinsics; -use std::unstable::intrinsics::TypeId; +use std::intrinsics; +use std::intrinsics::TypeId; struct A; struct Test; From 3e57808a01407be24a35f69148d20b76341b162f Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 16 Feb 2014 00:04:33 -0800 Subject: [PATCH 2/4] std: Move raw to std::raw Issue #1457 --- src/libgreen/context.rs | 2 +- src/libgreen/sched.rs | 2 +- src/libgreen/task.rs | 2 +- src/librustc/back/archive.rs | 2 +- src/libstd/c_str.rs | 2 +- src/libstd/cast.rs | 2 +- src/libstd/cleanup.rs | 2 +- src/libstd/lib.rs | 2 ++ src/libstd/managed.rs | 2 +- src/libstd/{unstable => }/raw.rs | 2 ++ src/libstd/reflect.rs | 2 +- src/libstd/repr.rs | 2 +- src/libstd/rt/global_heap.rs | 2 +- src/libstd/rt/local_heap.rs | 2 +- src/libstd/rt/unwind.rs | 2 +- src/libstd/str.rs | 4 ++-- src/libstd/unstable/mod.rs | 1 - src/libstd/vec.rs | 4 ++-- src/libstd/vec_ng.rs | 2 +- 19 files changed, 22 insertions(+), 19 deletions(-) rename src/libstd/{unstable => }/raw.rs (99%) diff --git a/src/libgreen/context.rs b/src/libgreen/context.rs index 58188ede13c..3f6dc299da5 100644 --- a/src/libgreen/context.rs +++ b/src/libgreen/context.rs @@ -13,7 +13,7 @@ use std::cast::{transmute, transmute_mut_unsafe, transmute_region, transmute_mut_region}; use stack::Stack; use std::unstable::stack; -use std::unstable::raw; +use std::raw; // FIXME #7761: Registers is boxed so that it is 16-byte aligned, for storing // SSE regs. It would be marginally better not to do this. In C++ we diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs index a966dff000a..f722744e23d 100644 --- a/src/libgreen/sched.rs +++ b/src/libgreen/sched.rs @@ -16,7 +16,7 @@ use std::rt::task::BlockedTask; use std::rt::task::Task; use std::sync::deque; use std::unstable::mutex::NativeMutex; -use std::unstable::raw; +use std::raw; use TaskState; use context::Context; diff --git a/src/libgreen/task.rs b/src/libgreen/task.rs index e139cfa1025..1d7fb64896f 100644 --- a/src/libgreen/task.rs +++ b/src/libgreen/task.rs @@ -26,7 +26,7 @@ use std::rt::rtio; use std::rt::task::{Task, BlockedTask, SendMessage}; use std::task::TaskOpts; use std::unstable::mutex::NativeMutex; -use std::unstable::raw; +use std::raw; use context::Context; use coroutine::Coroutine; diff --git a/src/librustc/back/archive.rs b/src/librustc/back/archive.rs index d5d784cc2de..6dec7550fec 100644 --- a/src/librustc/back/archive.rs +++ b/src/librustc/back/archive.rs @@ -22,7 +22,7 @@ use std::libc; use std::os; use std::run::{ProcessOptions, Process, ProcessOutput}; use std::str; -use std::unstable::raw; +use std::raw; use extra::tempfile::TempDir; use syntax::abi; diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs index e6b0958617e..af5d9838186 100644 --- a/src/libstd/c_str.rs +++ b/src/libstd/c_str.rs @@ -79,7 +79,7 @@ use str; use vec::{ImmutableVector, MutableVector}; use vec; use rt::global_heap::malloc_raw; -use unstable::raw::Slice; +use raw::Slice; /// The representation of a C String. /// diff --git a/src/libstd/cast.rs b/src/libstd/cast.rs index c2db0c78205..8280553c1a3 100644 --- a/src/libstd/cast.rs +++ b/src/libstd/cast.rs @@ -113,7 +113,7 @@ pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T { #[cfg(test)] mod tests { use cast::{bump_box_refcount, transmute}; - use unstable::raw; + use raw; #[test] fn test_transmute_copy() { diff --git a/src/libstd/cleanup.rs b/src/libstd/cleanup.rs index dd43d8e2971..39c7932cdc8 100644 --- a/src/libstd/cleanup.rs +++ b/src/libstd/cleanup.rs @@ -11,7 +11,7 @@ #[doc(hidden)]; use ptr; -use unstable::raw; +use raw; static RC_IMMORTAL : uint = 0x77777777; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 46958974484..65b908a9f56 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -198,6 +198,8 @@ pub mod reflect; pub mod unstable; #[experimental] pub mod intrinsics; +#[experimental] +pub mod raw; /* For internal use, not exported */ diff --git a/src/libstd/managed.rs b/src/libstd/managed.rs index 63196cd4f16..4cd99492ee4 100644 --- a/src/libstd/managed.rs +++ b/src/libstd/managed.rs @@ -15,7 +15,7 @@ /// Returns the refcount of a shared box (as just before calling this) #[inline] pub fn refcount(t: @T) -> uint { - use unstable::raw::Repr; + use raw::Repr; unsafe { (*t.repr()).ref_count - 1 } } diff --git a/src/libstd/unstable/raw.rs b/src/libstd/raw.rs similarity index 99% rename from src/libstd/unstable/raw.rs rename to src/libstd/raw.rs index c25422d24e9..c7ba2ad3932 100644 --- a/src/libstd/unstable/raw.rs +++ b/src/libstd/raw.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[allow(missing_doc)]; + use cast; /// The representation of a Rust managed box diff --git a/src/libstd/reflect.rs b/src/libstd/reflect.rs index 5ee840748e6..a9e70bd3c63 100644 --- a/src/libstd/reflect.rs +++ b/src/libstd/reflect.rs @@ -18,7 +18,7 @@ Runtime type reflection use intrinsics::{Disr, Opaque, TyDesc, TyVisitor}; use mem; -use unstable::raw; +use raw; /** * Trait for visitor that wishes to reflect on data. To use this, create a diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index 8e1a0714748..c1b276899d5 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -30,7 +30,7 @@ use str::StrSlice; use to_str::ToStr; use vec::OwnedVector; use intrinsics::{Disr, Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc}; -use unstable::raw; +use raw; macro_rules! try( ($me:expr, $e:expr) => ( match $e { diff --git a/src/libstd/rt/global_heap.rs b/src/libstd/rt/global_heap.rs index 191d57a58fc..23b23cf8af0 100644 --- a/src/libstd/rt/global_heap.rs +++ b/src/libstd/rt/global_heap.rs @@ -11,7 +11,7 @@ use libc::{c_void, size_t, free, malloc, realloc}; use ptr::{RawPtr, mut_null}; use intrinsics::abort; -use unstable::raw; +use raw; use mem::size_of; #[inline] diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs index 8a42cd73565..4ff25a34210 100644 --- a/src/libstd/rt/local_heap.rs +++ b/src/libstd/rt/local_heap.rs @@ -20,7 +20,7 @@ use ptr::RawPtr; use rt::global_heap; use rt::local::Local; use rt::task::Task; -use unstable::raw; +use raw; use vec::ImmutableVector; use vec_ng::Vec; diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs index 127859b4275..16d677b5ff2 100644 --- a/src/libstd/rt/unwind.rs +++ b/src/libstd/rt/unwind.rs @@ -177,7 +177,7 @@ impl Unwinder { } pub fn try(&mut self, f: ||) { - use unstable::raw::Closure; + use raw::Closure; use libc::{c_void}; unsafe { diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 1c1b10bb14c..4d5eabbed10 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -104,7 +104,7 @@ use vec::{OwnedVector, OwnedCloneableVector, ImmutableVector, MutableVector}; use vec_ng::Vec; use default::Default; use to_bytes::{IterBytes, Cb}; -use unstable::raw::Repr; +use raw::Repr; /* Section: Creating a string @@ -1386,7 +1386,7 @@ pub mod raw { use str::{is_utf8, OwnedStr, StrSlice}; use vec; use vec::{MutableVector, ImmutableVector, OwnedVector}; - use unstable::raw::Slice; + use raw::Slice; /// Create a Rust string from a *u8 buffer of the given length pub unsafe fn from_buf_len(buf: *u8, len: uint) -> ~str { diff --git a/src/libstd/unstable/mod.rs b/src/libstd/unstable/mod.rs index d3dae938b34..9f37bfcddb9 100644 --- a/src/libstd/unstable/mod.rs +++ b/src/libstd/unstable/mod.rs @@ -21,7 +21,6 @@ pub mod simd; pub mod lang; pub mod sync; pub mod mutex; -pub mod raw; pub mod stack; /** diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 0adc6083f6b..00617af05b1 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -122,7 +122,7 @@ use mem::size_of; use kinds::marker; use uint; use unstable::finally::try_finally; -use unstable::raw::{Repr, Slice, Vec}; +use raw::{Repr, Slice, Vec}; /** * Creates and initializes an owned vector. @@ -2488,7 +2488,7 @@ pub mod raw { use ptr; use ptr::RawPtr; use vec::{with_capacity, MutableVector, OwnedVector}; - use unstable::raw::Slice; + use raw::Slice; /** * Form a slice from a pointer and length (as a number of units, diff --git a/src/libstd/vec_ng.rs b/src/libstd/vec_ng.rs index 114f34963e2..3532e7b26a4 100644 --- a/src/libstd/vec_ng.rs +++ b/src/libstd/vec_ng.rs @@ -24,7 +24,7 @@ use option::{None, Option, Some}; use ptr::RawPtr; use ptr; use rt::global_heap::{malloc_raw, realloc_raw}; -use unstable::raw::Slice; +use raw::Slice; use vec::{ImmutableVector, Items, MutItems, MutableVector, RevItems}; pub struct Vec { From 96b299e1f08e2b6bbb8c03dfaa2881898dc6a0cb Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 16 Feb 2014 20:16:23 -0800 Subject: [PATCH 3/4] std: Remove unstable::lang Put the lonely lang items here closer to the code they are calling. --- src/libstd/rt/local_heap.rs | 19 +++++++++++++- src/libstd/rt/unwind.rs | 18 +++++++++++++ src/libstd/unstable/lang.rs | 52 ------------------------------------- src/libstd/unstable/mod.rs | 2 -- 4 files changed, 36 insertions(+), 55 deletions(-) delete mode 100644 src/libstd/unstable/lang.rs diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs index 4ff25a34210..29b3dcaa4f2 100644 --- a/src/libstd/rt/local_heap.rs +++ b/src/libstd/rt/local_heap.rs @@ -276,6 +276,14 @@ impl Drop for MemoryRegion { } } + +#[cfg(not(test))] +#[lang="malloc"] +#[inline] +pub unsafe fn local_malloc_(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 { + local_malloc(drop_glue, size, align) +} + #[inline] pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 { // FIXME: Unsafe borrow for speed. Lame. @@ -288,7 +296,16 @@ pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> * } } -// A little compatibility function +#[cfg(not(test))] +#[lang="free"] +#[inline] +pub unsafe fn local_free_(ptr: *u8) { + local_free(ptr) +} + +// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from +// inside a landing pad may corrupt the state of the exception handler. If a +// problem occurs, call exit instead. #[inline] pub unsafe fn local_free(ptr: *u8) { // FIXME: Unsafe borrow for speed. Lame. diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs index 16d677b5ff2..b9459aed582 100644 --- a/src/libstd/rt/unwind.rs +++ b/src/libstd/rt/unwind.rs @@ -376,6 +376,24 @@ pub mod eabi { } } +#[cold] +#[lang="fail_"] +#[cfg(not(test))] +pub fn fail_(expr: *u8, file: *u8, line: uint) -> ! { + begin_unwind_raw(expr, file, line); +} + +#[cold] +#[lang="fail_bounds_check"] +#[cfg(not(test))] +pub fn fail_bounds_check(file: *u8, line: uint, index: uint, len: uint) -> ! { + use c_str::ToCStr; + + let msg = format!("index out of bounds: the len is {} but the index is {}", + len as uint, index as uint); + msg.with_c_str(|buf| fail_(buf as *u8, file, line)) +} + /// This is the entry point of unwinding for things like lang items and such. /// The arguments are normally generated by the compiler, and need to /// have static lifetimes. diff --git a/src/libstd/unstable/lang.rs b/src/libstd/unstable/lang.rs deleted file mode 100644 index 8818cb0d270..00000000000 --- a/src/libstd/unstable/lang.rs +++ /dev/null @@ -1,52 +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. - -//! Runtime calls emitted by the compiler. - -use c_str::CString; -use libc::c_char; -use cast; -use option::Some; - -#[cold] -#[lang="fail_"] -pub fn fail_(expr: *u8, file: *u8, line: uint) -> ! { - ::rt::begin_unwind_raw(expr, file, line); -} - -#[cold] -#[lang="fail_bounds_check"] -pub fn fail_bounds_check(file: *u8, line: uint, index: uint, len: uint) -> ! { - let msg = format!("index out of bounds: the len is {} but the index is {}", - len as uint, index as uint); - - let file_str = match unsafe { CString::new(file as *c_char, false) }.as_str() { - // This transmute is safe because `file` is always stored in rodata. - Some(s) => unsafe { cast::transmute::<&str, &'static str>(s) }, - None => "file wasn't UTF-8 safe" - }; - - ::rt::begin_unwind(msg, file_str, line) -} - -#[lang="malloc"] -#[inline] -pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 { - ::rt::local_heap::local_malloc(drop_glue, size, align) -} - -// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from -// inside a landing pad may corrupt the state of the exception handler. If a -// problem occurs, call exit instead. -#[lang="free"] -#[inline] -pub unsafe fn local_free(ptr: *u8) { - ::rt::local_heap::local_free(ptr); -} diff --git a/src/libstd/unstable/mod.rs b/src/libstd/unstable/mod.rs index 9f37bfcddb9..1a4862fd733 100644 --- a/src/libstd/unstable/mod.rs +++ b/src/libstd/unstable/mod.rs @@ -17,8 +17,6 @@ pub mod dynamic_lib; pub mod finally; pub mod simd; -#[cfg(not(test))] -pub mod lang; pub mod sync; pub mod mutex; pub mod stack; From db111846b58253c723750be280a478ed7d27d879 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 16 Feb 2014 21:37:12 -0800 Subject: [PATCH 4/4] std: Move unstable::stack to rt::stack --- src/libgreen/context.rs | 2 +- src/libnative/task.rs | 2 +- src/libstd/rt/mod.rs | 3 +++ src/libstd/{unstable => rt}/stack.rs | 0 src/libstd/rt/thread.rs | 6 +++--- src/libstd/unstable/mod.rs | 1 - 6 files changed, 8 insertions(+), 6 deletions(-) rename src/libstd/{unstable => rt}/stack.rs (100%) diff --git a/src/libgreen/context.rs b/src/libgreen/context.rs index 3f6dc299da5..1d79f3f14c5 100644 --- a/src/libgreen/context.rs +++ b/src/libgreen/context.rs @@ -12,7 +12,7 @@ use std::uint; use std::cast::{transmute, transmute_mut_unsafe, transmute_region, transmute_mut_region}; use stack::Stack; -use std::unstable::stack; +use std::rt::stack; use std::raw; // FIXME #7761: Registers is boxed so that it is 16-byte aligned, for storing diff --git a/src/libnative/task.rs b/src/libnative/task.rs index b0f063ff06e..ccfc040e7df 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -23,7 +23,7 @@ use std::rt::thread::Thread; use std::rt; use std::task::TaskOpts; use std::unstable::mutex::NativeMutex; -use std::unstable::stack; +use std::rt::stack; use io; use task; diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index b751c57c0fa..2f1a6989092 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -128,6 +128,9 @@ pub mod args; // Support for running procedures when a program has exited. mod at_exit_imp; +// Stack overflow protection +pub mod stack; + /// The default error code of the rust runtime if the main task fails instead /// of exiting cleanly. pub static DEFAULT_ERROR_CODE: int = 101; diff --git a/src/libstd/unstable/stack.rs b/src/libstd/rt/stack.rs similarity index 100% rename from src/libstd/unstable/stack.rs rename to src/libstd/rt/stack.rs diff --git a/src/libstd/rt/thread.rs b/src/libstd/rt/thread.rs index b443182c157..7b24c94b518 100644 --- a/src/libstd/rt/thread.rs +++ b/src/libstd/rt/thread.rs @@ -41,7 +41,7 @@ static DEFAULT_STACK_SIZE: uint = 1024 * 1024; // and invoke it. #[no_split_stack] extern fn thread_start(main: *libc::c_void) -> imp::rust_thread_return { - use unstable::stack; + use rt::stack; unsafe { stack::record_stack_bounds(0, uint::MAX); let f: ~proc() = cast::transmute(main); @@ -150,7 +150,7 @@ mod imp { use libc::types::os::arch::extra::{LPSECURITY_ATTRIBUTES, SIZE_T, BOOL, LPVOID, DWORD, LPDWORD, HANDLE}; use ptr; - use unstable::stack::RED_ZONE; + use rt::stack::RED_ZONE; pub type rust_thread = HANDLE; pub type rust_thread_return = DWORD; @@ -208,7 +208,7 @@ mod imp { use mem; use os; use ptr; - use unstable::stack::RED_ZONE; + use rt::stack::RED_ZONE; pub type rust_thread = libc::pthread_t; pub type rust_thread_return = *u8; diff --git a/src/libstd/unstable/mod.rs b/src/libstd/unstable/mod.rs index 1a4862fd733..7bee0cf48ee 100644 --- a/src/libstd/unstable/mod.rs +++ b/src/libstd/unstable/mod.rs @@ -19,7 +19,6 @@ pub mod finally; pub mod simd; pub mod sync; pub mod mutex; -pub mod stack; /**