Skip to content

Commit ed6c0ca

Browse files
committed
---
yaml --- r: 60641 b: refs/heads/auto c: 18df18c h: refs/heads/master i: 60639: 7fcc9a4 v: v3
1 parent 81ce7bf commit ed6c0ca

File tree

23 files changed

+1043
-21
lines changed

23 files changed

+1043
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: ee52865c8848657e737e3c2071728b062ec9c8de
17+
refs/heads/auto: 18df18c817b5e109710c58f512a2cc5ad14fa8b2
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/librustc/metadata/csearch.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,6 @@ pub fn each_lang_item(cstore: @mut cstore::CStore,
5454
}
5555

5656
/// Iterates over all the paths in the given crate.
57-
#[cfg(stage0)]
58-
pub fn each_path(cstore: @mut cstore::CStore,
59-
cnum: ast::crate_num,
60-
f: &fn(&str, decoder::def_like, ast::visibility) -> bool) {
61-
let crate_data = cstore::get_crate_data(cstore, cnum);
62-
let get_crate_data: decoder::GetCrateDataCb = |cnum| {
63-
cstore::get_crate_data(cstore, cnum)
64-
};
65-
decoder::each_path(cstore.intr, crate_data, get_crate_data, f)
66-
}
67-
/// Iterates over all the paths in the given crate.
68-
#[cfg(not(stage0))]
6957
pub fn each_path(cstore: @mut cstore::CStore,
7058
cnum: ast::crate_num,
7159
f: &fn(&str, decoder::def_like, ast::visibility) -> bool)

branches/auto/src/librustc/metadata/decoder.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -566,14 +566,6 @@ pub fn _each_path(intr: @ident_interner,
566566
return broken;
567567
}
568568

569-
#[cfg(stage0)]
570-
pub fn each_path(intr: @ident_interner,
571-
cdata: cmd,
572-
get_crate_data: GetCrateDataCb,
573-
f: &fn(&str, def_like, ast::visibility) -> bool) {
574-
_each_path(intr, cdata, get_crate_data, f);
575-
}
576-
#[cfg(not(stage0))]
577569
pub fn each_path(intr: @ident_interner,
578570
cdata: cmd,
579571
get_crate_data: GetCrateDataCb,

branches/auto/src/librustc/middle/borrowck/gather_loans/lifetime.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
//! This module implements the check that the lifetime of a borrow
1212
//! does not exceed the lifetime of the value being borrowed.
1313
14+
use core::prelude::*;
15+
1416
use middle::borrowck::*;
1517
use mc = middle::mem_categorization;
1618
use middle::ty;

branches/auto/src/librustc/middle/borrowck/gather_loans/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// their associated scopes. In phase two, checking loans, we will then make
1717
// sure that all of these loans are honored.
1818

19+
use core::prelude::*;
20+
1921
use middle::borrowck::*;
2022
use mc = middle::mem_categorization;
2123
use middle::pat_util;

branches/auto/src/librustc/middle/borrowck/gather_loans/restrictions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
//! Computes the restrictions that result from a borrow.
1212
13+
use core::prelude::*;
14+
1315
use middle::borrowck::*;
1416
use mc = middle::mem_categorization;
1517
use middle::ty;

branches/auto/src/librustc/middle/borrowck/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
/*! See doc.rs for a thorough explanation of the borrow checker */
1212

13+
use core::prelude::*;
14+
1315
use mc = middle::mem_categorization;
1416
use middle::ty;
1517
use middle::typeck;

branches/auto/src/librustc/middle/resolve.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use middle::lint::unused_imports;
2222
use middle::pat_util::pat_bindings;
2323

2424
use syntax::ast::*;
25+
use syntax::ast;
2526
use syntax::ast_util::{def_id_of_def, local_def};
2627
use syntax::ast_util::{path_to_ident, walk_pat, trait_method_to_ty_method};
2728
use syntax::ast_util::{Privacy, Public, Private};
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use sys::{TypeDesc, size_of};
12+
use libc::{c_void, size_t, uintptr_t};
13+
use c_malloc = libc::malloc;
14+
use c_free = libc::free;
15+
use managed::raw::{BoxHeaderRepr, BoxRepr};
16+
use cast::transmute;
17+
use unstable::intrinsics::{atomic_xadd,atomic_xsub};
18+
use ptr::null;
19+
use intrinsic::TyDesc;
20+
21+
pub unsafe fn malloc(td: *TypeDesc, size: uint) -> *c_void {
22+
assert!(td.is_not_null());
23+
24+
let total_size = get_box_size(size, (*td).align);
25+
let p = c_malloc(total_size as size_t);
26+
assert!(p.is_not_null());
27+
28+
// FIXME #3475: Converting between our two different tydesc types
29+
let td: *TyDesc = transmute(td);
30+
31+
let box: &mut BoxRepr = transmute(p);
32+
box.header.ref_count = -1; // Exchange values not ref counted
33+
box.header.type_desc = td;
34+
box.header.prev = null();
35+
box.header.next = null();
36+
37+
let exchange_count = &mut *exchange_count_ptr();
38+
atomic_xadd(exchange_count, 1);
39+
40+
return transmute(box);
41+
}
42+
/**
43+
Thin wrapper around libc::malloc, none of the box header
44+
stuff in exchange_alloc::malloc
45+
*/
46+
pub unsafe fn malloc_raw(size: uint) -> *c_void {
47+
let p = c_malloc(size as size_t);
48+
if p.is_null() {
49+
fail!("Failure in malloc_raw: result ptr is null");
50+
}
51+
p
52+
}
53+
54+
pub unsafe fn free(ptr: *c_void) {
55+
let exchange_count = &mut *exchange_count_ptr();
56+
atomic_xsub(exchange_count, 1);
57+
58+
assert!(ptr.is_not_null());
59+
c_free(ptr);
60+
}
61+
///Thin wrapper around libc::free, as with exchange_alloc::malloc_raw
62+
pub unsafe fn free_raw(ptr: *c_void) {
63+
c_free(ptr);
64+
}
65+
66+
fn get_box_size(body_size: uint, body_align: uint) -> uint {
67+
let header_size = size_of::<BoxHeaderRepr>();
68+
// FIXME (#2699): This alignment calculation is suspicious. Is it right?
69+
let total_size = align_to(header_size, body_align) + body_size;
70+
return total_size;
71+
}
72+
73+
// Rounds |size| to the nearest |alignment|. Invariant: |alignment| is a power
74+
// of two.
75+
fn align_to(size: uint, align: uint) -> uint {
76+
assert!(align != 0);
77+
(size + align - 1) & !(align - 1)
78+
}
79+
80+
fn exchange_count_ptr() -> *mut int {
81+
// XXX: Need mutable globals
82+
unsafe { transmute(&rust_exchange_count) }
83+
}
84+
85+
extern {
86+
static rust_exchange_count: uintptr_t;
87+
}

0 commit comments

Comments
 (0)