]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/unstable/intrinsics.rs
Register new snapshots
[rust.git] / src / libstd / unstable / intrinsics.rs
index 20563718a6c1fdd42cb0c647797c411990448c5c..d3649f0285caa221c98dac1df5faef36c395e537 100644 (file)
@@ -34,7 +34,7 @@
 
 // This is needed to prevent duplicate lang item definitions.
 #[cfg(test)]
-pub use realstd::unstable::intrinsics::{TyDesc, Opaque, TyVisitor};
+pub use realstd::unstable::intrinsics::{TyDesc, Opaque, TyVisitor, TypeId};
 
 pub type GlueFn = extern "Rust" fn(*i8);
 
@@ -49,23 +49,23 @@ pub struct TyDesc {
     align: uint,
 
     // Called on a copy of a value of type `T` *after* memcpy
-    priv take_glue: GlueFn,
+    take_glue: GlueFn,
 
     // Called when a value of type `T` is no longer needed
     drop_glue: GlueFn,
 
     // Called by drop glue when a value of type `T` can be freed
-    priv free_glue: GlueFn,
+    free_glue: GlueFn,
 
     // Called by reflection visitor to visit a value of type `T`
-    priv visit_glue: GlueFn,
+    visit_glue: GlueFn,
 
     // If T represents a box pointer (`@U` or `~U`), then
     // `borrow_offset` is the amount that the pointer must be adjusted
     // to find the payload.  This is always derivable from the type
     // `U`, but in the case of `@Trait` or `~Trait` objects, the type
     // `U` is unknown.
-    priv borrow_offset: uint,
+    borrow_offset: uint,
 
     // Name corresponding to the type
     name: &'static str
@@ -75,9 +75,6 @@ pub struct TyDesc {
 #[cfg(not(test))]
 pub enum Opaque { }
 
-#[cfg(stage0)]
-pub type Disr = int;
-#[cfg(not(stage0))]
 pub type Disr = u64;
 
 #[lang="ty_visitor"]
@@ -163,7 +160,7 @@ fn visit_leave_enum(&mut self, n_variants: uint,
     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, 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;
 
@@ -179,6 +176,9 @@ fn visit_leave_fn(&mut self, purity: uint, proto: uint,
     /// Abort the execution of the process.
     pub fn abort() -> !;
 
+    /// Execute a breakpoint trap, for inspection by a debugger.
+    pub fn breakpoint();
+
     /// Atomic compare and exchange, sequentially consistent.
     pub fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int;
     /// Atomic compare and exchange, acquire ordering.
@@ -310,6 +310,12 @@ fn visit_leave_fn(&mut self, purity: uint, proto: 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,
@@ -331,7 +337,7 @@ fn visit_leave_fn(&mut self, purity: uint, proto: uint,
     pub fn needs_drop<T>() -> bool;
 
     /// Returns `true` if a type is managed (will be allocated on the local heap)
-    pub fn contains_managed<T>() -> bool;
+    pub fn owns_managed<T>() -> bool;
 
     pub fn visit_tydesc(td: *TyDesc, tv: &mut TyVisitor);
 
@@ -346,26 +352,20 @@ fn visit_leave_fn(&mut self, purity: uint, proto: uint,
     /// integer, since the conversion would throw away aliasing information.
     pub fn offset<T>(dst: *T, offset: int) -> *T;
 
-    /// Equivalent to the `llvm.memcpy.p0i8.0i8.i32` intrinsic, with a size of
-    /// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
-    pub fn memcpy32<T>(dst: *mut T, src: *T, count: u32);
-    /// Equivalent to the `llvm.memcpy.p0i8.0i8.i64` intrinsic, with a size of
-    /// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
-    pub fn memcpy64<T>(dst: *mut T, src: *T, count: u64);
-
-    /// Equivalent to the `llvm.memmove.p0i8.0i8.i32` intrinsic, with a size of
-    /// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
-    pub fn memmove32<T>(dst: *mut T, src: *T, count: u32);
-    /// Equivalent to the `llvm.memmove.p0i8.0i8.i64` intrinsic, with a size of
-    /// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
-    pub fn memmove64<T>(dst: *mut T, src: *T, count: u64);
-
-    /// Equivalent to the `llvm.memset.p0i8.i32` intrinsic, with a size of
-    /// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
-    pub fn memset32<T>(dst: *mut T, val: u8, count: u32);
-    /// Equivalent to the `llvm.memset.p0i8.i64` intrinsic, with a size of
-    /// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
-    pub fn memset64<T>(dst: *mut T, val: u8, count: u64);
+    /// 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;
@@ -373,28 +373,16 @@ fn visit_leave_fn(&mut self, purity: uint, proto: uint,
     pub fn powif32(a: f32, x: i32) -> f32;
     pub fn powif64(a: f64, x: i32) -> f64;
 
-    // the following kill the stack canary without
-    // `fixed_stack_segment`. This possibly only affects the f64
-    // variants, but it's hard to be sure since it seems to only
-    // occur with fairly specific arguments.
-    #[fixed_stack_segment]
     pub fn sinf32(x: f32) -> f32;
-    #[fixed_stack_segment]
     pub fn sinf64(x: f64) -> f64;
 
-    #[fixed_stack_segment]
     pub fn cosf32(x: f32) -> f32;
-    #[fixed_stack_segment]
     pub fn cosf64(x: f64) -> f64;
 
-    #[fixed_stack_segment]
     pub fn powf32(a: f32, x: f32) -> f32;
-    #[fixed_stack_segment]
     pub fn powf64(a: f64, x: f64) -> f64;
 
-    #[fixed_stack_segment]
     pub fn expf32(x: f32) -> f32;
-    #[fixed_stack_segment]
     pub fn expf64(x: f64) -> f64;
 
     pub fn exp2f32(x: f32) -> f32;
@@ -499,3 +487,21 @@ fn visit_leave_fn(&mut self, purity: uint, proto: uint,
 #[cfg(target_endian = "big")]    pub fn to_be32(x: i32) -> i32 { x }
 #[cfg(target_endian = "little")] pub fn to_be64(x: i64) -> i64 { unsafe { bswap64(x) } }
 #[cfg(target_endian = "big")]    pub fn to_be64(x: i64) -> i64 { x }
+
+
+/// `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>() }
+    }
+}