]> git.lizzy.rs Git - rust.git/commitdiff
std: Move intrinsics to std::intrinsics.
authorBrian Anderson <banderson@mozilla.com>
Sun, 16 Feb 2014 07:49:08 +0000 (23:49 -0800)
committerBrian Anderson <banderson@mozilla.com>
Sun, 23 Feb 2014 09:07:53 +0000 (01:07 -0800)
Issue #1457

42 files changed:
src/libarena/lib.rs
src/libgreen/macros.rs
src/libnative/io/pipe_unix.rs
src/libnative/io/pipe_win32.rs
src/librustdoc/html/markdown.rs
src/libstd/any.rs
src/libstd/cast.rs
src/libstd/intrinsics.rs [new file with mode: 0644]
src/libstd/lib.rs
src/libstd/local_data.rs
src/libstd/mem.rs
src/libstd/num/f32.rs
src/libstd/num/f64.rs
src/libstd/num/i16.rs
src/libstd/num/i32.rs
src/libstd/num/i64.rs
src/libstd/num/i8.rs
src/libstd/num/int.rs
src/libstd/num/u16.rs
src/libstd/num/u32.rs
src/libstd/num/u64.rs
src/libstd/num/u8.rs
src/libstd/num/uint.rs
src/libstd/ptr.rs
src/libstd/reflect.rs
src/libstd/repr.rs
src/libstd/rt/global_heap.rs
src/libstd/rt/unwind.rs
src/libstd/rt/util.rs
src/libstd/sync/atomics.rs
src/libstd/unstable/intrinsics.rs [deleted file]
src/libstd/unstable/mod.rs
src/libstd/unstable/stack.rs
src/test/auxiliary/typeid-intrinsic.rs
src/test/auxiliary/typeid-intrinsic2.rs
src/test/bench/sudoku.rs
src/test/compile-fail/forget-init-unsafe.rs
src/test/run-make/volatile-intrinsics/main.rs
src/test/run-pass/issue-6898.rs
src/test/run-pass/reflect-visit-type.rs
src/test/run-pass/tydesc-name.rs
src/test/run-pass/typeid-intrinsic.rs

index 3f5c268606449fe963f84e959df6a09f608dab7d..3cf89c3124c39360444c31dd85d1c76a2fff6101 100644 (file)
@@ -37,8 +37,8 @@
 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
index ef2c77fc8e25f4b1c7671cc8f2ab9eb389f7ef82..ab106138ae1088bd40bf6c04dfe027f311c45bf5 100644 (file)
@@ -124,7 +124,7 @@ pub fn abort(msg: &str) -> ! {
     abort();
 
     fn abort() -> ! {
-        use std::unstable::intrinsics;
+        use std::intrinsics;
         unsafe { intrinsics::abort() }
     }
 }
index 64acdbf7f489fe612a44e743a551f181582eab70..784d8650689a4d4d0f030794244dbcf75e44d8d1 100644 (file)
@@ -15,7 +15,7 @@
 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};
index fc4fc0fa7893d84f08513b3e911248f092c4a083..e5e9592eb5ab53c4e96aab5c44e58cfc27b05294 100644 (file)
@@ -90,7 +90,7 @@
 use std::ptr;
 use std::rt::rtio;
 use std::sync::arc::UnsafeArc;
-use std::unstable::intrinsics;
+use std::intrinsics;
 
 use super::IoResult;
 
index af0a43efa148f6b614575bd928ead6a6e4cbd67e..4662742f25cb18b53559892b9c72eb9367b821a5 100644 (file)
@@ -32,7 +32,7 @@
 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
index 3f14db14882ec54a271aef7733a16af2df4dd88b..06ae20d60bce5c90d3435e4d94d550c05423bdf5 100644 (file)
@@ -25,8 +25,8 @@
 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 { }
