Skip to content

Commit d2c4b64

Browse files
committed
Merge remote-tracking branch 'remotes/origin/incoming' into incoming
2 parents 3953bdd + b171d0e commit d2c4b64

34 files changed

+168
-102
lines changed

doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ the following forms:
297297
num_lit : nonzero_dec [ dec_digit | '_' ] * num_suffix ?
298298
| '0' [ [ dec_digit | '_' ] + num_suffix ?
299299
| 'b' [ '1' | '0' | '_' ] + int_suffix ?
300-
| 'x' [ hex_digit | '-' ] + int_suffix ? ] ;
300+
| 'x' [ hex_digit | '_' ] + int_suffix ? ] ;
301301
302302
num_suffix : int_suffix | float_suffix ;
303303

src/libcore/cleanup.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn debug_mem() -> bool {
154154
#[cfg(notest)]
155155
#[lang="annihilate"]
156156
pub unsafe fn annihilate() {
157-
use rt::rt_free;
157+
use rt::local_free;
158158
use io::WriterUtil;
159159
use io;
160160
use libc;
@@ -192,7 +192,7 @@ pub unsafe fn annihilate() {
192192
stats.n_bytes_freed +=
193193
(*((*box).header.type_desc)).size
194194
+ sys::size_of::<BoxRepr>();
195-
rt_free(transmute(box));
195+
local_free(transmute(box));
196196
}
197197
}
198198

src/libcore/io.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,10 @@ impl<R:Reader,C> Reader for Wrapper<R, C> {
474474

475475
pub struct FILERes {
476476
f: *libc::FILE,
477-
drop {
477+
}
478+
479+
impl Drop for FILERes {
480+
fn finalize(&self) {
478481
unsafe {
479482
libc::fclose(self.f);
480483
}
@@ -683,7 +686,10 @@ impl Writer for fd_t {
683686

684687
pub struct FdRes {
685688
fd: fd_t,
686-
drop {
689+
}
690+
691+
impl Drop for FdRes {
692+
fn finalize(&self) {
687693
unsafe {
688694
libc::close(self.fd);
689695
}

src/libcore/option.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,10 @@ fn test_unwrap_str() {
450450
fn test_unwrap_resource() {
451451
struct R {
452452
i: @mut int,
453-
drop { *(self.i) += 1; }
453+
}
454+
455+
impl ::ops::Drop for R {
456+
fn finalize(&self) { *(self.i) += 1; }
454457
}
455458

456459
fn R(i: @mut int) -> R {

src/libcore/pipes.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,10 @@ pub unsafe fn get_buffer<T>(p: *PacketHeader) -> ~Buffer<T> {
346346
struct BufferResource<T> {
347347
buffer: ~Buffer<T>,
348348
349-
drop {
349+
}
350+
351+
impl<T> ::ops::Drop for BufferResource<T> {
352+
fn finalize(&self) {
350353
unsafe {
351354
let b = move_it!(self.buffer);
352355
//let p = ptr::addr_of(*b);

src/libcore/private.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ struct ArcData<T> {
126126

127127
struct ArcDestruct<T> {
128128
mut data: *libc::c_void,
129-
drop {
129+
}
130+
131+
impl<T> Drop for ArcDestruct<T>{
132+
fn finalize(&self) {
130133
unsafe {
131134
if self.data.is_null() {
132135
return; // Happens when destructing an unwrapper's handle.
@@ -178,7 +181,10 @@ pub unsafe fn unwrap_shared_mutable_state<T:Owned>(rc: SharedMutableState<T>)
178181
struct DeathThroes<T> {
179182
mut ptr: Option<~ArcData<T>>,
180183
mut response: Option<comm::ChanOne<bool>>,
181-
drop {
184+
}
185+
186+
impl<T> Drop for DeathThroes<T>{
187+
fn finalize(&self) {
182188
unsafe {
183189
let response = option::swap_unwrap(&mut self.response);
184190
// In case we get killed early, we need to tell the person who
@@ -311,7 +317,10 @@ type rust_little_lock = *libc::c_void;
311317
312318
struct LittleLock {
313319
l: rust_little_lock,
314-
drop {
320+
}
321+
322+
impl Drop for LittleLock {
323+
fn finalize(&self) {
315324
unsafe {
316325
rustrt::rust_destroy_little_lock(self.l);
317326
}

src/libcore/rand.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,10 @@ impl Rng {
365365

366366
struct RandRes {
367367
rng: *rust_rng,
368-
drop {
368+
}
369+
370+
impl Drop for RandRes {
371+
fn finalize(&self) {
369372
unsafe {
370373
rustrt::rand_free(self.rng);
371374
}

src/libcore/rt.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,60 +36,54 @@ pub extern mod rustrt {
3636
unsafe fn rust_upcall_free(ptr: *c_char);
3737
}
3838

39-
#[rt(fail_)]
4039
#[lang="fail_"]
41-
pub fn rt_fail_(expr: *c_char, file: *c_char, line: size_t) -> ! {
40+
pub fn fail_(expr: *c_char, file: *c_char, line: size_t) -> ! {
4241
sys::begin_unwind_(expr, file, line);
4342
}
4443

45-
#[rt(fail_bounds_check)]
4644
#[lang="fail_bounds_check"]
47-
pub unsafe fn rt_fail_bounds_check(file: *c_char, line: size_t,
48-
index: size_t, len: size_t) {
45+
pub unsafe fn fail_bounds_check(file: *c_char, line: size_t,
46+
index: size_t, len: size_t) {
4947
let msg = fmt!("index out of bounds: the len is %d but the index is %d",
5048
len as int, index as int);
5149
do str::as_buf(msg) |p, _len| {
52-
rt_fail_(p as *c_char, file, line);
50+
fail_(p as *c_char, file, line);
5351
}
5452
}
5553

56-
pub unsafe fn rt_fail_borrowed() {
54+
pub unsafe fn fail_borrowed() {
5755
let msg = "borrowed";
5856
do str::as_buf(msg) |msg_p, _| {
5957
do str::as_buf("???") |file_p, _| {
60-
rt_fail_(msg_p as *c_char, file_p as *c_char, 0);
58+
fail_(msg_p as *c_char, file_p as *c_char, 0);
6159
}
6260
}
6361
}
6462

6563
// FIXME #4942: Make these signatures agree with exchange_alloc's signatures
66-
#[rt(exchange_malloc)]
6764
#[lang="exchange_malloc"]
68-
pub unsafe fn rt_exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
65+
pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
6966
transmute(exchange_alloc::malloc(transmute(td), transmute(size)))
7067
}
7168

7269
// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
7370
// inside a landing pad may corrupt the state of the exception handler. If a
7471
// problem occurs, call exit instead.
75-
#[rt(exchange_free)]
7672
#[lang="exchange_free"]
77-
pub unsafe fn rt_exchange_free(ptr: *c_char) {
73+
pub unsafe fn exchange_free(ptr: *c_char) {
7874
exchange_alloc::free(transmute(ptr))
7975
}
8076

81-
#[rt(malloc)]
8277
#[lang="malloc"]
83-
pub unsafe fn rt_malloc(td: *c_char, size: uintptr_t) -> *c_char {
78+
pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char {
8479
return rustrt::rust_upcall_malloc(td, size);
8580
}
8681

8782
// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
8883
// inside a landing pad may corrupt the state of the exception handler. If a
8984
// problem occurs, call exit instead.
90-
#[rt(free)]
9185
#[lang="free"]
92-
pub unsafe fn rt_free(ptr: *c_char) {
86+
pub unsafe fn local_free(ptr: *c_char) {
9387
rustrt::rust_upcall_free(ptr);
9488
}
9589

@@ -112,7 +106,7 @@ pub unsafe fn return_to_mut(a: *u8) {
112106
pub unsafe fn check_not_borrowed(a: *u8) {
113107
let a: *mut BoxRepr = transmute(a);
114108
if ((*a).header.ref_count & FROZEN_BIT) != 0 {
115-
rt_fail_borrowed();
109+
fail_borrowed();
116110
}
117111
}
118112

src/libcore/run.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,10 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
248248
}
249249
struct ProgRes {
250250
r: ProgRepr,
251-
drop {
251+
}
252+
253+
impl Drop for ProgRes {
254+
fn finalize(&self) {
252255
unsafe {
253256
// FIXME #4943: This is bad.
254257
destroy_repr(cast::transmute(&self.r));

src/libcore/task/spawn.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,11 @@ struct TCB {
308308
mut ancestors: AncestorList,
309309
is_main: bool,
310310
notifier: Option<AutoNotify>,
311+
}
312+
313+
impl Drop for TCB {
311314
// Runs on task exit.
312-
drop {
315+
fn finalize(&self) {
313316
unsafe {
314317
// If we are failing, the whole taskgroup needs to die.
315318
if rt::rust_task_is_unwinding(self.me) {
@@ -353,7 +356,10 @@ fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList,
353356
struct AutoNotify {
354357
notify_chan: Chan<TaskResult>,
355358
mut failed: bool,
356-
drop {
359+
}
360+
361+
impl Drop for AutoNotify {
362+
fn finalize(&self) {
357363
let result = if self.failed { Failure } else { Success };
358364
self.notify_chan.send(result);
359365
}

0 commit comments

Comments
 (0)