Skip to content

Commit 60e09e1

Browse files
committed
---
yaml --- r: 60797 b: refs/heads/auto c: ff86830 h: refs/heads/master i: 60795: e455d1d v: v3
1 parent d43d3ca commit 60e09e1

File tree

232 files changed

+2768
-4720
lines changed

Some content is hidden

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

232 files changed

+2768
-4720
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 6861d542a2ab3c8eca58a64bd6b93f067427e1bb
17+
refs/heads/auto: ff86830c9c2c0e4e88070206bd73f88ad7141b1e
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ src/.DS_Store
7373
/doc/html
7474
/doc/latex
7575
/doc/std
76-
/doc/extra
7776
/nd/
7877
/llvm/
7978
version.md
@@ -82,6 +81,7 @@ keywords.md
8281
x86_64-apple-darwin/
8382
x86_64-unknown-linux-gnu/
8483
i686-unknown-linux-gnu/
84+
doc/core/
8585
tmp.*.rs
8686
config.stamp
8787
.DS_Store

branches/auto/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ DRIVER_CRATE := $(S)src/driver/driver.rs
275275

276276
# FIXME: x86-ism
277277
LLVM_COMPONENTS=x86 arm mips ipo bitreader bitwriter linker asmparser jit mcjit \
278-
interpreter instrumentation
278+
interpreter
279279

280280
define DEF_LLVM_VARS
281281
# The configure script defines these variables with the target triples

branches/auto/configure

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,11 @@ then
555555
CFG_CLANG_VERSION=$("$CFG_CLANG" \
556556
--version \
557557
| grep version \
558-
| sed 's/.*\(version .*\)/\1/; s/.*based on \(LLVM .*\))/\1/' \
558+
| sed 's/.*\(version .*\)/\1/' \
559559
| cut -d ' ' -f 2)
560560

561561
case $CFG_CLANG_VERSION in
562-
(3.0svn | 3.0 | 3.1* | 3.2* | 3.3*)
562+
(3.0svn | 3.0 | 3.1* | 3.2* | 3.3* | 4.0* | 4.1* | 4.2*)
563563
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
564564
CFG_C_COMPILER="clang"
565565
;;

branches/auto/doc/tutorial-tasks.md

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ let result = ports.foldl(0, |accum, port| *accum + port.recv() );
284284
# fn some_expensive_computation(_i: uint) -> int { 42 }
285285
~~~
286286

287-
## Backgrounding computations: Futures
287+
## Futures
288288
With `extra::future`, rust has a mechanism for requesting a computation and getting the result
289289
later.
290290

@@ -329,77 +329,6 @@ fn main() {
329329
}
330330
~~~
331331

332-
## Sharing immutable data without copy: ARC
333-
334-
To share immutable data between tasks, a first approach would be to only use pipes as we have seen
335-
previously. A copy of the data to share would then be made for each task. In some cases, this would
336-
add up to a significant amount of wasted memory and would require copying the same data more than
337-
necessary.
338-
339-
To tackle this issue, one can use an Atomically Reference Counted wrapper (`ARC`) as implemented in
340-
the `extra` library of Rust. With an ARC, the data will no longer be copied for each task. The ARC
341-
acts as a reference to the shared data and only this reference is shared and cloned.
342-
343-
Here is a small example showing how to use ARCs. We wish to run concurrently several computations on
344-
a single large vector of floats. Each task needs the full vector to perform its duty.
345-
~~~
346-
use extra::arc::ARC;
347-
348-
fn pnorm(nums: &~[float], p: uint) -> float {
349-
(vec::foldl(0.0, *nums, |a,b| a+(*b).pow(p as float) )).pow(1f / (p as float))
350-
}
351-
352-
fn main() {
353-
let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
354-
println(fmt!("Inf-norm = %?", numbers.max()));
355-
356-
let numbers_arc = ARC(numbers);
357-
358-
for uint::range(1,10) |num| {
359-
let (port, chan) = stream();
360-
chan.send(numbers_arc.clone());
361-
362-
do spawn {
363-
let local_arc : ARC<~[float]> = port.recv();
364-
let task_numbers = local_arc.get();
365-
println(fmt!("%u-norm = %?", num, pnorm(task_numbers, num)));
366-
}
367-
}
368-
}
369-
~~~
370-
371-
The function `pnorm` performs a simple computation on the vector (it computes the sum of its items
372-
at the power given as argument and takes the inverse power of this value). The ARC on the vector is
373-
created by the line
374-
~~~
375-
# use extra::arc::ARC;
376-
# let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
377-
let numbers_arc=ARC(numbers);
378-
~~~
379-
and a clone of it is sent to each task
380-
~~~
381-
# use extra::arc::ARC;
382-
# let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
383-
# let numbers_arc = ARC(numbers);
384-
# let (port, chan) = stream();
385-
chan.send(numbers_arc.clone());
386-
~~~
387-
copying only the wrapper and not its contents.
388-
389-
Each task recovers the underlying data by
390-
~~~
391-
# use extra::arc::ARC;
392-
# let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
393-
# let numbers_arc=ARC(numbers);
394-
# let (port, chan) = stream();
395-
# chan.send(numbers_arc.clone());
396-
# let local_arc : ARC<~[float]> = port.recv();
397-
let task_numbers = local_arc.get();
398-
~~~
399-
and can use it as if it were local.
400-
401-
The `arc` module also implements ARCs around mutable data that are not covered here.
402-
403332
# Handling task failure
404333