index ffdd70a6c144a6f0e300048d7f872ccd3a5ff085..c2db0c78205088962da96ba7347a8b6e0234101a 100644 (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.
diff --git a/src/libstd/intrinsics.rs b/src/libstd/intrinsics.rs
new file mode 100644 (file)
index 0000000..b386335
--- /dev/null
@@ -0,0 +1,459 @@
+// Copyright 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.
+
+/*! rustc compiler intrinsics.
+
+The corresponding definitions are in librustc/middle/trans/foreign.rs.
+
+# Volatiles
+
+The volatile intrinsics provide operations intended to act on I/O
+memory, which are guaranteed to not be reordered by the compiler
+across other volatile intrinsics. See the LLVM documentation on
+[[volatile]].
+
+[volatile]: http://llvm.org/docs/LangRef.html#volatile-memory-accesses
+
+# Atomics
+
+The atomic intrinsics provide common atomic operations on machine
+words, with multiple possible memory orderings. They obey the same
+semantics as C++11. See the LLVM documentation on [[atomics]].
+
+[atomics]: http://llvm.org/docs/Atomics.html
+
+A quick refresher on memory ordering:
+
+* Acquire - a barrier for acquiring a lock. Subsequent reads and writes
+  take place after the barrier.
+* Release - a barrier for releasing a lock. Preceding reads and writes
+  take place before the barrier.
+* Sequentially consistent - sequentially consistent operations are
+  guaranteed to happen in order. This is the standard mode for working
+  with atomic types and is equivalent to Java's `volatile`.
+
+*/
+
+#[allow(missing_doc)];
+
+// This is needed to prevent duplicate lang item definitions.
+#[cfg(test)]
+pub use realstd::intrinsics::{TyDesc, Opaque, TyVisitor, TypeId};
+
+pub type GlueFn = extern "Rust" fn(*i8);
+
+#[lang="ty_desc"]
+#[cfg(not(test))]
+pub struct TyDesc {
+    // sizeof(T)
+    size: uint,
+
+    // alignof(T)
+    align: uint,
+
+    // Called when a value of type `T` is no longer needed
+    drop_glue: GlueFn,
+
+    // Called by reflection visitor to visit a value of type `T`
+    visit_glue: GlueFn,
+
+    // Name corresponding to the type
+    name: &'static str
+}
+
+#[lang="opaque"]
+#[cfg(not(test))]
+pub enum Opaque { }
+
+pub type Disr = u64;
+
+#[lang="ty_visitor"]
+#[cfg(not(test))]
+pub trait TyVisitor {
+    fn visit_bot(&mut self) -> bool;
+    fn visit_nil(&mut self) -> bool;
+    fn visit_bool(&mut self) -> bool;
+
+    fn visit_int(&mut self) -> bool;
+    fn visit_i8(&mut self) -> bool;
+    fn visit_i16(&mut self) -> bool;
+    fn visit_i32(&mut self) -> bool;
+    fn visit_i64(&mut self) -> bool;
+
+    fn visit_uint(&mut self) -> bool;
+    fn visit_u8(&mut self) -> bool;
+    fn visit_u16(&mut self) -> bool;
+    fn visit_u32(&mut self) -> bool;
+    fn visit_u64(&mut self) -> bool;
+
+    fn visit_f32(&mut self) -> bool;
+    fn visit_f64(&mut self) -> bool;
+
+    fn visit_char(&mut self) -> bool;
+
+    fn visit_estr_box(&mut self) -> bool;
+    fn visit_estr_uniq(&mut self) -> bool;
+    fn visit_estr_slice(&mut self) -> bool;
+    fn visit_estr_fixed(&mut self, n: uint, sz: uint, align: uint) -> bool;
+
+    fn visit_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_ptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_rptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
+
+    fn visit_vec(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_unboxed_vec(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_evec_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_evec_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_evec_slice(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_evec_fixed(&mut self, n: uint, sz: uint, align: uint,
+                        mtbl: uint, inner: *TyDesc) -> bool;
+
+    fn visit_enter_rec(&mut self, n_fields: uint,
+                       sz: uint, align: uint) -> bool;
+    fn visit_rec_field(&mut self, i: uint, name: &str,
+                       mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_leave_rec(&mut self, n_fields: uint,
+                       sz: uint, align: uint) -> bool;
+
+    fn visit_enter_class(&mut self, name: &str, named_fields: bool, n_fields: uint,
+                         sz: uint, align: uint) -> bool;
+    fn visit_class_field(&mut self, i: uint, name: &str, named: bool,
+                         mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_leave_class(&mut self, name: &str, named_fields: bool, n_fields: uint,
+                         sz: uint, align: uint) -> bool;
+
+    fn visit_enter_tup(&mut self, n_fields: uint,
+                       sz: uint, align: uint) -> bool;
+    fn visit_tup_field(&mut self, i: uint, inner: *TyDesc) -> bool;
+    fn visit_leave_tup(&mut self, n_fields: uint,
+                       sz: uint, align: uint) -> bool;
+
+    fn visit_enter_enum(&mut self, n_variants: uint,
+                        get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
+                        sz: uint, align: uint) -> bool;
+    fn visit_enter_enum_variant(&mut self, variant: uint,
+                                disr_val: Disr,
+                                n_fields: uint,
+                                name: &str) -> bool;
+    fn visit_enum_variant_field(&mut self, i: uint, offset: uint, inner: *TyDesc) -> bool;
+    fn visit_leave_enum_variant(&mut self, variant: uint,
+                                disr_val: Disr,
+                                n_fields: uint,
+                                name: &str) -> bool;
+    fn visit_leave_enum(&mut self, n_variants: uint,
+                        get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
+                        sz: uint, align: uint) -> bool;
+
+    fn visit_enter_fn(&mut self, purity: uint, proto: uint,
+                      n_inputs: uint, retstyle: uint) -> bool;
+    fn visit_fn_input(&mut self, i: uint, mode: uint, inner: *TyDesc) -> bool;
+    fn visit_fn_output(&mut self, retstyle: uint, variadic: bool, inner: *TyDesc) -> bool;
+    fn visit_leave_fn(&mut self, purity: uint, proto: uint,
+                      n_inputs: uint, retstyle: uint) -> bool;
+
+    fn visit_trait(&mut self, name: &str) -> bool;
+    fn visit_param(&mut self, i: uint) -> bool;
+    fn visit_self(&mut self) -> bool;
+}
+
+extern "rust-intrinsic" {
+    pub fn atomic_cxchg<T>(dst: &mut T, old: T, src: T) -> T;
+    pub fn atomic_cxchg_acq<T>(dst: &mut T, old: T, src: T) -> T;
+    pub fn atomic_cxchg_rel<T>(dst: &mut T, old: T, src: T) -> T;
+    pub fn atomic_cxchg_acqrel<T>(dst: &mut T, old: T, src: T) -> T;
+    pub fn atomic_cxchg_relaxed<T>(dst: &mut T, old: T, src: T) -> T;
+
+    pub fn atomic_load<T>(src: &T) -> T;
+    pub fn atomic_load_acq<T>(src: &T) -> T;
+    pub fn atomic_load_relaxed<T>(src: &T) -> T;
+
+    pub fn atomic_store<T>(dst: &mut T, val: T);
+    pub fn atomic_store_rel<T>(dst: &mut T, val: T);
+    pub fn atomic_store_relaxed<T>(dst: &mut T, val: T);
+
+    pub fn atomic_xchg<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xchg_acq<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xchg_rel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xchg_acqrel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xchg_relaxed<T>(dst: &mut T, src: T) -> T;
+
+    pub fn atomic_xadd<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xadd_acq<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xadd_rel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xadd_acqrel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xadd_relaxed<T>(dst: &mut T, src: T) -> T;
+
+    pub fn atomic_xsub<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xsub_acq<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xsub_rel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xsub_acqrel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xsub_relaxed<T>(dst: &mut T, src: T) -> T;
+
+    pub fn atomic_and<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_and_acq<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_and_rel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_and_acqrel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_and_relaxed<T>(dst: &mut T, src: T) -> T;
+
+    pub fn atomic_nand<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_nand_acq<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_nand_rel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_nand_acqrel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_nand_relaxed<T>(dst: &mut T, src: T) -> T;
+
+    pub fn atomic_or<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_or_acq<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_or_rel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_or_acqrel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_or_relaxed<T>(dst: &mut T, src: T) -> T;
+
+    pub fn atomic_xor<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xor_acq<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xor_rel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xor_acqrel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_xor_relaxed<T>(dst: &mut T, src: T) -> T;
+
+    pub fn atomic_max<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_max_acq<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_max_rel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_max_acqrel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_max_relaxed<T>(dst: &mut T, src: T) -> T;
+
+    pub fn atomic_min<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_min_acq<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_min_rel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_min_acqrel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_min_relaxed<T>(dst: &mut T, src: T) -> T;
+
+    pub fn atomic_umin<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_umin_acq<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_umin_rel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_umin_acqrel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_umin_relaxed<T>(dst: &mut T, src: T) -> T;
+
+    pub fn atomic_umax<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_umax_acq<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_umax_rel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_umax_acqrel<T>(dst: &mut T, src: T) -> T;
+    pub fn atomic_umax_relaxed<T>(dst: &mut T, src: T) -> T;
+
+    pub fn atomic_fence();
+    pub fn atomic_fence_acq();
+    pub fn atomic_fence_rel();
+    pub fn atomic_fence_acqrel();
+
+    /// Abort the execution of the process.
+    pub fn abort() -> !;
+
+    /// Execute a breakpoint trap, for inspection by a debugger.
+    pub fn breakpoint();
+
+    pub fn volatile_load<T>(src: *T) -> T;
+    pub fn volatile_store<T>(dst: *mut T, val: T);
+
+
+    /// The size of a type in bytes.
+    ///
+    /// This is the exact number of bytes in memory taken up by a
+    /// value of the given type. In other words, a memset of this size
+    /// would *exactly* overwrite a value. When laid out in vectors
+    /// and structures there may be additional padding between
+    /// elements.
+    pub fn size_of<T>() -> uint;
+
+    /// Move a value to an uninitialized memory location.
+    ///
+    /// Drop glue is not run on the destination.
+    pub fn move_val_init<T>(dst: &mut T, src: T);
+
+    pub fn min_align_of<T>() -> uint;
+    pub fn pref_align_of<T>() -> uint;
+
+    /// Get a static pointer to a type descriptor.
+    pub fn get_tydesc<T>() -> *TyDesc;
+
+    /// Gets an identifier which is globally unique to the specified type. This
+    /// function will return the same value for a type regardless of whichever
+    /// crate it is invoked in.
+    pub fn type_id<T: 'static>() -> TypeId;
+
+
+    /// Create a value initialized to zero.
+    ///
+    /// `init` is unsafe because it returns a zeroed-out datum,
+    /// which is unsafe unless T is Pod.
+    pub fn init<T>() -> T;
+
+    /// Create an uninitialized value.
+    pub fn uninit<T>() -> T;
+
+    /// Move a value out of scope without running drop glue.
+    ///
+    /// `forget` is unsafe because the caller is responsible for
+    /// ensuring the argument is deallocated already.
+    pub fn forget<T>(_: T) -> ();
+    pub fn transmute<T,U>(e: T) -> U;
+
+    /// Returns `true` if a type requires drop glue.
+    pub fn needs_drop<T>() -> bool;
+
+    /// Returns `true` if a type is managed (will be allocated on the local heap)
+    pub fn owns_managed<T>() -> bool;
+
+    pub fn visit_tydesc(td: *TyDesc, tv: &mut TyVisitor);
+
+    /// Calculates the offset from a pointer. The offset *must* be in-bounds of
+    /// the object, or one-byte-past-the-end. An arithmetic overflow is also
+    /// undefined behaviour.
+    ///
+    /// This is implemented as an intrinsic to avoid converting to and from an
+    /// integer, since the conversion would throw away aliasing information.
+    pub fn offset<T>(dst: *T, offset: int) -> *T;
+
+    /// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with
+    /// a size of `count` * `size_of::<T>()` and an alignment of
+    /// `min_align_of::<T>()`
+    pub fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *T, count: uint);
+
+    /// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with
+    /// a size of `count` * `size_of::<T>()` and an alignment of
+    /// `min_align_of::<T>()`
+    pub fn copy_memory<T>(dst: *mut T, src: *T, count: uint);
+
+    /// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a
+    /// size of `count` * `size_of::<T>()` and an alignment of
+    /// `min_align_of::<T>()`
+    pub fn set_memory<T>(dst: *mut T, val: u8, count: uint);
+
+    pub fn sqrtf32(x: f32) -> f32;
+    pub fn sqrtf64(x: f64) -> f64;
+
+    pub fn powif32(a: f32, x: i32) -> f32;
+    pub fn powif64(a: f64, x: i32) -> f64;
+
+    pub fn sinf32(x: f32) -> f32;
+    pub fn sinf64(x: f64) -> f64;
+
+    pub fn cosf32(x: f32) -> f32;
+    pub fn cosf64(x: f64) -> f64;
+
+    pub fn powf32(a: f32, x: f32) -> f32;
+    pub fn powf64(a: f64, x: f64) -> f64;
+
+    pub fn expf32(x: f32) -> f32;
+    pub fn expf64(x: f64) -> f64;
+
+    pub fn exp2f32(x: f32) -> f32;
+    pub fn exp2f64(x: f64) -> f64;
+
+    pub fn logf32(x: f32) -> f32;
+    pub fn logf64(x: f64) -> f64;
+
+    pub fn log10f32(x: f32) -> f32;
+    pub fn log10f64(x: f64) -> f64;
+
+    pub fn log2f32(x: f32) -> f32;
+    pub fn log2f64(x: f64) -> f64;
+
+    pub fn fmaf32(a: f32, b: f32, c: f32) -> f32;
+    pub fn fmaf64(a: f64, b: f64, c: f64) -> f64;
+
+    pub fn fabsf32(x: f32) -> f32;
+    pub fn fabsf64(x: f64) -> f64;
+
+    pub fn copysignf32(x: f32, y: f32) -> f32;
+    pub fn copysignf64(x: f64, y: f64) -> f64;
+
+    pub fn floorf32(x: f32) -> f32;
+    pub fn floorf64(x: f64) -> f64;
+
+    pub fn ceilf32(x: f32) -> f32;
+    pub fn ceilf64(x: f64) -> f64;
+
+    pub fn truncf32(x: f32) -> f32;
+    pub fn truncf64(x: f64) -> f64;
+
+    pub fn rintf32(x: f32) -> f32;
+    pub fn rintf64(x: f64) -> f64;
+
+    pub fn nearbyintf32(x: f32) -> f32;
+    pub fn nearbyintf64(x: f64) -> f64;
+
+    pub fn roundf32(x: f32) -> f32;
+    pub fn roundf64(x: f64) -> f64;
+
+    pub fn ctpop8(x: i8) -> i8;
+    pub fn ctpop16(x: i16) -> i16;
+    pub fn ctpop32(x: i32) -> i32;
+    pub fn ctpop64(x: i64) -> i64;
+
+    pub fn ctlz8(x: i8) -> i8;
+    pub fn ctlz16(x: i16) -> i16;
+    pub fn ctlz32(x: i32) -> i32;
+    pub fn ctlz64(x: i64) -> i64;
+
+    pub fn cttz8(x: i8) -> i8;
+    pub fn cttz16(x: i16) -> i16;
+    pub fn cttz32(x: i32) -> i32;
+    pub fn cttz64(x: i64) -> i64;
+
+    pub fn bswap16(x: i16) -> i16;
+    pub fn bswap32(x: i32) -> i32;
+    pub fn bswap64(x: i64) -> i64;
+
+    pub fn i8_add_with_overflow(x: i8, y: i8) -> (i8, bool);
+    pub fn i16_add_with_overflow(x: i16, y: i16) -> (i16, bool);
+    pub fn i32_add_with_overflow(x: i32, y: i32) -> (i32, bool);
+    pub fn i64_add_with_overflow(x: i64, y: i64) -> (i64, bool);
+
+    pub fn u8_add_with_overflow(x: u8, y: u8) -> (u8, bool);
+    pub fn u16_add_with_overflow(x: u16, y: u16) -> (u16, bool);
+    pub fn u32_add_with_overflow(x: u32, y: u32) -> (u32, bool);
+    pub fn u64_add_with_overflow(x: u64, y: u64) -> (u64, bool);
+
+    pub fn i8_sub_with_overflow(x: i8, y: i8) -> (i8, bool);
+    pub fn i16_sub_with_overflow(x: i16, y: i16) -> (i16, bool);
+    pub fn i32_sub_with_overflow(x: i32, y: i32) -> (i32, bool);
+    pub fn i64_sub_with_overflow(x: i64, y: i64) -> (i64, bool);
+
+    pub fn u8_sub_with_overflow(x: u8, y: u8) -> (u8, bool);
+    pub fn u16_sub_with_overflow(x: u16, y: u16) -> (u16, bool);
+    pub fn u32_sub_with_overflow(x: u32, y: u32) -> (u32, bool);
+    pub fn u64_sub_with_overflow(x: u64, y: u64) -> (u64, bool);
+
+    pub fn i8_mul_with_overflow(x: i8, y: i8) -> (i8, bool);
+    pub fn i16_mul_with_overflow(x: i16, y: i16) -> (i16, bool);
+    pub fn i32_mul_with_overflow(x: i32, y: i32) -> (i32, bool);
+    pub fn i64_mul_with_overflow(x: i64, y: i64) -> (i64, bool);
+
+    pub fn u8_mul_with_overflow(x: u8, y: u8) -> (u8, bool);
+    pub fn u16_mul_with_overflow(x: u16, y: u16) -> (u16, bool);
+    pub fn u32_mul_with_overflow(x: u32, y: u32) -> (u32, bool);
+    pub fn u64_mul_with_overflow(x: u64, y: u64) -> (u64, bool);
+}
+
+
+/// `TypeId` represents a globally unique identifier for a type
+#[lang="type_id"] // This needs to be kept in lockstep with the code in trans/intrinsic.rs and
+                  // middle/lang_items.rs
+#[deriving(Eq, IterBytes)]
+#[cfg(not(test))]
+pub struct TypeId {
+    priv t: u64,
+}
+
+#[cfg(not(test))]
+impl TypeId {
+    /// Returns the `TypeId` of the type this generic function has been instantiated with
+    pub fn of<T: 'static>() -> TypeId {
+        unsafe { type_id::<T>() }
+    }
+}
index 6996cba42b40ee379989d51868ff7ea7dc0dafa7..4695897448485deaba2db910b9acc33af6004fc1 100644 (file)
 // Private APIs
 #[unstable]
 pub mod unstable;
-
+#[experimental]
+pub mod intrinsics;
 
 /* For internal use, not exported */
 
index 043da46ba5e2c24173325da3e8d0a65316de941c..6b854daabda851d3abc8a207034c54131a1be80b 100644 (file)
@@ -281,7 +281,7 @@ fn get_with<T:'static,
 }
 
 fn abort() -> ! {
-    use std::unstable::intrinsics;
+    use intrinsics;
     unsafe { intrinsics::abort() }
 }
 
index 11053f01ded09222d8653d9bb173a40b425832b3..603f2b80eea7a28e6375f91ca3e73f38c83e390e 100644 (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]
index da3f2c1636fe010e8aff00e039cc2746710645b6..7b1fe949199cd69595c3aee9de184491ad9b4ba6 100644 (file)
@@ -20,7 +20,7 @@
 use num::{Zero, One, Bounded, strconv};
 use num;
 use to_str;
-use unstable::intrinsics;
+use intrinsics;
 
 macro_rules! delegate(
     (
index 24165cbef50b9a76b68c9b3bbd494e901208a9bd..d5a571cdd23716d3346032798a1d2fa26290e3ff 100644 (file)
@@ -21,7 +21,7 @@
 use num::{Zero, One, Bounded, strconv};
 use num;
 use to_str;
-use unstable::intrinsics;
+use intrinsics;
 
 pub use cmp::{min, max};
 
index cbeff5d4aa21ee8eed9ed8f5816042b07cf1ffbd..141626ed98a7548562ff183b340b0c3e07b5dcce 100644 (file)
@@ -20,7 +20,7 @@
 use num::{ToStrRadix, FromStrRadix};
 use option::{Option, Some, None};
 use str;
-use unstable::intrinsics;
+use intrinsics;
 
 int_module!(i16, 16)
 
index 9afc1a145453ea425e0f8661ef207d9c1d7fcd71..a43a6e6a288cdb2de7a3b66f2c0f5a1d8cdc3e2a 100644 (file)
@@ -20,7 +20,7 @@
 use num::{ToStrRadix, FromStrRadix};
 use option::{Option, Some, None};
 use str;
-use unstable::intrinsics;
+use intrinsics;
 
 int_module!(i32, 32)
 
index f1e9f5a4fdc06f3c39f09a76e2fab81f6de0efe0..e8503d808a70320ef7f0ce4d7ae52dd237e93e6a 100644 (file)
@@ -22,7 +22,7 @@
 use num::{ToStrRadix, FromStrRadix};
 use option::{Option, Some, None};
 use str;
-use unstable::intrinsics;
+use intrinsics;
 
 int_module!(i64, 64)
 
index e0e549b731a07b8a22996d34313f6083a57c86c5..9f857ff40ff508cbf82723fdc34fd8bc1de818dd 100644 (file)
@@ -20,7 +20,7 @@
 use num::{ToStrRadix, FromStrRadix};
 use option::{Option, Some, None};
 use str;
-use unstable::intrinsics;
+use intrinsics;
 
 int_module!(i8, 8)
 
index d525639045e73ebbc60b13658405cc214a4ecab3..6d1a50b724fd267182f9a9e1d62723e24d69196d 100644 (file)
@@ -20,7 +20,7 @@
 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)
index 770db889af55f1cd915462089780275beb4378a7..da0293b3418649265691af68fc8f080f788db2b9 100644 (file)
@@ -21,7 +21,7 @@
 use num::{ToStrRadix, FromStrRadix};
 use option::{Option, Some, None};
 use str;
-use unstable::intrinsics;
+use intrinsics;
 
 uint_module!(u16, i16, 16)
 
index 9e08ffed3b70bbd3c7d80e649f360f7c24bad179..b103e18f7019f0a4ad1e8f98d027f3c00cddc419 100644 (file)
@@ -21,7 +21,7 @@
 use num::{ToStrRadix, FromStrRadix};
 use option::{Option, Some, None};
 use str;
-use unstable::intrinsics;
+use intrinsics;
 
 uint_module!(u32, i32, 32)
 
index 17eebed967c6f788b5be8c7eb21a4619cb2e72d7..f7956f0128e5e76e14a6ce6c3f47132433c59e20 100644 (file)
@@ -23,7 +23,7 @@
 use num::{ToStrRadix, FromStrRadix};
 use option::{Option, Some, None};
 use str;
-use unstable::intrinsics;
+use intrinsics;
 
 uint_module!(u64, i64, 64)
 
index 4aa34b6d880444a08b14e75ac08c91158bf25c70..e6ce9c72e96b2f3de021067d262d409f6e8d7e0e 100644 (file)
@@ -21,7 +21,7 @@
 use num::{ToStrRadix, FromStrRadix};
 use option::{Option, Some, None};
 use str;
-use unstable::intrinsics;
+use intrinsics;
 
 uint_module!(u8, i8, 8)
 
index 1811ebc7acc041424e30d7f272c1edcdc4b46b69..a8c85787f7ec852bee7d0440fc104f581ebc0c7f 100644 (file)
@@ -21,7 +21,7 @@
 use num::{ToStrRadix, FromStrRadix};
 use option::{Option, Some, None};
 use str;
-use unstable::intrinsics;
+use intrinsics;
 
 uint_module!(uint, int, ::int::BITS)
 
index 193e9ea7052f0cd0b48cfdfb81a1c4bc56f947ab..86264c1ca5507e9728006bfd4367b8919468fc5f 100644 (file)
@@ -17,7 +17,7 @@
 use iter::{range, Iterator};
 use mem;
 use option::{Option, Some, None};
-use unstable::intrinsics;
+use intrinsics;
 
 #[cfg(not(test))] use cmp::{Eq, Ord};
 
index f88da60ae9b7971a219783371273635ad6e5a1a8..5ee840748e67cc8a8791ac5f41fd66352bf3cf71 100644 (file)
@@ -16,7 +16,7 @@
 
 #[allow(missing_doc)];
 
-use unstable::intrinsics::{Disr, Opaque, TyDesc, TyVisitor};
+use intrinsics::{Disr, Opaque, TyDesc, TyVisitor};
 use mem;
 use unstable::raw;
 
index 680ac11230021b8a377d54e20959f42d22a1fa27..8e1a0714748541801ae2796d8d85e8dcd1ce8419 100644 (file)
@@ -29,7 +29,7 @@
 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) => (
index 8128bb021487d50a1c577b0bc281b8f6b67d6841..191d57a58fc66dd892698e76126f9b67d85d07a1 100644 (file)
@@ -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;
 
index ef8bd94c89766f1883ff51eb4bbfc2502eb2f652..127859b42756b1d7fdd47fc7ed70f4ac38aecee0 100644 (file)
@@ -69,7 +69,7 @@
 use rt::task::Task;
 use str::Str;
 use task::TaskResult;
-use unstable::intrinsics;
+use intrinsics;
 
 use uw = self::libunwind;
 
index 69e240f30bcf026af4a40d3e98a85f800ac6f815..408f51f2017e0c4c6ac113eb5c394f8387fb8ed0 100644 (file)
@@ -143,7 +143,7 @@ pub fn abort(msg: &str) -> ! {
     abort();
 
     fn abort() -> ! {
-        use std::unstable::intrinsics;
+        use intrinsics;
         unsafe { intrinsics::abort() }
     }
 }
index 00ce07d747f94784abf89fc32c1e245214cba626..b4d465c0397de4d87090e19d506d703167c163e3 100644 (file)
@@ -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/intrinsics.rs b/src/libstd/unstable/intrinsics.rs
deleted file mode 100644 (file)
index c983d82..0000000
+++ /dev/null
@@ -1,457 +0,0 @@
-// Copyright 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.
-
-/*! rustc compiler intrinsics.
-
-The corresponding definitions are in librustc/middle/trans/foreign.rs.
-
-# Volatiles
-
-The volatile intrinsics provide operations intended to act on I/O
-memory, which are guaranteed to not be reordered by the compiler
-across other volatile intrinsics. See the LLVM documentation on
-[[volatile]].
-
-[volatile]: http://llvm.org/docs/LangRef.html#volatile-memory-accesses
-
-# Atomics
-
-The atomic intrinsics provide common atomic operations on machine
-words, with multiple possible memory orderings. They obey the same
-semantics as C++11. See the LLVM documentation on [[atomics]].
-
-[atomics]: http://llvm.org/docs/Atomics.html
-
-A quick refresher on memory ordering:
-
-* Acquire - a barrier for acquiring a lock. Subsequent reads and writes
-  take place after the barrier.
-* Release - a barrier for releasing a lock. Preceding reads and writes
-  take place before the barrier.
-* Sequentially consistent - sequentially consistent operations are
-  guaranteed to happen in order. This is the standard mode for working
-  with atomic types and is equivalent to Java's `volatile`.
-
-*/
-
-// This is needed to prevent duplicate lang item definitions.
-#[cfg(test)]
-pub use realstd::unstable::intrinsics::{TyDesc, Opaque, TyVisitor, TypeId};
-
-pub type GlueFn = extern "Rust" fn(*i8);
-
-#[lang="ty_desc"]
-#[cfg(not(test))]
-pub struct TyDesc {
-    // sizeof(T)
-    size: uint,
-
-    // alignof(T)
-    align: uint,
-
-    // Called when a value of type `T` is no longer needed
-    drop_glue: GlueFn,
-
-    // Called by reflection visitor to visit a value of type `T`
-    visit_glue: GlueFn,
-
-    // Name corresponding to the type
-    name: &'static str
-}
-
-#[lang="opaque"]
-#[cfg(not(test))]
-pub enum Opaque { }
-
-pub type Disr = u64;
-
-#[lang="ty_visitor"]
-#[cfg(not(test))]
-pub trait TyVisitor {
-    fn visit_bot(&mut self) -> bool;
-    fn visit_nil(&mut self) -> bool;
-    fn visit_bool(&mut self) -> bool;
-
-    fn visit_int(&mut self) -> bool;
-    fn visit_i8(&mut self) -> bool;
-    fn visit_i16(&mut self) -> bool;
-    fn visit_i32(&mut self) -> bool;
-    fn visit_i64(&mut self) -> bool;
-
-    fn visit_uint(&mut self) -> bool;
-    fn visit_u8(&mut self) -> bool;
-    fn visit_u16(&mut self) -> bool;
-    fn visit_u32(&mut self) -> bool;
-    fn visit_u64(&mut self) -> bool;
-
-    fn visit_f32(&mut self) -> bool;
-    fn visit_f64(&mut self) -> bool;
-
-    fn visit_char(&mut self) -> bool;
-
-    fn visit_estr_box(&mut self) -> bool;
-    fn visit_estr_uniq(&mut self) -> bool;
-    fn visit_estr_slice(&mut self) -> bool;
-    fn visit_estr_fixed(&mut self, n: uint, sz: uint, align: uint) -> bool;
-
-    fn visit_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
-    fn visit_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
-    fn visit_ptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
-    fn visit_rptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
-
-    fn visit_vec(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
-    fn visit_unboxed_vec(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
-    fn visit_evec_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
-    fn visit_evec_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
-    fn visit_evec_slice(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
-    fn visit_evec_fixed(&mut self, n: uint, sz: uint, align: uint,
-                        mtbl: uint, inner: *TyDesc) -> bool;
-
-    fn visit_enter_rec(&mut self, n_fields: uint,
-                       sz: uint, align: uint) -> bool;
-    fn visit_rec_field(&mut self, i: uint, name: &str,
-                       mtbl: uint, inner: *TyDesc) -> bool;
-    fn visit_leave_rec(&mut self, n_fields: uint,
-                       sz: uint, align: uint) -> bool;
-
-    fn visit_enter_class(&mut self, name: &str, named_fields: bool, n_fields: uint,
-                         sz: uint, align: uint) -> bool;
-    fn visit_class_field(&mut self, i: uint, name: &str, named: bool,
-                         mtbl: uint, inner: *TyDesc) -> bool;
-    fn visit_leave_class(&mut self, name: &str, named_fields: bool, n_fields: uint,
-                         sz: uint, align: uint) -> bool;
-
-    fn visit_enter_tup(&mut self, n_fields: uint,
-                       sz: uint, align: uint) -> bool;
-    fn visit_tup_field(&mut self, i: uint, inner: *TyDesc) -> bool;
-    fn visit_leave_tup(&mut self, n_fields: uint,
-                       sz: uint, align: uint) -> bool;
-
-    fn visit_enter_enum(&mut self, n_variants: uint,
-                        get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
-                        sz: uint, align: uint) -> bool;
-    fn visit_enter_enum_variant(&mut self, variant: uint,
-                                disr_val: Disr,
-                                n_fields: uint,
-                                name: &str) -> bool;
-    fn visit_enum_variant_field(&mut self, i: uint, offset: uint, inner: *TyDesc) -> bool;
-    fn visit_leave_enum_variant(&mut self, variant: uint,
-                                disr_val: Disr,
-                                n_fields: uint,
-                                name: &str) -> bool;
-    fn visit_leave_enum(&mut self, n_variants: uint,
-                        get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
-                        sz: uint, align: uint) -> bool;
-
-    fn visit_enter_fn(&mut self, purity: uint, proto: uint,
-                      n_inputs: uint, retstyle: uint) -> bool;
-    fn visit_fn_input(&mut self, i: uint, mode: uint, inner: *TyDesc) -> bool;
-    fn visit_fn_output(&mut self, retstyle: uint, variadic: bool, inner: *TyDesc) -> bool;
-    fn visit_leave_fn(&mut self, purity: uint, proto: uint,
-                      n_inputs: uint, retstyle: uint) -> bool;
-
-    fn visit_trait(&mut self, name: &str) -> bool;
-    fn visit_param(&mut self, i: uint) -> bool;
-    fn visit_self(&mut self) -> bool;
-}
-
-extern "rust-intrinsic" {
-    pub fn atomic_cxchg<T>(dst: &mut T, old: T, src: T) -> T;
-    pub fn atomic_cxchg_acq<T>(dst: &mut T, old: T, src: T) -> T;
-    pub fn atomic_cxchg_rel<T>(dst: &mut T, old: T, src: T) -> T;
-    pub fn atomic_cxchg_acqrel<T>(dst: &mut T, old: T, src: T) -> T;
-    pub fn atomic_cxchg_relaxed<T>(dst: &mut T, old: T, src: T) -> T;
-
-    pub fn atomic_load<T>(src: &T) -> T;
-    pub fn atomic_load_acq<T>(src: &T) -> T;
-    pub fn atomic_load_relaxed<T>(src: &T) -> T;
-
-    pub fn atomic_store<T>(dst: &mut T, val: T);
-    pub fn atomic_store_rel<T>(dst: &mut T, val: T);
-    pub fn atomic_store_relaxed<T>(dst: &mut T, val: T);
-
-    pub fn atomic_xchg<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xchg_acq<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xchg_rel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xchg_acqrel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xchg_relaxed<T>(dst: &mut T, src: T) -> T;
-
-    pub fn atomic_xadd<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xadd_acq<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xadd_rel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xadd_acqrel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xadd_relaxed<T>(dst: &mut T, src: T) -> T;
-
-    pub fn atomic_xsub<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xsub_acq<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xsub_rel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xsub_acqrel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xsub_relaxed<T>(dst: &mut T, src: T) -> T;
-
-    pub fn atomic_and<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_and_acq<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_and_rel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_and_acqrel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_and_relaxed<T>(dst: &mut T, src: T) -> T;
-
-    pub fn atomic_nand<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_nand_acq<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_nand_rel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_nand_acqrel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_nand_relaxed<T>(dst: &mut T, src: T) -> T;
-
-    pub fn atomic_or<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_or_acq<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_or_rel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_or_acqrel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_or_relaxed<T>(dst: &mut T, src: T) -> T;
-
-    pub fn atomic_xor<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xor_acq<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xor_rel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xor_acqrel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_xor_relaxed<T>(dst: &mut T, src: T) -> T;
-
-    pub fn atomic_max<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_max_acq<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_max_rel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_max_acqrel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_max_relaxed<T>(dst: &mut T, src: T) -> T;
-
-    pub fn atomic_min<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_min_acq<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_min_rel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_min_acqrel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_min_relaxed<T>(dst: &mut T, src: T) -> T;
-
-    pub fn atomic_umin<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_umin_acq<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_umin_rel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_umin_acqrel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_umin_relaxed<T>(dst: &mut T, src: T) -> T;
-
-    pub fn atomic_umax<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_umax_acq<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_umax_rel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_umax_acqrel<T>(dst: &mut T, src: T) -> T;
-    pub fn atomic_umax_relaxed<T>(dst: &mut T, src: T) -> T;
-
-    pub fn atomic_fence();
-    pub fn atomic_fence_acq();
-    pub fn atomic_fence_rel();
-    pub fn atomic_fence_acqrel();
-
-    /// Abort the execution of the process.
-    pub fn abort() -> !;
-
-    /// Execute a breakpoint trap, for inspection by a debugger.
-    pub fn breakpoint();
-
-    pub fn volatile_load<T>(src: *T) -> T;
-    pub fn volatile_store<T>(dst: *mut T, val: T);
-
-
-    /// The size of a type in bytes.
-    ///
-    /// This is the exact number of bytes in memory taken up by a
-    /// value of the given type. In other words, a memset of this size
-    /// would *exactly* overwrite a value. When laid out in vectors
-    /// and structures there may be additional padding between
-    /// elements.
-    pub fn size_of<T>() -> uint;
-
-    /// Move a value to an uninitialized memory location.
-    ///
-    /// Drop glue is not run on the destination.
-    pub fn move_val_init<T>(dst: &mut T, src: T);
-
-    pub fn min_align_of<T>() -> uint;
-    pub fn pref_align_of<T>() -> uint;
-
-    /// Get a static pointer to a type descriptor.
-    pub fn get_tydesc<T>() -> *TyDesc;
-
-    /// Gets an identifier which is globally unique to the specified type. This
-    /// function will return the same value for a type regardless of whichever
-    /// crate it is invoked in.
-    pub fn type_id<T: 'static>() -> TypeId;
-
-
-    /// Create a value initialized to zero.
-    ///
-    /// `init` is unsafe because it returns a zeroed-out datum,
-    /// which is unsafe unless T is Pod.
-    pub fn init<T>() -> T;
-
-    /// Create an uninitialized value.
-    pub fn uninit<T>() -> T;
-
-    /// Move a value out of scope without running drop glue.
-    ///
-    /// `forget` is unsafe because the caller is responsible for
-    /// ensuring the argument is deallocated already.
-    pub fn forget<T>(_: T) -> ();
-    pub fn transmute<T,U>(e: T) -> U;
-
-    /// Returns `true` if a type requires drop glue.
-    pub fn needs_drop<T>() -> bool;
-
-    /// Returns `true` if a type is managed (will be allocated on the local heap)
-    pub fn owns_managed<T>() -> bool;
-
-    pub fn visit_tydesc(td: *TyDesc, tv: &mut TyVisitor);
-
-    /// Calculates the offset from a pointer. The offset *must* be in-bounds of
-    /// the object, or one-byte-past-the-end. An arithmetic overflow is also
-    /// undefined behaviour.
-    ///
-    /// This is implemented as an intrinsic to avoid converting to and from an
-    /// integer, since the conversion would throw away aliasing information.
-    pub fn offset<T>(dst: *T, offset: int) -> *T;
-
-    /// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with
-    /// a size of `count` * `size_of::<T>()` and an alignment of
-    /// `min_align_of::<T>()`
-    pub fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *T, count: uint);
-
-    /// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with
-    /// a size of `count` * `size_of::<T>()` and an alignment of
-    /// `min_align_of::<T>()`
-    pub fn copy_memory<T>(dst: *mut T, src: *T, count: uint);
-
-    /// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a
-    /// size of `count` * `size_of::<T>()` and an alignment of
-    /// `min_align_of::<T>()`
-    pub fn set_memory<T>(dst: *mut T, val: u8, count: uint);
-
-    pub fn sqrtf32(x: f32) -> f32;
-    pub fn sqrtf64(x: f64) -> f64;
-
-    pub fn powif32(a: f32, x: i32) -> f32;
-    pub fn powif64(a: f64, x: i32) -> f64;
-
-    pub fn sinf32(x: f32) -> f32;
-    pub fn sinf64(x: f64) -> f64;
-
-    pub fn cosf32(x: f32) -> f32;
-    pub fn cosf64(x: f64) -> f64;
-
-    pub fn powf32(a: f32, x: f32) -> f32;
-    pub fn powf64(a: f64, x: f64) -> f64;
-
-    pub fn expf32(x: f32) -> f32;
-    pub fn expf64(x: f64) -> f64;
-
-    pub fn exp2f32(x: f32) -> f32;
-    pub fn exp2f64(x: f64) -> f64;
-
-    pub fn logf32(x: f32) -> f32;
-    pub fn logf64(x: f64) -> f64;
-
-    pub fn log10f32(x: f32) -> f32;
-    pub fn log10f64(x: f64) -> f64;
-
-    pub fn log2f32(x: f32) -> f32;
-    pub fn log2f64(x: f64) -> f64;
-
-    pub fn fmaf32(a: f32, b: f32, c: f32) -> f32;
-    pub fn fmaf64(a: f64, b: f64, c: f64) -> f64;
-
-    pub fn fabsf32(x: f32) -> f32;
-    pub fn fabsf64(x: f64) -> f64;
-
-    pub fn copysignf32(x: f32, y: f32) -> f32;
-    pub fn copysignf64(x: f64, y: f64) -> f64;
-
-    pub fn floorf32(x: f32) -> f32;
-    pub fn floorf64(x: f64) -> f64;
-
-    pub fn ceilf32(x: f32) -> f32;
-    pub fn ceilf64(x: f64) -> f64;
-
-    pub fn truncf32(x: f32) -> f32;
-    pub fn truncf64(x: f64) -> f64;
-
-    pub fn rintf32(x: f32) -> f32;
-    pub fn rintf64(x: f64) -> f64;
-
-    pub fn nearbyintf32(x: f32) -> f32;
-    pub fn nearbyintf64(x: f64) -> f64;
-
-    pub fn roundf32(x: f32) -> f32;
-    pub fn roundf64(x: f64) -> f64;
-
-    pub fn ctpop8(x: i8) -> i8;
-    pub fn ctpop16(x: i16) -> i16;
-    pub fn ctpop32(x: i32) -> i32;
-    pub fn ctpop64(x: i64) -> i64;
-
-    pub fn ctlz8(x: i8) -> i8;
-    pub fn ctlz16(x: i16) -> i16;
-    pub fn ctlz32(x: i32) -> i32;
-    pub fn ctlz64(x: i64) -> i64;
-
-    pub fn cttz8(x: i8) -> i8;
-    pub fn cttz16(x: i16) -> i16;
-    pub fn cttz32(x: i32) -> i32;
-    pub fn cttz64(x: i64) -> i64;
-
-    pub fn bswap16(x: i16) -> i16;
-    pub fn bswap32(x: i32) -> i32;
-    pub fn bswap64(x: i64) -> i64;
-
-    pub fn i8_add_with_overflow(x: i8, y: i8) -> (i8, bool);
-    pub fn i16_add_with_overflow(x: i16, y: i16) -> (i16, bool);
-    pub fn i32_add_with_overflow(x: i32, y: i32) -> (i32, bool);
-    pub fn i64_add_with_overflow(x: i64, y: i64) -> (i64, bool);
-
-    pub fn u8_add_with_overflow(x: u8, y: u8) -> (u8, bool);
-    pub fn u16_add_with_overflow(x: u16, y: u16) -> (u16, bool);
-    pub fn u32_add_with_overflow(x: u32, y: u32) -> (u32, bool);
-    pub fn u64_add_with_overflow(x: u64, y: u64) -> (u64, bool);
-
-    pub fn i8_sub_with_overflow(x: i8, y: i8) -> (i8, bool);
-    pub fn i16_sub_with_overflow(x: i16, y: i16) -> (i16, bool);
-    pub fn i32_sub_with_overflow(x: i32, y: i32) -> (i32, bool);
-    pub fn i64_sub_with_overflow(x: i64, y: i64) -> (i64, bool);
-
-    pub fn u8_sub_with_overflow(x: u8, y: u8) -> (u8, bool);
-    pub fn u16_sub_with_overflow(x: u16, y: u16) -> (u16, bool);
-    pub fn u32_sub_with_overflow(x: u32, y: u32) -> (u32, bool);
-    pub fn u64_sub_with_overflow(x: u64, y: u64) -> (u64, bool);
-
-    pub fn i8_mul_with_overflow(x: i8, y: i8) -> (i8, bool);
-    pub fn i16_mul_with_overflow(x: i16, y: i16) -> (i16, bool);
-    pub fn i32_mul_with_overflow(x: i32, y: i32) -> (i32, bool);
-    pub fn i64_mul_with_overflow(x: i64, y: i64) -> (i64, bool);
-
-    pub fn u8_mul_with_overflow(x: u8, y: u8) -> (u8, bool);
-    pub fn u16_mul_with_overflow(x: u16, y: u16) -> (u16, bool);
-    pub fn u32_mul_with_overflow(x: u32, y: u32) -> (u32, bool);
-    pub fn u64_mul_with_overflow(x: u64, y: u64) -> (u64, bool);
-}
-
-
-/// `TypeId` represents a globally unique identifier for a type
-#[lang="type_id"] // This needs to be kept in lockstep with the code in trans/intrinsic.rs and
-                  // middle/lang_items.rs
-#[deriving(Eq, IterBytes)]
-#[cfg(not(test))]
-pub struct TypeId {
-    priv t: u64,
-}
-
-#[cfg(not(test))]
-impl TypeId {
-    /// Returns the `TypeId` of the type this generic function has been instantiated with
-    pub fn of<T: 'static>() -> TypeId {
-        unsafe { type_id::<T>() }
-    }
-}
index 87870ef033142c5b28998485babfaae2ab411907..d3dae938b34dcfc877f4aa24b7ac4f8bd9e1735b 100644 (file)
@@ -16,7 +16,6 @@
 pub mod dynamic_lib;
 
 pub mod finally;
-pub mod intrinsics;
 pub mod simd;
 #[cfg(not(test))]
 pub mod lang;
index 90c7888973afdab8a29779e9921799f1603ee554..655c209fec8744605ee5e8c9add72be4f87a7421 100644 (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
index 9bb867372619a2e650be659935f31d4dbc51b9d2..b6c35f48010ca1fcfd42e2035684246a2b0904fd 100644 (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>);
index 9bb867372619a2e650be659935f31d4dbc51b9d2..b6c35f48010ca1fcfd42e2035684246a2b0904fd 100644 (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>);
index 56390b70ab3bc32cfac347204707e4f5333f5f27..b77180e8e4ccf2da681a2421cefd5cb6c6883229 100644 (file)
@@ -18,7 +18,7 @@
 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
index 9ad7a178fb188ae84d205b72bc25d03780775331..12df0c71cc57e0952681964c314e00677029aac9 100644 (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() {
index 5011a7540a726413269979ef83da184fb832f651..6dffb53e4a319754c20e37b14992f6f887284cac 100644 (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 {
index 48a02063c6d2e8713a7c95d99703031c657bf063..9e6293216bc116b18bac39236c8673b0553b241b 100644 (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 {
index 56db021e2bc29ff4607a72f16a7e7684e0b043fc..f81ddabf77c7ff1dded1e1d3518acb6a05273cd1 100644 (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],
index ea337aae27bcb0ac02d50725a6d34b7097ba28c3..b3835ad5cdfad32204c2abac1dbf4f4b32a5bd93 100644 (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
index 2d5c1d100be8b91cdbdb92688305050157c4f753..b8356cc0e448e0939cbfc66874015098d4da0340 100644 (file)
@@ -16,8 +16,8 @@
 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;