auto merge of #12311 : brson/rust/unstable, r=alexcrichton

With the stability attributes we can put public-but unstable modules next to others, so this moves `intrinsics` and `raw` out of the `unstable` module (and marks both as `#[experimental]`).
This commit is contained in:
bors 2014-02-23 02:21:53 -08:00
commit 551da06157
57 changed files with 115 additions and 127 deletions

View File

@ -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

View File

@ -12,8 +12,8 @@ use std::uint;
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::rt::stack;
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

View File

@ -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() }
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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};

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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 { }

View File

@ -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.
///

View File

@ -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.
@ -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() {

View File

@ -11,7 +11,7 @@
#[doc(hidden)];
use ptr;
use unstable::raw;
use raw;
static RC_IMMORTAL : uint = 0x77777777;

View File

@ -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);

View File

@ -194,7 +194,10 @@ pub mod reflect;
// Private APIs
#[unstable]
pub mod unstable;
#[experimental]
pub mod intrinsics;
#[experimental]
pub mod raw;
/* For internal use, not exported */

View File

@ -281,7 +281,7 @@ fn get_with<T:'static,
}
fn abort() -> ! {
use std::unstable::intrinsics;
use intrinsics;
unsafe { intrinsics::abort() }
}

View File

@ -15,7 +15,7 @@
/// Returns the refcount of a shared box (as just before calling this)
#[inline]
pub fn refcount<T>(t: @T) -> uint {
use unstable::raw::Repr;
use raw::Repr;
unsafe { (*t.repr()).ref_count - 1 }
}

View File

@ -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]

View File

@ -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(
(

View File

@ -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};

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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};

View File

@ -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

View File

@ -16,9 +16,9 @@ Runtime type reflection
#[allow(missing_doc)];
use unstable::intrinsics::{Disr, Opaque, TyDesc, TyVisitor};
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

View File

@ -29,8 +29,8 @@ 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 unstable::raw;
use intrinsics::{Disr, Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc};
use raw;
macro_rules! try( ($me:expr, $e:expr) => (
match $e {

View File

@ -10,8 +10,8 @@
use libc::{c_void, size_t, free, malloc, realloc};
use ptr::{RawPtr, mut_null};
use unstable::intrinsics::abort;
use unstable::raw;
use intrinsics::abort;
use raw;
use mem::size_of;
#[inline]

View File

@ -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;
@ -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.

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;
@ -177,7 +177,7 @@ impl Unwinder {
}
pub fn try(&mut self, f: ||) {
use unstable::raw::Closure;
use raw::Closure;
use libc::{c_void};
unsafe {
@ -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.

View File

@ -143,7 +143,7 @@ memory and partly incapable of presentation to others.",
abort();
fn abort() -> ! {
use std::unstable::intrinsics;
use intrinsics;
unsafe { intrinsics::abort() }
}
}

View File

@ -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 {

View File

@ -21,7 +21,7 @@
#[allow(missing_doc)];
use unstable::intrinsics;
use intrinsics;
use cast;
use std::kinds::marker;
use option::{Option,Some,None};

View File

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! 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);
}

View File

@ -16,14 +16,9 @@ use libc::uintptr_t;
pub mod dynamic_lib;
pub mod finally;
pub mod intrinsics;
pub mod simd;
#[cfg(not(test))]
pub mod lang;
pub mod sync;
pub mod mutex;
pub mod raw;
pub mod stack;
/**

View File

@ -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,

View File

@ -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<T> {

View File

@ -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<A>);

View File

@ -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<A>);

View File

@ -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

View File

@ -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() {

View File

@ -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 {

View File

@ -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<T>() -> uint {

View File

@ -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],

View File

@ -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<T> {
x: T

View File

@ -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;