};
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)
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)]));
}
// 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;
children: [*CrateMap, ..1]
}
+#[cfg(stage0)]
struct CrateMap {
version: i32,
annihilate_fn: *c_void,
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
}
}
-/// 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 => {
struct CrateMapT3 {
version: i32,
- annihilate_fn: *c_void,
entries: *ModEntry,
children: [*CrateMap, ..3]
}
];
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()]
};
struct CrateMapT2 {
version: i32,
- annihilate_fn: *c_void,
entries: *ModEntry,
children: [*CrateMap, ..2]
}
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},
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()}
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()}