Skip to content

Commit 6cb69a9

Browse files
committed
---
yaml --- r: 61309 b: refs/heads/try c: 03f75b6 h: refs/heads/master i: 61307: c0652bd v: v3
1 parent 86a536b commit 6cb69a9

38 files changed

+667
-1554
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
5-
refs/heads/try: b04fce6a901f490a9df378c64166dda26e0297a3
5+
refs/heads/try: 03f75b629a5d1d8e0a5916abdef4499f0c7c61d6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/core.rc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,8 @@ mod unicode;
205205
#[path = "num/cmath.rs"]
206206
mod cmath;
207207
mod stackwalk;
208-
209-
// XXX: This shouldn't be pub, and it should be reexported under 'unstable'
210-
// but name resolution doesn't work without it being pub.
211208
#[path = "rt/mod.rs"]
212-
pub mod rt;
209+
mod rt;
213210

214211
// A curious inner-module that's not exported that contains the binding
215212
// 'core' so that macro-expanded references to core::error and such

branches/try/src/libcore/logging.rs

Lines changed: 13 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010

1111
//! Logging
1212
13-
use option::*;
14-
use either::*;
15-
use rt;
16-
use rt::logging::{Logger, StdErrLogger};
17-
use io;
18-
use libc;
19-
use repr;
20-
use vec;
21-
use cast;
22-
use str;
13+
pub mod rustrt {
14+
use libc;
15+
16+
pub extern {
17+
unsafe fn rust_log_console_on();
18+
unsafe fn rust_log_console_off();
19+
unsafe fn rust_log_str(level: u32,
20+
string: *libc::c_char,
21+
size: libc::size_t);
22+
}
23+
}
2324

