about summary refs log tree commit diff
path: root/src/libstd/cleanup.rs
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-07-02 17:36:58 -0700
committerBrian Anderson <banderson@mozilla.com>2013-07-03 14:49:13 -0700
commit1098d6980b13dc00e3f20deae987423e3bcae9ce (patch)
tree4d6cfd62f1d0d3298d4144aebd6c81c91edea9dc /src/libstd/cleanup.rs
parentf8a4d09f7efb618ca3f8b70374e158504cb33cb0 (diff)
parentab34864a304fa364dc91bf16988e272e93de8d62 (diff)
downloadrust-1098d6980b13dc00e3f20deae987423e3bcae9ce.tar.gz
rust-1098d6980b13dc00e3f20deae987423e3bcae9ce.zip
Merge remote-tracking branch 'mozilla/master'
Conflicts:
	src/libextra/test.rs
	src/libstd/at_vec.rs
	src/libstd/cleanup.rs
	src/libstd/rt/comm.rs
	src/libstd/rt/global_heap.rs
	src/libstd/task/spawn.rs
	src/libstd/unstable/lang.rs
	src/libstd/vec.rs
	src/rt/rustrt.def.in
	src/test/run-pass/extern-pub.rs
Diffstat (limited to 'src/libstd/cleanup.rs')
-rw-r--r--src/libstd/cleanup.rs33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/libstd/cleanup.rs b/src/libstd/cleanup.rs
index 36c1fdf781b..abda76c9ca6 100644
--- a/src/libstd/cleanup.rs
+++ b/src/libstd/cleanup.rs
@@ -10,17 +10,13 @@
 
 #[doc(hidden)];
 
-use libc::{c_char, c_void, intptr_t, uintptr_t};
-use ptr::mut_null;
+use libc::c_void;
+use ptr::{mut_null};
 use repr::BoxRepr;
-use rt;
-use rt::OldTaskContext;
-use sys::TypeDesc;
 use cast::transmute;
+use unstable::intrinsics::TyDesc;
 
-#[cfg(not(test))] use ptr::to_unsafe_ptr;
-
-type DropGlue<'self> = &'self fn(**TypeDesc, *c_void);
+type DropGlue<'self> = &'self fn(**TyDesc, *c_void);
 
 /*
  * Box annihilation
@@ -63,6 +59,8 @@ unsafe fn each_live_alloc(read_next_before: bool,
 
 #[cfg(unix)]
 fn debug_mem() -> bool {
+    use rt;
+    use rt::OldTaskContext;
     // XXX: Need to port the environment struct to newsched
     match rt::context() {
         OldTaskContext => ::rt::env::get().debug_mem,
@@ -75,6 +73,19 @@ fn debug_mem() -> bool {
     false
 }
 
+#[inline]
+#[cfg(not(stage0))]
+unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
+    // This function should be inlined when stage0 is gone
+    ((*tydesc).drop_glue)(data);
+}
+
+#[inline]
+#[cfg(stage0)]
+unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
+    ((*tydesc).drop_glue)(0 as **TyDesc, data);
+}
+
 /// Destroys all managed memory (i.e. @ boxes) held by the current task.
 pub unsafe fn annihilate() {
     use rt::local_heap::local_free;
@@ -115,9 +126,9 @@ pub unsafe fn annihilate() {
     // callback, as the original value may have been freed.
     for each_live_alloc(false) |box, uniq| {
         if !uniq {
-            let tydesc: *TypeDesc = transmute(copy (*box).header.type_desc);
-            let drop_glue: DropGlue = transmute(((*tydesc).drop_glue, 0));
-            drop_glue(&tydesc, transmute(&(*box).data));
+            let tydesc: *TyDesc = transmute(copy (*box).header.type_desc);
+            let data = transmute(&(*box).data);
+            call_drop_glue(tydesc, data);
         }
     }