diff options
| author | bors <bors@rust-lang.org> | 2013-09-24 20:25:58 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-09-24 20:25:58 -0700 |
| commit | d7bb40c50c99767fc1c7eaf785242011b36d574d (patch) | |
| tree | 831cf04b6624be0bd34c45afbb3d7facfb4b5eba /src/libstd | |
| parent | 512f7781fe86cde003132969e7fed5aea649bf13 (diff) | |
| parent | 90e009f9b6aae3b3a9f500f07bca07b531e54507 (diff) | |
| download | rust-d7bb40c50c99767fc1c7eaf785242011b36d574d.tar.gz rust-d7bb40c50c99767fc1c7eaf785242011b36d574d.zip | |
auto merge of #9470 : luqmana/rust/bba, r=brson
#8431 ~~@brson: do we need to bump up the cratemap version for this change?~~ Tis a no.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/rt/crate_map.rs | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/libstd/rt/crate_map.rs b/src/libstd/rt/crate_map.rs index 67cbdaae4fa..57abb7560a1 100644 --- a/src/libstd/rt/crate_map.rs +++ b/src/libstd/rt/crate_map.rs @@ -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 @@ fn iter_crate_map_duplicates() { ]; 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 @@ fn iter_crate_map_follow_children() { 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 @@ fn iter_crate_map_follow_children() { 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 @@ fn iter_crate_map_follow_children() { 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()} |
