Skip to content

Commit 17ef1d6

Browse files
committed
---
yaml --- r: 112433 b: refs/heads/try c: 3157c3e h: refs/heads/master i: 112431: d168fa4 v: v3
1 parent d886a07 commit 17ef1d6

File tree

89 files changed

+811
-622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+811
-622
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: a72a6ec897e1b8d7e125be9bb4b60d89c79aa4c0
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b5dd3f05fe95168b5569d0f519636149479eb6ac
5-
refs/heads/try: a08198ba6f58e33cd8dda6fec74f3ca2d28bbaf9
5+
refs/heads/try: 3157c3e95b3f8d217e4a1e1e7f93939866e74472
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libfourcc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) ->
9191

9292
let s = match expr.node {
9393
// expression is a literal
94-
ast::ExprLit(lit) => match lit.node {
94+
ast::ExprLit(ref lit) => match lit.node {
9595
// string literal
9696
ast::LitStr(ref s, _) => {
9797
if s.get().char_len() != 4 {

branches/try/src/libnative/io/c_win32.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ extern "system" {
5050
pub fn ioctlsocket(s: libc::SOCKET, cmd: libc::c_long,
5151
argp: *mut libc::c_ulong) -> libc::c_int;
5252
pub fn select(nfds: libc::c_int,
53-
readfds: *mut fd_set,
54-
writefds: *mut fd_set,
55-
exceptfds: *mut fd_set,
53+
readfds: *fd_set,
54+
writefds: *fd_set,
55+
exceptfds: *fd_set,
5656
timeout: *libc::timeval) -> libc::c_int;
5757
pub fn getsockopt(sockfd: libc::SOCKET,
5858
level: libc::c_int,

branches/try/src/libnative/io/net.rs

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use std::cast;
1313
use std::io::net::ip;
1414
use std::io;
1515
use std::mem;
16+
use std::os;
1617
use std::ptr;
1718
use std::rt::rtio;
1819
use std::sync::arc::UnsafeArc;
@@ -144,6 +145,21 @@ fn last_error() -> io::IoError {
144145
super::last_error()
145146
}
146147

148+
fn ms_to_timeval(ms: u64) -> libc::timeval {
149+
libc::timeval {
150+
tv_sec: (ms / 1000) as libc::time_t,
151+
tv_usec: ((ms % 1000) * 1000) as libc::suseconds_t,
152+
}
153+
}
154+
155+
fn timeout(desc: &'static str) -> io::IoError {
156+
io::IoError {
157+
kind: io::TimedOut,
158+
desc: desc,
159+
detail: None,
160+
}
161+
}
162+
147163
#[cfg(windows)] unsafe fn close(sock: sock_t) { let _ = libc::closesocket(sock); }
148164
#[cfg(unix)] unsafe fn close(sock: sock_t) { let _ = libc::close(sock); }
149165

@@ -271,8 +287,7 @@ impl TcpStream {
271287
fn connect_timeout(fd: sock_t,
272288
addrp: *libc::sockaddr,
273289
len: libc::socklen_t,
274-
timeout: u64) -> IoResult<()> {
275-
use std::os;
290+
timeout_ms: u64) -> IoResult<()> {
276291
#[cfg(unix)] use INPROGRESS = libc::EINPROGRESS;
277292
#[cfg(windows)] use INPROGRESS = libc::WSAEINPROGRESS;
278293
#[cfg(unix)] use WOULDBLOCK = libc::EWOULDBLOCK;
@@ -289,12 +304,8 @@ impl TcpStream {
289304
os::errno() as int == WOULDBLOCK as int => {
290305
let mut set: c::fd_set = unsafe { mem::init() };
291306
c::fd_set(&mut set, fd);
292-
match await(fd, &mut set, timeout) {
293-
0 => Err(io::IoError {
294-
kind: io::TimedOut,
295-
desc: "connection timed out",
296-
detail: None,
297-
}),
307+
match await(fd, &mut set, timeout_ms) {
308+
0 => Err(timeout("connection timed out")),
298309
-1 => Err(last_error()),
299310
_ => {
300311
let err: libc::c_int = try!(
@@ -338,22 +349,14 @@ impl TcpStream {
338349
// Recalculate the timeout each iteration (it is generally
339350
// undefined what the value of the 'tv' is after select
340351
// returns EINTR).
341-
let timeout = timeout - (::io::timer::now() - start);
342-
let tv = libc::timeval {
343-
tv_sec: (timeout / 1000) as libc::time_t,
344-
tv_usec: ((timeout % 1000) * 1000) as libc::suseconds_t,
345-
};
346-
c::select(fd + 1, ptr::null(), set as *mut _ as *_,
347-
ptr::null(), &tv)
352+
let tv = ms_to_timeval(timeout - (::io::timer::now() - start));
353+
c::select(fd + 1, ptr::null(), &*set, ptr::null(), &tv)
348354
})
349355
}
350356
#[cfg(windows)]
351357
fn await(_fd: sock_t, set: &mut c::fd_set, timeout: u64) -> libc::c_int {
352-
let tv = libc::timeval {
353-
tv_sec: (timeout / 1000) as libc::time_t,
354-
tv_usec: ((timeout % 1000) * 1000) as libc::suseconds_t,
355-
};
356-
unsafe { c::select(1, ptr::mut_null(), set, ptr::mut_null(), &tv) }
358+
let tv = ms_to_timeval(timeout);
359+
unsafe { c::select(1, ptr::null(), &*set, ptr::null(), &tv) }
357360
}
358361
}
359362

@@ -467,7 +470,7 @@ impl Drop for Inner {
467470
////////////////////////////////////////////////////////////////////////////////
468471

469472
pub struct TcpListener {
470-
inner: UnsafeArc<Inner>,
473+
inner: Inner,
471474
}
472475

473476
impl TcpListener {
@@ -477,7 +480,7 @@ impl TcpListener {
477480
let (addr, len) = addr_to_sockaddr(addr);
478481
let addrp = &addr as *libc::sockaddr_storage;
479482
let inner = Inner { fd: fd };
480-
let ret = TcpListener { inner: UnsafeArc::new(inner) };
483+
let ret = TcpListener { inner: inner };
481484
// On platforms with Berkeley-derived sockets, this allows
482485
// to quickly rebind a socket, without needing to wait for
483486
// the OS to clean up the previous one.
@@ -498,15 +501,12 @@ impl TcpListener {
498501
}
499502
}
500503

501-
pub fn fd(&self) -> sock_t {
502-
// This is just a read-only arc so the unsafety is fine
503-
unsafe { (*self.inner.get()).fd }
504-
}
504+
pub fn fd(&self) -> sock_t { self.inner.fd }
505505

506506
pub fn native_listen(self, backlog: int) -> IoResult<TcpAcceptor> {
507507
match unsafe { libc::listen(self.fd(), backlog as libc::c_int) } {
508508
-1 => Err(last_error()),
509-
_ => Ok(TcpAcceptor { listener: self })
509+
_ => Ok(TcpAcceptor { listener: self, deadline: 0 })
510510
}
511511
}
512512
}
@@ -525,12 +525,16 @@ impl rtio::RtioSocket for TcpListener {
525525

526526
pub struct TcpAcceptor {
527527
listener: TcpListener,
528+
deadline: u64,
528529
}
529530

530531
impl TcpAcceptor {
531532
pub fn fd(&self) -> sock_t { self.listener.fd() }
532533

533534
pub fn native_accept(&mut self) -> IoResult<TcpStream> {
535+
if self.deadline != 0 {
536+
try!(self.accept_deadline());
537+
}
534538
unsafe {
535539
let mut storage: libc::sockaddr_storage = mem::init();
536540
let storagep = &mut storage as *mut libc::sockaddr_storage;
@@ -546,6 +550,25 @@ impl TcpAcceptor {
546550
}
547551
}
548552
}
553+
554+
fn accept_deadline(&mut self) -> IoResult<()> {
555+
let mut set: c::fd_set = unsafe { mem::init() };
556+
c::fd_set(&mut set, self.fd());
557+
558+
match retry(|| {
559+
// If we're past the deadline, then pass a 0 timeout to select() so
560+
// we can poll the status of the socket.
561+
let now = ::io::timer::now();
562+
let ms = if self.deadline > now {0} else {self.deadline - now};
563+
let tv = ms_to_timeval(ms);
564+
let n = if cfg!(windows) {1} else {self.fd() as libc::c_int + 1};
565+
unsafe { c::select(n, &set, ptr::null(), ptr::null(), &tv) }
566+
}) {
567+
-1 => Err(last_error()),
568+
0 => Err(timeout("accept timed out")),
569+
_ => return Ok(()),
570+
}
571+
}
549572
}
550573

551574
impl rtio::RtioSocket for TcpAcceptor {
@@ -561,6 +584,12 @@ impl rtio::RtioTcpAcceptor for TcpAcceptor {
561584

562585
fn accept_simultaneously(&mut self) -> IoResult<()> { Ok(()) }
563586
fn dont_accept_simultaneously(&mut self) -> IoResult<()> { Ok(()) }
587+
fn set_timeout(&mut self, timeout: Option<u64>) {
588+
self.deadline = match timeout {
589+
None => 0,
590+
Some(t) => ::io::timer::now() + t,
591+
};
592+
}
564593
}
565594

566595
////////////////////////////////////////////////////////////////////////////////

branches/try/src/libnative/io/timer_win32.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ fn helper(input: libc::HANDLE, messages: Receiver<Req>) {
8989
}
9090
}
9191

92+
// returns the current time (in milliseconds)
93+
pub fn now() -> u64 {
94+
let mut ticks_per_s = 0;
95+
assert_eq!(unsafe { libc::QueryPerformanceFrequency(&mut ticks_per_s) }, 1);
96+
let ticks_per_s = if ticks_per_s == 0 {1} else {ticks_per_s};
97+
let mut ticks = 0;
98+
assert_eq!(unsafe { libc::QueryPerformanceCounter(&mut ticks) }, 1);
99+
100+
return (ticks as u64 * 1000) / (ticks_per_s as u64);
101+
}
102+
92103
impl Timer {
93104
pub fn new() -> IoResult<Timer> {
94105
timer_helper::boot(helper);

branches/try/src/librustc/back/link.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub fn llvm_err(sess: &Session, msg: ~str) -> ! {
6060
if cstr == ptr::null() {
6161
sess.fatal(msg);
6262
} else {
63-
let err = CString::new(cstr, false);
63+
let err = CString::new(cstr, true);
6464
let err = str::from_utf8_lossy(err.as_bytes());
6565
sess.fatal(msg + ": " + err.as_slice());
6666
}
@@ -516,7 +516,10 @@ pub mod write {
516516

517517
pub fn find_crate_id(attrs: &[ast::Attribute], out_filestem: &str) -> CrateId {
518518
match attr::find_crateid(attrs) {
519-
None => from_str(out_filestem).unwrap(),
519+
None => from_str(out_filestem).unwrap_or_else(|| {
520+
let mut s = out_filestem.chars().filter(|c| c.is_XID_continue());
521+
from_str(s.collect::<~str>()).or(from_str("rust-out")).unwrap()
522+
}),
520523
Some(s) => s,
521524
}
522525
}

branches/try/src/librustc/driver/driver.rs

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,7 @@ pub fn phase_3_run_analysis_passes(sess: Session,
346346
time(time_passes, "effect checking", (), |_|
347347
middle::effect::check_crate(&ty_cx, krate));
348348

349-
let middle::moves::MoveMaps {moves_map, moved_variables_set,
350-
capture_map} =
349+
let middle::moves::MoveMaps {moves_map, capture_map} =
351350
time(time_passes, "compute moves", (), |_|
352351
middle::moves::compute_moves(&ty_cx, krate));
353352

@@ -357,14 +356,11 @@ pub fn phase_3_run_analysis_passes(sess: Session,
357356
time(time_passes, "liveness checking", (), |_|
358357
middle::liveness::check_crate(&ty_cx, &capture_map, krate));
359358

360-
let root_map =
361-
time(time_passes, "borrow checking", (), |_|
362-
middle::borrowck::check_crate(&ty_cx, &moves_map,
363-
&moved_variables_set,
364-
&capture_map, krate));
359+
time(time_passes, "borrow checking", (), |_|
360+
middle::borrowck::check_crate(&ty_cx, &moves_map,
361+
&capture_map, krate));
365362

366363
drop(moves_map);
367-
drop(moved_variables_set);
368364

369365
time(time_passes, "kind checking", (), |_|
370366
kind::check_crate(&ty_cx, krate));
@@ -389,7 +385,6 @@ pub fn phase_3_run_analysis_passes(sess: Session,
389385
exported_items: exported_items,
390386
public_items: public_items,
391387
maps: astencode::Maps {
392-
root_map: root_map,
393388
capture_map: RefCell::new(capture_map)
394389
},
395390
reachable: reachable_map
@@ -493,7 +488,7 @@ pub fn stop_after_phase_5(sess: &Session) -> bool {
493488
fn write_out_deps(sess: &Session,
494489
input: &Input,
495490
outputs: &OutputFilenames,
496-
krate: &ast::Crate) -> io::IoResult<()> {
491+
krate: &ast::Crate) {
497492
let id = link::find_crate_id(krate.attrs.as_slice(), outputs.out_filestem);
498493

499494
let mut out_filenames = Vec::new();
@@ -522,28 +517,34 @@ fn write_out_deps(sess: &Session,
522517
StrInput(..) => {
523518
sess.warn("can not write --dep-info without a filename \
524519
when compiling stdin.");
525-
return Ok(());
520+
return
526521
},
527522
},
528-
_ => return Ok(()),
523+
_ => return,
529524
};
530525

531-
// Build a list of files used to compile the output and
532-
// write Makefile-compatible dependency rules
533-
let files: Vec<~str> = sess.codemap().files.borrow()
534-
.iter().filter_map(|fmap| {
535-
if fmap.is_real_file() {
536-
Some(fmap.name.clone())
537-
} else {
538-
None
539-
}
540-
}).collect();
541-
let mut file = try!(io::File::create(&deps_filename));
542-
for path in out_filenames.iter() {
543-
try!(write!(&mut file as &mut Writer,
544-
"{}: {}\n\n", path.display(), files.connect(" ")));
526+
let result = (|| {
527+
// Build a list of files used to compile the output and
528+
// write Makefile-compatible dependency rules
529+
let files: Vec<~str> = sess.codemap().files.borrow()
530+
.iter().filter(|fmap| fmap.is_real_file())
531+
.map(|fmap| fmap.name.clone())
532+
.collect();
533+
let mut file = try!(io::File::create(&deps_filename));
534+
for path in out_filenames.iter() {
535+
try!(write!(&mut file as &mut Writer,
536+
"{}: {}\n\n", path.display(), files.connect(" ")));
537+
}
538+
Ok(())
539+
})();
540+
541+
match result {
542+
Ok(()) => {}
543+
Err(e) => {
544+
sess.fatal(format!("error writing dependencies to `{}`: {}",
545+
deps_filename.display(), e));
546+
}
545547
}
546-
Ok(())
547548
}
548549

549550
pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
@@ -567,7 +568,7 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
567568
krate, &id);
568569
(outputs, expanded_crate, ast_map)
569570
};
570-
write_out_deps(&sess, input, &outputs, &expanded_crate).unwrap();
571+
write_out_deps(&sess, input, &outputs, &expanded_crate);
571572

572573
if stop_after_phase_2(&sess) { return; }
573574

branches/try/src/librustc/front/config.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -36,6 +36,9 @@ impl<'a> fold::Folder for Context<'a> {
3636
fn fold_item_underscore(&mut self, item: &ast::Item_) -> ast::Item_ {
3737
fold_item_underscore(self, item)
3838
}
39+
fn fold_expr(&mut self, expr: @ast::Expr) -> @ast::Expr {
40+
fold_expr(self, expr)
41+
}
3942
}
4043

4144
pub fn strip_items(krate: ast::Crate,
@@ -189,6 +192,24 @@ fn fold_block(cx: &mut Context, b: ast::P<ast::Block>) -> ast::P<ast::Block> {
189192
})
190193
}
191194

195+
fn fold_expr(cx: &mut Context, expr: @ast::Expr) -> @ast::Expr {
196+
let expr = match expr.node {
197+
ast::ExprMatch(ref m, ref arms) => {
198+
let arms = arms.iter()
199+
.filter(|a| (cx.in_cfg)(a.attrs.as_slice()))
200+
.map(|a| a.clone())
201+
.collect();
202+
@ast::Expr {
203+
id: expr.id,
204+
span: expr.span.clone(),
205+
node: ast::ExprMatch(m.clone(), arms),
206+
}
207+
}
208+
_ => expr.clone()
209+
};
210+
fold::noop_fold_expr(expr, cx)
211+
}
212+
192213
fn item_in_cfg(cx: &mut Context, item: &ast::Item) -> bool {
193214
return (cx.in_cfg)(item.attrs.as_slice());
194215
}

0 commit comments

Comments
 (0)