// 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);
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
#[cfg(not(test))]
pub enum Opaque { }
-#[cfg(stage0)]
-pub type Disr = int;
-#[cfg(not(stage0))]
pub type Disr = u64;
#[lang="ty_visitor"]
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;
/// 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.
/// 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,
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);
/// 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;
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;
#[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>() }
+ }
+}