]> git.lizzy.rs Git - rust.git/commitdiff
Remove the annihilate function from the crate map. Fixes #8431
authorLuqman Aden <laden@csclub.uwaterloo.ca>
Tue, 24 Sep 2013 17:35:42 +0000 (13:35 -0400)
committerLuqman Aden <laden@csclub.uwaterloo.ca>
Wed, 25 Sep 2013 00:34:11 +0000 (20:34 -0400)
src/librustc/middle/trans/base.rs
src/libstd/rt/crate_map.rs

index 67aee43bc46b472cec2e3fe4bb622e460e009df3..a0b7ed15b29aa773f103f8e96a2e4c51d8719565 100644 (file)
@@ -2949,7 +2949,7 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
     };
     let sym_name = ~"_rust_crate_map_" + mapname;
     let arrtype = Type::array(&int_type, n_subcrates as u64);
-    let maptype = Type::struct_([Type::i32(), Type::i8p(), int_type, arrtype], false);
+    let maptype = Type::struct_([Type::i32(), int_type, arrtype], false);
     let map = do sym_name.with_c_str |buf| {
         unsafe {
             llvm::LLVMAddGlobal(llmod, maptype.to_ref(), buf)
@@ -2990,8 +2990,6 @@ pub fn fill_crate_map(ccx: @mut CrateContext, map: ValueRef) {
         let mod_map = create_module_map(ccx);
         llvm::LLVMSetInitializer(map, C_struct(
             [C_i32(1),
-             // FIXME #8431 This used to be the annihilate function, now it's nothing
-             C_null(Type::i8p()),
              p2i(ccx, mod_map),
              C_array(ccx.int_type, subcrates)]));
     }
index 67cbdaae4fa5706e2ecffac969178ec710664646..57abb7560a1344aacda6a9185e32bc1719925cea 100644 (file)
@@ -9,7 +9,8 @@
 // except according to those terms.
 
 
-use libc::{c_void, c_char};
+use libc::c_char;
+#[cfg(stage0)] use libc::c_void;
 use ptr;
 use ptr::RawPtr;
 use vec;
@@ -39,6 +40,7 @@ struct CrateMapV0 {
     children: [*CrateMap, ..1]
 }
 
+#[cfg(stage0)]
 struct CrateMap {
     version: i32,
     annihilate_fn: *c_void,
@@ -48,6 +50,15 @@ struct CrateMap {
     children: [*CrateMap, ..1]
 }
 
+#[cfg(not(stage0))]
+struct CrateMap {
+    version: i32,
+    entries: *ModEntry,
+    /// a dynamically sized struct, where all pointers to children are listed adjacent
+    /// to the struct, terminated with NULL
+    children: [*CrateMap, ..1]
+}
+
 #[cfg(not(windows))]
 pub fn get_crate_map() -> *CrateMap {
     &'static CRATE_MAP as *CrateMap
@@ -79,15 +90,6 @@ unsafe fn version(crate_map: *CrateMap) -> i32 {
     }
 }
 
-/// Returns a pointer to the annihilate function of the CrateMap
-pub unsafe fn annihilate_fn(crate_map: *CrateMap) -> *c_void {
-    match version(crate_map) {
-        0 => return ptr::null(),
-        1 => return (*crate_map).annihilate_fn,
-        _ => fail!("Unknown crate map version!")
-    }
-}
-
 unsafe fn entries(crate_map: *CrateMap) -> *ModEntry {
     match version(crate_map) {
         0 => {
@@ -145,7 +147,6 @@ fn iter_crate_map_duplicates() {
 
     struct CrateMapT3 {
         version: i32,
-        annihilate_fn: *c_void,
         entries: *ModEntry,
         children: [*CrateMap, ..3]
     }
@@ -160,13 +161,12 @@ struct CrateMapT3 {
         ];
         let child_crate = CrateMap {
             version: 1,
-            annihilate_fn: ptr::null(),
             entries: vec::raw::to_ptr(entries),
             children: [ptr::null()]
         };
 
         let root_crate = CrateMapT3 {
-            version: 1, annihilate_fn: ptr::null(),
+            version: 1,
             entries: vec::raw::to_ptr([ModEntry { name: ptr::null(), log_level: ptr::mut_null()}]),
             children: [&child_crate as *CrateMap, &child_crate as *CrateMap, ptr::null()]
         };
@@ -187,7 +187,6 @@ fn iter_crate_map_follow_children() {
 
     struct CrateMapT2 {
         version: i32,
-        annihilate_fn: *c_void,
         entries: *ModEntry,
         children: [*CrateMap, ..2]
     }
@@ -199,7 +198,6 @@ struct CrateMapT2 {
         let mut level3: u32 = 3;
         let child_crate2 = CrateMap {
             version: 1,
-            annihilate_fn: ptr::null(),
             entries: vec::raw::to_ptr([
                 ModEntry { name: mod_name1.with_ref(|buf| buf), log_level: &mut level2},
                 ModEntry { name: mod_name2.with_ref(|buf| buf), log_level: &mut level3},
@@ -210,7 +208,6 @@ struct CrateMapT2 {
 
         let child_crate1 = CrateMapT2 {
             version: 1,
-            annihilate_fn: ptr::null(),
             entries: vec::raw::to_ptr([
                 ModEntry { name: "t::f1".to_c_str().with_ref(|buf| buf), log_level: &mut 1},
                 ModEntry { name: ptr::null(), log_level: ptr::mut_null()}
@@ -220,7 +217,7 @@ struct CrateMapT2 {
 
         let child_crate1_ptr: *CrateMap = transmute(&child_crate1);
         let root_crate = CrateMapT2 {
-            version: 1, annihilate_fn: ptr::null(),
+            version: 1,
             entries: vec::raw::to_ptr([
                 ModEntry { name: "t::f1".to_c_str().with_ref(|buf| buf), log_level: &mut 0},
                 ModEntry { name: ptr::null(), log_level: ptr::mut_null()}