Skip to content

Commit f055e1d

Browse files
committed
---
yaml --- r: 94798 b: refs/heads/try c: aa5d779 h: refs/heads/master v: v3
1 parent e34f1ce commit f055e1d

Some content is hidden

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

58 files changed

+2099
-777
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: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
5-
refs/heads/try: a9a7a427a1f1a61497105283594d32b976d7559f
5+
refs/heads/try: aa5d779a3590b1ed1559e0489138040a71ae688b
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
branch = master
99
[submodule "src/gyp"]
1010
path = src/gyp
11-
url = https://github.com/brson/gyp.git
11+
url = https://github.com/alexcrichton/gyp.git

branches/try/doc/tutorial.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3071,7 +3071,7 @@ Therefore, if you plan to compile your crate as a library, you should annotate i
30713071
30723072
# #[crate_type = "lib"];
30733073
// Package ID
3074-
#[pkgid = "farm#2.5"];
3074+
#[crate_id = "farm#2.5"];
30753075
30763076
// ...
30773077
# fn farm() {}
@@ -3095,7 +3095,7 @@ or setting the crate type (library or executable) explicitly:
30953095
// ...
30963096
30973097
// This crate is a library ("bin" is the default)
3098-
#[pkgid = "farm#2.5"];
3098+
#[crate_id = "farm#2.5"];
30993099
#[crate_type = "lib"];
31003100
31013101
// Turn on a warning
@@ -3116,7 +3116,7 @@ We define two crates, and use one of them as a library in the other.
31163116

31173117
~~~~
31183118
// world.rs
3119-
#[pkgid = "world#0.42"];
3119+
#[crate_id = "world#0.42"];
31203120
# extern mod extra;
31213121
pub fn explore() -> &'static str { "world" }
31223122
# fn main() {}

branches/try/mk/docs.mk

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
######################################################################
1414

1515
DOCS :=
16+
CDOCS :=
1617
DOCS_L10N :=
1718

1819
BASE_DOC_OPTS := --from=markdown --standalone --toc --number-sections
@@ -232,8 +233,21 @@ doc/$(1)/index.html: $$(RUSTDOC) $$(TLIB2_T_$(3)_H_$(3))/$(CFG_STDLIB_$(3))
232233
DOCS += doc/$(1)/index.html
233234
endef
234235

236+
define compiledoc
237+
doc/$(1)/index.html: $$(RUSTDOC) $$(TLIB2_T_$(3)_H_$(3))/$(CFG_STDLIB_$(3))
238+
@$$(call E, rustdoc: $$@)
239+
$(Q)$(RUSTDOC) --cfg stage2 $(2)
240+
241+
CDOCS += doc/$(1)/index.html
242+
endef
243+
235244
$(eval $(call libdoc,std,$(STDLIB_CRATE),$(CFG_BUILD)))
236245
$(eval $(call libdoc,extra,$(EXTRALIB_CRATE),$(CFG_BUILD)))
246+
$(eval $(call libdoc,native,$(LIBNATIVE_CRATE),$(CFG_BUILD)))
247+
$(eval $(call libdoc,green,$(LIBGREEN_CRATE),$(CFG_BUILD)))
248+
249+
$(eval $(call compiledoc,rustc,$(COMPILER_CRATE),$(CFG_BUILD)))
250+
$(eval $(call compiledoc,syntax,$(LIBSYNTAX_CRATE),$(CFG_BUILD)))
237251

238252

239253
ifdef CFG_DISABLE_DOCS
@@ -256,6 +270,7 @@ doc/version_info.html: version_info.html.template $(MKFILE_DEPS) \
256270
GENERATED += doc/version.md doc/version_info.html
257271

258272
docs: $(DOCS)
273+
compiler-docs: $(CDOCS)
259274

260275
docs-l10n: $(DOCS_L10N)
261276

branches/try/src/etc/vim/syntax/rust.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ syn keyword rustTrait Default
7878
syn keyword rustTrait Hash
7979
syn keyword rustTrait FromStr
8080
syn keyword rustTrait FromIterator Extendable
81-
syn keyword rustTrait Iterator DoubleEndedIterator RandomAccessIterator ClonableIterator
81+
syn keyword rustTrait Iterator DoubleEndedIterator RandomAccessIterator CloneableIterator
8282
syn keyword rustTrait OrdIterator MutableDoubleEndedIterator ExactSize
8383
syn keyword rustTrait Times
8484

