Skip to content

Commit 70fb7a9

Browse files
committed
---
yaml --- r: 63487 b: refs/heads/snap-stage3 c: 5086c08 h: refs/heads/master i: 63485: ffa1f50 63483: 37a5a8c 63479: d40b7a4 63471: ab7fe74 63455: 0e9d430 63423: 6d4d6a5 63359: 6183ed3 63231: ef08c0a 62975: fa69e26 62463: e2ae320 61439: 3aaf321 v: v3
1 parent 8bdf06b commit 70fb7a9

File tree

20 files changed

+747
-507
lines changed

20 files changed

+747
-507
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 083c692565340791b06ab67d66c4c95d63b222cb
4+
refs/heads/snap-stage3: 5086c0850ebdd8407901d108f312ab141e4a4a18
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libstd/macros.rs

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,16 @@
1010

1111
#[macro_escape];
1212

13+
macro_rules! rterrln (
14+
($( $arg:expr),+) => ( {
15+
::rt::util::dumb_println(fmt!( $($arg),+ ));
16+
} )
17+
)
18+
1319
// Some basic logging
1420
macro_rules! rtdebug_ (
1521
($( $arg:expr),+) => ( {
16-
dumb_println(fmt!( $($arg),+ ));
17-
18-
fn dumb_println(s: &str) {
19-
use io::WriterUtil;
20-
let dbg = ::libc::STDERR_FILENO as ::io::fd_t;
21-
dbg.write_str(s);
22-
dbg.write_str("\n");
23-
}
24-
22+
rterrln!( $($arg),+ )
2523
} )
2624
)
2725