2425
/// Turns on logging to stdout globally
2526
pub fn console_on() {
@@ -54,46 +55,8 @@ pub fn log_type<T>(level: u32, object: &T) {
5455
let bytes = do io::with_bytes_writer |writer| {
5556
repr::write_repr(writer, object);
5657
};
57-
58-
match rt::context() {
59-
rt::OldTaskContext => {
60-
unsafe {
61-
let len = bytes.len() as libc::size_t;
62-
rustrt::rust_log_str(level, cast::transmute(vec::raw::to_ptr(bytes)), len);
63-
}
64-
}
65-
_ => {
66-
// XXX: Bad allocation
67-
let msg = str::from_bytes(bytes);
68-
newsched_log_str(msg);
69-
}
70-
}
71-
}
72-
73-
fn newsched_log_str(msg: ~str) {
7458
unsafe {
75-
match rt::local_services::unsafe_try_borrow_local_services() {
76-
Some(local) => {
77-
// Use the available logger
78-
(*local).logger.log(Left(msg));
79-
}
80-
None => {
81-
// There is no logger anywhere, just write to stderr
82-
let mut logger = StdErrLogger;
83-
logger.log(Left(msg));
84-
}
85-
}
86-
}
87-
}
88-
89-
pub mod rustrt {
90-
use libc;
91-
92-
pub extern {
93-
unsafe fn rust_log_console_on();
94-
unsafe fn rust_log_console_off();
95-
unsafe fn rust_log_str(level: u32,
96-
string: *libc::c_char,
97-
size: libc::size_t);
59+
let len = bytes.len() as libc::size_t;
60+
rustrt::rust_log_str(level, transmute(vec::raw::to_ptr(bytes)), len);
9861
}
9962
}

branches/try/src/libcore/macros.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,10 @@ macro_rules! rtdebug (
3030
($( $arg:expr),+) => ( $(let _ = $arg)*; )
3131
)
3232

33-
macro_rules! rtassert (
34-
( $arg:expr ) => ( {
35-
if !$arg {
36-
abort!("assertion failed: %s", stringify!($arg));
37-
}
38-
} )
39-
)
40-
4133
macro_rules! abort(
4234
($( $msg:expr),+) => ( {
4335
rtdebug!($($msg),+);
4436

45-
do_abort();
46-
47-
// NB: This is in a fn to avoid putting the `unsafe` block in a macro,
48-
// which causes spurious 'unnecessary unsafe block' warnings.
49-
fn do_abort() -> ! {
50-
unsafe { ::libc::abort(); }
51-
}
37+
unsafe { ::libc::abort(); }
5238
} )
5339
)

branches/try/src/libcore/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ pub fn list_dir(p: &Path) -> ~[~str] {
722722
use os::win32::{
723723
as_utf16_p
724724
};
725-
use rt::global_heap::{malloc_raw, free_raw};
725+
use unstable::exchange_alloc::{malloc_raw, free_raw};
726726
#[nolink]
727727
extern {
728728
unsafe fn rust_list_dir_wfd_size() -> libc::size_t;

branches/try/src/libcore/rt/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
111111
let sp = align_down(sp);
112112
let sp = mut_offset(sp, -4);
113113

114-
unsafe { *sp = arg as uint };
114+
unsafe { *sp = arg as uint; }
115115
let sp = mut_offset(sp, -1);
116-
unsafe { *sp = 0 }; // The final return address
116+
unsafe { *sp = 0; } // The final return address
117117

118118
regs.esp = sp as u32;
119119
regs.eip = fptr as u32;
@@ -195,7 +195,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
195195

196196
fn align_down(sp: *mut uint) -> *mut uint {
197197
unsafe {
198-
let sp: uint = transmute(sp);
198+
let sp = transmute::<*mut uint, uint>(sp);
199199
let sp = sp & !(16 - 1);
200200
transmute::<uint, *mut uint>(sp)
201201
}

branches/try/src/libcore/rt/io/file.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use prelude::*;
1212
use super::support::PathLike;
13-
use super::{Reader, Writer, Seek};
13+
use super::{Reader, Writer, Seek, Close};
1414
use super::SeekStyle;
1515

1616
/// # XXX
@@ -69,6 +69,10 @@ impl Seek for FileStream {
6969
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }
7070
}
7171

72+
impl Close for FileStream {
73+
fn close(&mut self) { fail!() }
74+
}
75+
7276
#[test]
7377
#[ignore]
7478
fn super_simple_smoke_test_lets_go_read_some_files_and_have_a_good_time() {

branches/try/src/libcore/rt/io/mod.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ Out of scope
238238
* How does I/O relate to the Iterator trait?
239239
* std::base64 filters
240240
* Using conditions is a big unknown since we don't have much experience with them
241-
* Too many uses of OtherIoError
242241
243242
*/
244243

@@ -253,9 +252,7 @@ pub use self::stdio::println;
253252

254253
pub use self::file::FileStream;
255254
pub use self::net::ip::IpAddr;
256-
#[cfg(not(stage0))]
257255
pub use self::net::tcp::TcpListener;
258-
#[cfg(not(stage0))]
259256
pub use self::net::tcp::TcpStream;
260257
pub use self::net::udp::UdpStream;
261258

@@ -269,7 +266,6 @@ pub mod file;
269266

270267
/// Synchronous, non-blocking network I/O.
271268
pub mod net {
272-
#[cfg(not(stage0))]
273269
pub mod tcp;
274270
pub mod udp;
275271
pub mod ip;
@@ -330,14 +326,12 @@ pub struct IoError {
330326

331327
#[deriving(Eq)]
332328
pub enum IoErrorKind {
333-
PreviousIoError,
334-
OtherIoError,
335-
EndOfFile,
336329
FileNotFound,
337-
PermissionDenied,
330+
FilePermission,
338331
ConnectionFailed,
339332
Closed,
340-
ConnectionRefused,
333+
OtherIoError,
334+
PreviousIoError
341335
}
342336

343337
// XXX: Can't put doc comments on macros
@@ -389,7 +383,16 @@ pub trait Writer {
389383
fn flush(&mut self);
390384
}
391385

392-
pub trait Stream: Reader + Writer { }
386+
/// I/O types that may be closed
387+
///
388+
/// Any further operations performed on a closed resource will raise
389+
/// on `io_error`
390+
pub trait Close {
391+
/// Close the I/O resource
392+
fn close(&mut self);
393+
}
394+
395+
pub trait Stream: Reader + Writer + Close { }
393396

394397
pub enum SeekStyle {
395398
/// Seek from the beginning of the stream

branches/try/src/libcore/rt/io/native/file.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ impl Writer for FileDesc {
4040
fn flush(&mut self) { fail!() }
4141
}
4242

43+
impl Close for FileDesc {
44+
fn close(&mut self) { fail!() }
45+
}
46+
4347
impl Seek for FileDesc {
4448
fn tell(&self) -> u64 { fail!() }
4549

@@ -68,6 +72,10 @@ impl Writer for CFile {
6872
fn flush(&mut self) { fail!() }
6973
}
7074

75+
impl Close for CFile {
76+
fn close(&mut self) { fail!() }
77+
}
78+
7179
impl Seek for CFile {
7280
fn tell(&self) -> u64 { fail!() }
7381
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }

0 commit comments

Comments
 (0)