405334
Rust has a built-in mechanism for raising exceptions. The `fail!()` macro

branches/auto/mk/platform.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $(foreach t,$(CFG_TARGET_TRIPLES),$(info cfg: os for $(t) is $(OSTYPE_$(t))))
2929
# FIXME: no-omit-frame-pointer is just so that task_start_wrapper
3030
# has a frame pointer and the stack walker can understand it. Turning off
3131
# frame pointers everywhere is overkill
32-
CFG_GCCISH_CFLAGS += -fno-omit-frame-pointer -DUSE_UTF8
32+
CFG_GCCISH_CFLAGS += -fno-omit-frame-pointer
3333

3434
# On Darwin, we need to run dsymutil so the debugging information ends
3535
# up in the right place. On other platforms, it automatically gets

branches/auto/mk/rustllvm.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ LLVM_EXTRA_INCDIRS_$(1)= -iquote $(S)src/llvm/include \
2222
-iquote llvm/$(1)/include
2323
endif
2424

25-
RUSTLLVM_OBJS_CS_$(1) := $$(addprefix rustllvm/, RustWrapper.cpp PassWrapper.cpp)
25+
RUSTLLVM_OBJS_CS_$(1) := $$(addprefix rustllvm/, RustWrapper.cpp)
2626

2727
RUSTLLVM_DEF_$(1) := rustllvm/rustllvm$(CFG_DEF_SUFFIX_$(1))
2828

branches/auto/mk/target.mk

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

11+
# This is the compile-time target-triple for the compiler. For the compiler at
12+
# runtime, this should be considered the host-triple. More explanation for why
13+
# this exists can be found on issue #2400
14+
export CFG_COMPILER_TRIPLE
15+
1116
# TARGET_STAGE_N template: This defines how target artifacts are built
1217
# for all stage/target architecture combinations. The arguments:
1318
# $(1) is the stage
@@ -62,6 +67,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM_$(3)): \
6267
@$$(call E, cp: $$@)
6368
$$(Q)cp $$< $$@
6469

70+
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): CFG_COMPILER_TRIPLE = $(2)
6571
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): \
6672
$$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
6773
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)) \

branches/auto/mk/tests.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ define TEST_RUNNER
284284
# If NO_REBUILD is set then break the dependencies on extra so we can
285285
# test crates without rebuilding std and extra first
286286
ifeq ($(NO_REBUILD),)
287-
STDTESTDEP_$(1)_$(2)_$(3) = $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_EXTRALIB_$(2))
287+
STDTESTDEP_$(1)_$(2)_$(3) = $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB_$(2))
288288
else
289289
STDTESTDEP_$(1)_$(2)_$(3) =
290290
endif
@@ -307,6 +307,7 @@ $(3)/stage$(1)/test/syntaxtest-$(2)$$(X_$(2)): \
307307
@$$(call E, compile_and_link: $$@)
308308
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
309309

310+
$(3)/stage$(1)/test/rustctest-$(2)$$(X_$(2)): CFG_COMPILER_TRIPLE = $(2)
310311
$(3)/stage$(1)/test/rustctest-$(2)$$(X_$(2)): \
311312
$$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
312313
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM_$(2)) \

branches/auto/src/compiletest/procsrv.rs

Lines changed: 69 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
use core::prelude::*;
1212

13+
use core::libc::c_int;
14+
use core::run::spawn_process;
1315
use core::run;
1416