branches/try/src/gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit f407f09c94e00d2d570e8e42114e3f6848b2deb2
1+
Subproject commit 1e46da1000bc29679ab4cebf3c1034cb7d6f4487

branches/try/src/libextra/enum_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! This module defines a container which uses an efficient bit mask
1414
//! representation to hold C-like enum variants.
1515
16-
#[deriving(Clone, Eq, IterBytes, ToStr)]
16+
#[deriving(Clone, Eq, IterBytes, ToStr, Encodable, Decodable)]
1717
/// A specialized Set implementation to use enum types.
1818
pub struct EnumSet<E> {
1919
// We must maintain the invariant that no bits are set

branches/try/src/libgreen/lib.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,7 @@ impl SchedPool {
214214
pool.handles.push(sched.make_handle());
215215
let sched = sched;
216216
pool.threads.push(do Thread::start {
217-
let mut sched = sched;
218-
let task = do GreenTask::new(&mut sched.stack_pool, None) {
219-
rtdebug!("boostraping a non-primary scheduler");
220-
};
221-
sched.bootstrap(task);
217+
sched.bootstrap();
222218
});
223219
}
224220

@@ -270,13 +266,7 @@ impl SchedPool {
270266
let ret = sched.make_handle();
271267
self.handles.push(sched.make_handle());
272268
let sched = sched;
273-
self.threads.push(do Thread::start {
274-
let mut sched = sched;
275-
let task = do GreenTask::new(&mut sched.stack_pool, None) {
276-
rtdebug!("boostraping a non-primary scheduler");
277-
};
278-
sched.bootstrap(task);
279-
});
269+
self.threads.push(do Thread::start { sched.bootstrap() });
280270

281271
return ret;
282272
}

branches/try/src/libgreen/sched.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl Scheduler {
171171

172172
// Take a main task to run, and a scheduler to run it in. Create a
173173
// scheduler task and bootstrap into it.
174-
pub fn bootstrap(mut ~self, task: ~GreenTask) {
174+
pub fn bootstrap(mut ~self) {
175175

176176
// Build an Idle callback.
177177
let cb = ~SchedRunner as ~Callback;
@@ -187,18 +187,11 @@ impl Scheduler {
187187
self.idle_callback.get_mut_ref().resume();
188188

189189
// Now, as far as all the scheduler state is concerned, we are inside
190-
// the "scheduler" context. So we can act like the scheduler and resume
191-
// the provided task. Let it think that the currently running task is
192-
// actually the sched_task so it knows where to squirrel it away.
193-
let mut sched_task = self.resume_task_immediately(sched_task, task);
194-
195-
// Now we are back in the scheduler context, having
196-
// successfully run the input task. Start by running the
197-
// scheduler. Grab it out of TLS - performing the scheduler
198-
// action will have given it away.
199-
let sched = sched_task.sched.take_unwrap();
200-
rtdebug!("starting scheduler {}", sched.sched_id());
201-
let mut sched_task = sched.run(sched_task);
190+
// the "scheduler" context. The scheduler immediately hands over control
191+
// to the event loop, and this will only exit once the event loop no
192+
// longer has any references (handles or I/O objects).
193+
rtdebug!("starting scheduler {}", self.sched_id());
194+
let mut sched_task = self.run(sched_task);
202195

203196
// Close the idle callback.
204197
let mut sched = sched_task.sched.take_unwrap();
@@ -548,7 +541,10 @@ impl Scheduler {
548541
// We push the task onto our local queue clone.
549542
assert!(!task.is_sched());
550543
self.work_queue.push(task);
551-
self.idle_callback.get_mut_ref().resume();
544+
match self.idle_callback {
545+
Some(ref mut idle) => idle.resume(),
546+
None => {} // allow enqueuing before the scheduler starts
547+
}
552548

553549
// We've made work available. Notify a
554550
// sleeping scheduler.
@@ -1176,25 +1172,21 @@ mod test {
11761172
let mut sh = special_handle;
11771173
sh.send(Shutdown);
11781174
};
1179-
1175+
normal_sched.enqueue_task(normal_task);
11801176

11811177
let special_task = do GreenTask::new(&mut special_sched.stack_pool,
11821178
None) {
11831179
run(task1);
11841180
run(task3);
11851181
chan.send(());
11861182
};
1187-
1183+
special_sched.enqueue_task(special_task);
11881184

11891185
let normal_sched = normal_sched;
1190-
let normal_thread = do Thread::start {
1191-
normal_sched.bootstrap(normal_task);
1192-
};
1186+
let normal_thread = do Thread::start { normal_sched.bootstrap() };
11931187

11941188
let special_sched = special_sched;
1195-
let special_thread = do Thread::start {
1196-
special_sched.bootstrap(special_task);
1197-
};
1189+
let special_thread = do Thread::start { special_sched.bootstrap() };
11981190

11991191
normal_thread.join();
12001192
special_thread.join();

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use super::IoResult;
2626
#[cfg(windows)] use std::ptr;
2727
#[cfg(windows)] use std::str;
2828

29-
fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 {
29+
pub fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 {
3030
#[cfg(windows)] static eintr: int = 0; // doesn't matter
3131
#[cfg(not(windows))] static eintr: int = libc::EINTR as int;
3232

@@ -37,7 +37,7 @@ fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 {
3737
let mut ret;
3838
loop {
3939
ret = f(data, amt);
40-
if cfg!(not(windows)) { break } // windows has no eintr
40+
if cfg!(windows) { break } // windows has no eintr
4141
// if we get an eintr, then try again
4242
if ret != -1 || os::errno() as int != eintr { break }
4343
}
@@ -73,7 +73,10 @@ impl FileDesc {
7373
FileDesc { fd: fd, close_on_drop: close_on_drop }
7474
}
7575

76-
fn inner_read(&mut self, buf: &mut [u8]) -> Result<uint, IoError> {
76+
// FIXME(#10465) these functions should not be public, but anything in
77+
// native::io wanting to use them is forced to have all the
78+
// rtio traits in scope
79+
pub fn inner_read(&mut self, buf: &mut [u8]) -> Result<uint, IoError> {
7780
#[cfg(windows)] type rlen = libc::c_uint;
7881
#[cfg(not(windows))] type rlen = libc::size_t;
7982
let ret = keep_going(buf, |buf, len| {
@@ -89,7 +92,7 @@ impl FileDesc {
8992
Ok(ret as uint)
9093
}
9194
}
92-
fn inner_write(&mut self, buf: &[u8]) -> Result<(), IoError> {
95+
pub fn inner_write(&mut self, buf: &[u8]) -> Result<(), IoError> {
9396
#[cfg(windows)] type wlen = libc::c_uint;
9497
#[cfg(not(windows))] type wlen = libc::size_t;
9598
let ret = keep_going(buf, |buf, len| {
@@ -103,6 +106,8 @@ impl FileDesc {
103106
Ok(())
104107
}
105108
}
109+
110+
pub fn fd(&self) -> fd_t { self.fd }
106111
}
107112

108113
impl io::Reader for FileDesc {

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

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub use self::process::Process;
4444
// Native I/O implementations
4545
pub mod file;
4646
pub mod process;
47+
pub mod net;
4748

4849
type IoResult<T> = Result<T, IoError>;
4950

@@ -55,12 +56,25 @@ fn unimpl() -> IoError {
5556
}
5657
}
5758

58-
fn last_error() -> IoError {
59+
fn translate_error(errno: i32, detail: bool) -> IoError {
5960
#[cfg(windows)]
6061
fn get_err(errno: i32) -> (io::IoErrorKind, &'static str) {
6162
match errno {
6263
libc::EOF => (io::EndOfFile, "end of file"),
63-
_ => (io::OtherIoError, "unknown error"),
64+
libc::WSAECONNREFUSED => (io::ConnectionRefused, "connection refused"),
65+
libc::WSAECONNRESET => (io::ConnectionReset, "connection reset"),
66+
libc::WSAEACCES => (io::PermissionDenied, "permission denied"),
67+
libc::WSAEWOULDBLOCK =>
68+
(io::ResourceUnavailable, "resource temporarily unavailable"),
69+
libc::WSAENOTCONN => (io::NotConnected, "not connected"),
70+
libc::WSAECONNABORTED => (io::ConnectionAborted, "connection aborted"),
71+
libc::WSAEADDRNOTAVAIL => (io::ConnectionRefused, "address not available"),
72+
libc::WSAEADDRINUSE => (io::ConnectionRefused, "address in use"),
73+
74+
x => {
75+
debug!("ignoring {}: {}", x, os::last_os_error());
76+
(io::OtherIoError, "unknown error")
77+
}
6478
}
6579
}
6680

@@ -69,24 +83,38 @@ fn last_error() -> IoError {
6983
// XXX: this should probably be a bit more descriptive...
7084
match errno {
7185
libc::EOF => (io::EndOfFile, "end of file"),
86+
libc::ECONNREFUSED => (io::ConnectionRefused, "connection refused"),
87+
libc::ECONNRESET => (io::ConnectionReset, "connection reset"),
88+
libc::EPERM | libc::EACCES =>
89+
(io::PermissionDenied, "permission denied"),
90+
libc::EPIPE => (io::BrokenPipe, "broken pipe"),
91+
libc::ENOTCONN => (io::NotConnected, "not connected"),
92+
libc::ECONNABORTED => (io::ConnectionAborted, "connection aborted"),
93+
libc::EADDRNOTAVAIL => (io::ConnectionRefused, "address not available"),
94+
libc::EADDRINUSE => (io::ConnectionRefused, "address in use"),
7295

7396
// These two constants can have the same value on some systems, but
7497
// different values on others, so we can't use a match clause
7598
x if x == libc::EAGAIN || x == libc::EWOULDBLOCK =>
7699
(io::ResourceUnavailable, "resource temporarily unavailable"),
77100

78-
_ => (io::OtherIoError, "unknown error"),
101+
x => {
102+
debug!("ignoring {}: {}", x, os::last_os_error());
103+
(io::OtherIoError, "unknown error")
104+
}
79105
}
80106
}
81107

82-
let (kind, desc) = get_err(os::errno() as i32);
108+
let (kind, desc) = get_err(errno);
83109
IoError {
84110
kind: kind,
85111
desc: desc,
86-
detail: Some(os::last_os_error())
112+
detail: if detail {Some(os::last_os_error())} else {None},
87113
}
88114
}
89115

116+
fn last_error() -> IoError { translate_error(os::errno() as i32, true) }
117+
90118
// unix has nonzero values as errors
91119
fn mkerr_libc(ret: libc::c_int) -> IoResult<()> {
92120
if ret != 0 {
@@ -106,17 +134,37 @@ fn mkerr_winbool(ret: libc::c_int) -> IoResult<()> {
106134
}
107135
}
108136

137+
#[cfg(unix)]
138+
fn retry(f: || -> libc::c_int) -> IoResult<libc::c_int> {
139+
loop {
140+
match f() {
141+
-1 if os::errno() as int == libc::EINTR as int => {}
142+
-1 => return Err(last_error()),
143+
n => return Ok(n),
144+
}
145+
}
146+
}
147+
109148
/// Implementation of rt::rtio's IoFactory trait to generate handles to the
110149
/// native I/O functionality.
111-
pub struct IoFactory;
150+
pub struct IoFactory {
151+
priv cannot_construct_outside_of_this_module: ()
152+
}
153+
154+
impl IoFactory {
155+
pub fn new() -> IoFactory {
156+
net::init();
157+
IoFactory { cannot_construct_outside_of_this_module: () }
158+
}
159+
}
112160

113161
impl rtio::IoFactory for IoFactory {
114162
// networking
115-
fn tcp_connect(&mut self, _addr: SocketAddr) -> IoResult<~RtioTcpStream> {
116-
Err(unimpl())
163+
fn tcp_connect(&mut self, addr: SocketAddr) -> IoResult<~RtioTcpStream> {
164+
net::TcpStream::connect(addr).map(|s| ~s as ~RtioTcpStream)
117165
}
118-
fn tcp_bind(&mut self, _addr: SocketAddr) -> IoResult<~RtioTcpListener> {
119-
Err(unimpl())
166+
fn tcp_bind(&mut self, addr: SocketAddr) -> IoResult<~RtioTcpListener> {
167+
net::TcpListener::bind(addr).map(|s| ~s as ~RtioTcpListener)
120168
}
121169
fn udp_bind(&mut self, _addr: SocketAddr) -> IoResult<~RtioUdpSocket> {
122170
Err(unimpl())
@@ -204,9 +252,7 @@ impl rtio::IoFactory for IoFactory {
204252
}
205253
fn tty_open(&mut self, fd: c_int, _readable: bool) -> IoResult<~RtioTTY> {
206254
if unsafe { libc::isatty(fd) } != 0 {
207-
// Don't ever close the stdio file descriptors, nothing good really
208-
// comes of that.
209-
Ok(~file::FileDesc::new(fd, fd > libc::STDERR_FILENO) as ~RtioTTY)
255+
Ok(~file::FileDesc::new(fd, true) as ~RtioTTY)
210256
} else {
211257
Err(IoError {
212258
kind: io::MismatchedFileTypeForOperation,

0 commit comments

Comments
 (0)