@@ -33,24 +31,15 @@ macro_rules! rtdebug (
3331
macro_rules! rtassert (
3432
( $arg:expr ) => ( {
3533
if !$arg {
36-
abort!("assertion failed: %s", stringify!($arg));
34+
rtabort!("assertion failed: %s", stringify!($arg));
3735
}
3836
} )
3937
)
4038

4139

42-
// The do_abort function was originally inside the abort macro, but
43-
// this was ICEing the compiler so it has been moved outside. Now this
44-
// seems to work?
45-
#[allow(missing_doc)]
46-
pub fn do_abort() -> ! {
47-
unsafe { ::libc::abort(); }
48-
}
49-
50-
macro_rules! abort(
40+
macro_rules! rtabort(
5141
($( $msg:expr),+) => ( {
52-
rtdebug!($($msg),+);
53-
::macros::do_abort();
42+
::rt::util::abort(fmt!($($msg),+));
5443
} )
5544
)
5645

branches/snap-stage3/src/libstd/rt/global_heap.rs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use c_malloc = libc::malloc;
1414
use c_free = libc::free;
1515
use managed::raw::{BoxHeaderRepr, BoxRepr};
1616
use cast::transmute;
17-
use unstable::intrinsics::{atomic_xadd,atomic_xsub};
17+
use unstable::intrinsics::{atomic_xadd,atomic_xsub, atomic_load};
1818
use ptr::null;
1919
use intrinsic::TyDesc;
2020

@@ -34,8 +34,7 @@ pub unsafe fn malloc(td: *TypeDesc, size: uint) -> *c_void {
3434
box.header.prev = null();
3535
box.header.next = null();
3636

37-
let exchange_count = &mut *exchange_count_ptr();
38-
atomic_xadd(exchange_count, 1);
37+
inc_count();
3938

4039
return transmute(box);
4140
}
@@ -48,21 +47,46 @@ pub unsafe fn malloc_raw(size: uint) -> *c_void {
4847
if p.is_null() {
4948
fail!("Failure in malloc_raw: result ptr is null");
5049
}
50+
inc_count();
5151
p
5252
}
5353

5454
pub unsafe fn free(ptr: *c_void) {
55-
let exchange_count = &mut *exchange_count_ptr();
56-
atomic_xsub(exchange_count, 1);
57-
5855
assert!(ptr.is_not_null());
56+
dec_count();
5957
c_free(ptr);
6058
}
6159
///Thin wrapper around libc::free, as with exchange_alloc::malloc_raw
6260
pub unsafe fn free_raw(ptr: *c_void) {
61+
assert!(ptr.is_not_null());
62+
dec_count();
6363
c_free(ptr);
6464
}
6565

66+
fn inc_count() {
67+
unsafe {
68+
let exchange_count = &mut *exchange_count_ptr();
69+
atomic_xadd(exchange_count, 1);
70+
}
71+
}
72+
73+
fn dec_count() {
74+
unsafe {
75+
let exchange_count = &mut *exchange_count_ptr();
76+
atomic_xsub(exchange_count, 1);
77+
}
78+
}
79+
80+
pub fn cleanup() {
81+
unsafe {
82+
let count_ptr = exchange_count_ptr();
83+
let allocations = atomic_load(&*count_ptr);
84+
if allocations != 0 {
85+
rtabort!("exchange heap not empty on exit - %i dangling allocations", allocations);
86+
}
87+
}
88+
}
89+
6690
fn get_box_size(body_size: uint, body_align: uint) -> uint {
6791
let header_size = size_of::<BoxHeaderRepr>();
6892
// FIXME (#2699): This alignment calculation is suspicious. Is it right?

branches/snap-stage3/src/libstd/rt/io/net/ip.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::cmp::{Eq, TotalEq};
12-
1311
pub enum IpAddr {
1412
Ipv4(u8, u8, u8, u8, u16),
1513
Ipv6
1614
}
17-
18-
impl Eq for IpAddr {
19-
fn eq(&self, other: &IpAddr) -> bool {
20-
match (*self, *other) {
21-
(Ipv4(a,b,c,d,e), Ipv4(f,g,h,i,j)) => (a,b,c,d,e) == (f,g,h,i,j),
22-
(Ipv6, Ipv6) => fail!(),
23-
_ => false
24-
}
25-
}
26-
fn ne(&self, other: &IpAddr) -> bool {
27-
!(self == other)
28-
}
29-
}
30-
31-
impl TotalEq for IpAddr {
32-
fn equals(&self, other: &IpAddr) -> bool {
33-
*self == *other
34-
}
35-
}

branches/snap-stage3/src/libstd/rt/io/net/udp.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use option::{Option};
12-
use rt::io::net::ip::IpAddr;
13-
use rt::io::{Reader, Writer, Listener};
14-
use rt::rtio::{RtioUdpStreamObject};
11+
use prelude::*;
12+
use super::super::*;
13+
use super::ip::IpAddr;
1514

16-
pub struct UdpStream {
17-
rtstream: ~RtioUdpStreamObject
18-
}
15+
pub struct UdpStream;
1916

2017
impl UdpStream {
21-
fn new(s: ~RtioUdpStreamObject) -> UdpStream {
22-
UdpStream {
23-
rtstream: s
24-
}
25-
}
26-
2718
pub fn connect(_addr: IpAddr) -> Option<UdpStream> {
2819
fail!()
2920
}

branches/snap-stage3/src/libstd/rt/local.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,25 @@ impl Local for Scheduler {
3838
}
3939
match res {
4040
Some(r) => { r }
41-
None => abort!("function failed!")
41+
None => rtabort!("function failed!")
4242
}
4343
}
4444
unsafe fn unsafe_borrow() -> *mut Scheduler { local_ptr::unsafe_borrow() }
45-
unsafe fn try_unsafe_borrow() -> Option<*mut Scheduler> { abort!("unimpl") }
45+
unsafe fn try_unsafe_borrow() -> Option<*mut Scheduler> { rtabort!("unimpl") }
4646
}
4747

4848
impl Local for Task {
49-
fn put(_value: ~Task) { abort!("unimpl") }
50-
fn take() -> ~Task { abort!("unimpl") }
51-
fn exists() -> bool { abort!("unimpl") }
49+
fn put(_value: ~Task) { rtabort!("unimpl") }
50+
fn take() -> ~Task { rtabort!("unimpl") }
51+
fn exists() -> bool { rtabort!("unimpl") }
5252
fn borrow<T>(f: &fn(&mut Task) -> T) -> T {
5353
do Local::borrow::<Scheduler, T> |sched| {
5454
match sched.current_task {
5555
Some(~ref mut task) => {
5656
f(&mut *task.task)
5757
}
5858
None => {
59-
abort!("no scheduler")
59+
rtabort!("no scheduler")
6060
}
6161
}
6262
}
@@ -69,7 +69,7 @@ impl Local for Task {
6969
}
7070
None => {
7171
// Don't fail. Infinite recursion
72-
abort!("no scheduler")
72+
rtabort!("no scheduler")
7373
}
7474
}
7575
}
@@ -84,16 +84,16 @@ impl Local for Task {
8484

8585
// XXX: This formulation won't work once ~IoFactoryObject is a real trait pointer
8686
impl Local for IoFactoryObject {
87-
fn put(_value: ~IoFactoryObject) { abort!("unimpl") }
88-
fn take() -> ~IoFactoryObject { abort!("unimpl") }
89-
fn exists() -> bool { abort!("unimpl") }
90-
fn borrow<T>(_f: &fn(&mut IoFactoryObject) -> T) -> T { abort!("unimpl") }
87+
fn put(_value: ~IoFactoryObject) { rtabort!("unimpl") }
88+
fn take() -> ~IoFactoryObject { rtabort!("unimpl") }
89+
fn exists() -> bool { rtabort!("unimpl") }
90+
fn borrow<T>(_f: &fn(&mut IoFactoryObject) -> T) -> T { rtabort!("unimpl") }
9191
unsafe fn unsafe_borrow() -> *mut IoFactoryObject {
9292
let sched = Local::unsafe_borrow::<Scheduler>();
9393
let io: *mut IoFactoryObject = (*sched).event_loop.io().unwrap();
9494
return io;
9595
}
96-
unsafe fn try_unsafe_borrow() -> Option<*mut IoFactoryObject> { abort!("unimpl") }
96+
unsafe fn try_unsafe_borrow() -> Option<*mut IoFactoryObject> { rtabort!("unimpl") }
9797
}
9898

9999
#[cfg(test)]

branches/snap-stage3/src/libstd/rt/local_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub unsafe fn unsafe_borrow<T>() -> *mut T {
109109
fn tls_key() -> tls::Key {
110110
match maybe_tls_key() {
111111
Some(key) => key,
112-
None => abort!("runtime tls key not initialized")
112+
None => rtabort!("runtime tls key not initialized")
113113
}
114114
}
115115

0 commit comments

Comments
 (0)