1517
#[cfg(target_os = "win32")]
@@ -36,35 +38,86 @@ fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
3638
#[cfg(target_os = "macos")]
3739
#[cfg(target_os = "freebsd")]
3840
fn target_env(_lib_path: &str, _prog: &str) -> ~[(~str,~str)] {
39-
os::env()
41+
~[]
4042
}
4143
4244
pub struct Result {status: int, out: ~str, err: ~str}
4345
46+
// FIXME (#2659): This code is duplicated in core::run::program_output
4447
pub fn run(lib_path: &str,
4548
prog: &str,
4649
args: &[~str],
4750
env: ~[(~str, ~str)],
4851
input: Option<~str>) -> Result {
52+
let pipe_in = os::pipe();
53+
let pipe_out = os::pipe();
54+
let pipe_err = os::pipe();
55+
let pid = spawn_process(prog, args,
56+
&Some(env + target_env(lib_path, prog)),
57+
&None, pipe_in.in, pipe_out.out, pipe_err.out);
58+
59+
os::close(pipe_in.in);
60+
os::close(pipe_out.out);
61+
os::close(pipe_err.out);
62+
if pid == -1i32 {
63+
os::close(pipe_in.out);
64+
os::close(pipe_out.in);
65+
os::close(pipe_err.in);
66+
fail!();
67+
}
4968
50-
let env = env + target_env(lib_path, prog);
51-
let mut proc = run::Process::new(prog, args, run::ProcessOptions {
52-
env: Some(env.slice(0, env.len())),
53-
dir: None,
54-
in_fd: None,
55-
out_fd: None,
56-
err_fd: None
57-
});
5869
59-
for input.each |input| {
60-
proc.input().write_str(*input);
70+
writeclose(pipe_in.out, input);
71+
let p = comm::PortSet::new();
72+
let ch = p.chan();
73+
do task::spawn_sched(task::SingleThreaded) || {
74+
let errput = readclose(pipe_err.in);
75+
ch.send((2, errput));
6176
}
62-
let output = proc.finish_with_output();
77+
let ch = p.chan();
78+
do task::spawn_sched(task::SingleThreaded) || {
79+
let output = readclose(pipe_out.in);
80+
ch.send((1, output));
81+
}
82+
let status = run::waitpid(pid);
83+
let mut errs = ~"";
84+
let mut outs = ~"";
85+
let mut count = 2;
86+
while count > 0 {
87+
match p.recv() {
88+
(1, s) => {
89+
outs = s;
90+
}
91+
(2, s) => {
92+
errs = s;
93+
}
94+
_ => { fail!() }
95+
};
96+
count -= 1;
97+
};
98+
return Result {status: status, out: outs, err: errs};
99+
}
63100
64-
Result {
65-
status: output.status,
66-
out: str::from_bytes(output.output),
67-
err: str::from_bytes(output.error)
101+
fn writeclose(fd: c_int, s: Option<~str>) {
102+
if s.is_some() {
103+
let writer = io::fd_writer(fd, false);
104+
writer.write_str(s.get());
68105
}
106+
107+
os::close(fd);
69108
}
70109
110+
fn readclose(fd: c_int) -> ~str {
111+
unsafe {
112+
// Copied from run::program_output
113+
let file = os::fdopen(fd);
114+
let reader = io::FILE_reader(file, false);
115+
let mut buf = ~"";
116+
while !reader.eof() {
117+
let bytes = reader.read_bytes(4096u);
118+
str::push_str(&mut buf, str::from_bytes(bytes));
119+
}
120+
os::fclose(file);
121+
return buf;
122+
}
123+
}

branches/auto/src/etc/ctags.rust

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
--regex-rust=/[ \t]*type[ \t]+([a-zA-Z0-9_]+)/\1/T,types/
55
--regex-rust=/[ \t]*enum[ \t]+([a-zA-Z0-9_]+)/\1/T,types/
66
--regex-rust=/[ \t]*struct[ \t]+([a-zA-Z0-9_]+)/\1/m,types/
7+
--regex-rust=/[ \t]*class[ \t]+([a-zA-Z0-9_]+)/\1/m,types/
78
--regex-rust=/[ \t]*mod[ \t]+([a-zA-Z0-9_]+)/\1/m,modules/
8-
--regex-rust=/[ \t]*static[ \t]+([a-zA-Z0-9_]+)/\1/m,consts/
9+
--regex-rust=/[ \t]*const[ \t]+([a-zA-Z0-9_]+)/\1/m,consts/
910
--regex-rust=/[ \t]*trait[ \t]+([a-zA-Z0-9_]+)/\1/m,traits/
1011
--regex-rust=/[ \t]*impl[ \t]+([a-zA-Z0-9_]+)/\1/m,impls/
12+
--regex-rust=/[ \t]*impl[ \t]+of[ \t]([a-zA-Z0-9_]+)/\1/m,impls/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"Highlight the 100th text column
2+
"Feature became available in v7.3
3+
if version >= 703
4+
setlocal colorcolumn=100
5+
endif

branches/auto/src/libextra/arc.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* In this example, a large vector of floats is shared between several tasks.
1818
* With simple pipes, without ARC, a copy would have to be made for each task.
1919
*
20-
* ~~~ {.rust}
20+
* ~~~
2121
* extern mod std;
2222
* use std::arc;
2323
* let numbers=vec::from_fn(100, |ind| (ind as float)*rand::random());
@@ -370,10 +370,7 @@ pub impl<T:Const + Owned> RWARC<T> {
370370
* See sync::rwlock.write_downgrade(). The RWWriteMode token must be used
371371
* to obtain the &mut T, and can be transformed into a RWReadMode token by
372372
* calling downgrade(), after which a &T can be obtained instead.
373-
*
374-
* # Example
375-
*
376-
* ~~~ {.rust}
373+
* ~~~
377374
* do arc.write_downgrade |write_mode| {
378375
* do (&write_mode).write_cond |state, condvar| {
379376
* ... exclusive access with mutable state ...
@@ -510,6 +507,7 @@ mod tests {
510507
use core::prelude::*;
511508
use core::cell::Cell;
512509
use arc::*;
510+
use arc;
513511

514512
#[test]
515513
fn manually_share_arc() {

0 commit comments

Comments
 (0)