Skip to content

Start taking apart the std::unstable module #12311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/libgreen/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/libgreen/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
}
}
2 changes: 1 addition & 1 deletion src/libgreen/sched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/libgreen/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/libnative/io/pipe_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion src/libnative/io/pipe_win32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/libnative/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#[doc(hidden)];

use ptr;
use unstable::raw;
use raw;

static RC_IMMORTAL : uint = 0x77777777;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 4 additions & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ pub mod reflect;
// Private APIs
#[unstable]
pub mod unstable;

#[experimental]
pub mod intrinsics;
#[experimental]
pub mod raw;

/* For internal use, not exported */

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/local_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ fn get_with<T:'static,
}

fn abort() -> ! {
use std::unstable::intrinsics;
use intrinsics;
unsafe { intrinsics::abort() }
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/managed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}

Expand Down
4 changes: 2 additions & 2 deletions src/libstd/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
(
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/i16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/i32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/i64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/i8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/u16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/u32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/u64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/u8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 2 additions & 0 deletions src/libstd/unstable/raw.rs → src/libstd/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/rt/global_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
21 changes: 19 additions & 2 deletions src/libstd/rt/local_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
Loading