Skip to content

Commit aed0ffa

Browse files
committed
---
yaml --- r: 64915 b: refs/heads/snap-stage3 c: ebd14c9 h: refs/heads/master i: 64913: 02dfe16 64911: f77e699 v: v3
1 parent fd5d10d commit aed0ffa

File tree

13 files changed

+125
-132
lines changed

13 files changed

+125
-132
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: ef87e2cc965615fa4aae80e3dccccdd3f65c4b08
4+
refs/heads/snap-stage3: ebd14c92f8b15f6d9388ea9bf6f19793a1b77a59
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/configure

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ opt docs 1 "build documentation"
371371
opt optimize 1 "build optimized rust code"
372372
opt optimize-cxx 1 "build optimized C++ code"
373373
opt optimize-llvm 1 "build optimized LLVM"
374-
opt llvm-assertions 1 "build LLVM with assertions"
375374
opt debug 0 "build with extra debug fun"
376375
opt ratchet-bench 0 "ratchet benchmarks"
377376
opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
@@ -794,17 +793,10 @@ do
794793
LLVM_DBG_OPTS="--enable-debug-symbols --disable-optimized"
795794
# Just use LLVM straight from its build directory to
796795
# avoid 'make install' time
797-
LLVM_INST_DIR=$LLVM_BUILD_DIR/Debug
796+
LLVM_INST_DIR=$LLVM_BUILD_DIR/Debug+Asserts
798797
else
799798
LLVM_DBG_OPTS="--enable-optimized"
800-
LLVM_INST_DIR=$LLVM_BUILD_DIR/Release
801-
fi
802-
if [ ! -z "$CFG_DISABLE_LLVM_ASSERTIONS" ]
803-
then
804-
LLVM_ASSERTION_OPTS="--disable-assertions"
805-
else
806-
LLVM_ASSERTION_OPTS="--enable-assertions"
807-
LLVM_INST_DIR=${LLVM_INST_DIR}+Asserts
799+
LLVM_INST_DIR=$LLVM_BUILD_DIR/Release+Asserts
808800
fi
809801
else
810802
msg "not reconfiguring LLVM, external LLVM root"
@@ -844,7 +836,7 @@ do
844836
LLVM_TARGET="--target=$t"
845837

846838
# Disable unused LLVM features
847-
LLVM_OPTS="$LLVM_DBG_OPTS $LLVM_ASSERTION_OPTS --disable-docs --enable-bindings=none"
839+
LLVM_OPTS="$LLVM_DBG_OPTS --disable-docs --enable-bindings=none"
848840

849841
case "$CFG_C_COMPILER" in
850842
("ccache clang")

branches/snap-stage3/src/libextra/arc.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,16 +576,12 @@ mod tests {
576576
let (p, c) = comm::stream();
577577
578578
do task::spawn() || {
579-
let p = comm::PortSet::new();
580-
c.send(p.chan());
581-
582579
let arc_v : Arc<~[int]> = p.recv();
583580
584581
let v = (*arc_v.get()).clone();
585582
assert_eq!(v[3], 4);
586583
};
587584
588-
let c = p.recv();
589585
c.send(arc_v.clone());
590586
591587
assert_eq!(arc_v.get()[2], 3);

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

Lines changed: 2 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@ Message passing
1414

1515
#[allow(missing_doc)];
1616

17-
use cast::{transmute, transmute_mut};
18-
use container::Container;
17+
use cast::transmute;
1918
use either::{Either, Left, Right};
2019
use kinds::Send;
21-
use option::{Option, Some, None};
22-
use uint;
23-
use vec::OwnedVector;
24-
use util::replace;
20+
use option::{Option, Some};
2521
use unstable::sync::Exclusive;
2622
use rtcomm = rt::comm;
2723
use rt;
@@ -143,81 +139,6 @@ impl<T: Send> Selectable for Port<T> {
143139
}
144140
}
145141

146-
/// Treat many ports as one.
147-
#[unsafe_mut_field(ports)]
148-
pub struct PortSet<T> {
149-
ports: ~[pipesy::Port<T>],
150-
}
151-
152-
impl<T: Send> PortSet<T> {
153-
pub fn new() -> PortSet<T> {
154-
PortSet {
155-
ports: ~[]
156-
}
157-
}
158-
159-
pub fn add(&self, port: Port<T>) {
160-
let Port { inner } = port;
161-
let port = match inner {
162-
Left(p) => p,
163-
Right(_) => fail!("PortSet not implemented")
164-
};
165-
unsafe {
166-
let self_ports = transmute_mut(&self.ports);
167-
self_ports.push(port)
168-
}
169-
}
170-
171-
pub fn chan(&self) -> Chan<T> {
172-
let (po, ch) = stream();
173-
self.add(po);
174-
ch
175-
}
176-
}
177-
178-
impl<T:Send> GenericPort<T> for PortSet<T> {
179-
fn try_recv(&self) -> Option<T> {
180-
unsafe {
181-
let self_ports = transmute_mut(&self.ports);
182-
let mut result = None;
183-
// we have to swap the ports array so we aren't borrowing
184-
// aliasable mutable memory.
185-
let mut ports = replace(self_ports, ~[]);
186-
while result.is_none() && ports.len() > 0 {
187-
let i = wait_many(ports);
188-
match ports[i].try_recv() {
189-
Some(m) => {
190-
result = Some(m);
191-
}
192-
None => {
193-
// Remove this port.
194-
let _ = ports.swap_remove(i);
195-
}
196-
}
197-
}
198-
*self_ports = ports;
199-
result
200-
}
201-
}
202-
fn recv(&self) -> T {
203-
self.try_recv().expect("port_set: endpoints closed")
204-
}
205-
}
206-
207-
impl<T: Send> Peekable<T> for PortSet<T> {
208-
fn peek(&self) -> bool {
209-
// It'd be nice to use self.port.each, but that version isn't
210-
// pure.
211-
for uint::range(0, self.ports.len()) |i| {
212-
let port: &pipesy::Port<T> = &self.ports[i];
213-
if port.peek() {
214-
return true;
215-
}
216-
}
217-
false
218-
}
219-
}
220-
221142
/// A channel that can be shared between many senders.
222143
pub struct SharedChan<T> {
223144
inner: Either<Exclusive<pipesy::Chan<T>>, rtcomm::SharedChan<T>>

branches/snap-stage3/src/libstd/unstable/atomics.rs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,18 @@ impl AtomicInt {
205205
pub fn fetch_sub(&mut self, val: int, order: Ordering) -> int {
206206
unsafe { atomic_sub(&mut self.v, val, order) }
207207
}
208+
209+
/// Returns the old value
210+
#[inline]
211+
pub fn fetch_min(&mut self, val: int, order: Ordering) -> int {
212+
unsafe { atomic_min(&mut self.v, val, order) }
213+
}
214+
215+
/// Returns the old value
216+
#[inline]
217+
pub fn fetch_max(&mut self, val: int, order: Ordering) -> int {
218+
unsafe { atomic_max(&mut self.v, val, order) }
219+
}
208220
}
209221

210222
impl AtomicUint {
@@ -243,6 +255,18 @@ impl AtomicUint {
243255
pub fn fetch_sub(&mut self, val: uint, order: Ordering) -> uint {
244256
unsafe { atomic_sub(&mut self.v, val, order) }
245257
}
258+
259+
/// Returns the old value
260+
#[inline]
261+
pub fn fetch_min(&mut self, val: uint, order: Ordering) -> uint {
262+
unsafe { atomic_umin(&mut self.v, val, order) }
263+
}
264+
265+
/// Returns the old value
266+
#[inline]
267+
pub fn fetch_max(&mut self, val: uint, order: Ordering) -> uint {
268+
unsafe { atomic_umax(&mut self.v, val, order) }
269+
}
246270
}
247271

248272
impl<T> AtomicPtr<T> {
@@ -491,6 +515,64 @@ pub unsafe fn atomic_xor<T>(dst: &mut T, val: T, order: Ordering) -> T {
491515
}
492516

493517

518+
#[inline]
519+
pub unsafe fn atomic_max<T>(dst: &mut T, val: T, order: Ordering) -> T {
520+
let dst = cast::transmute(dst);
521+
let val = cast::transmute(val);
522+
523+
cast::transmute(match order {
524+
Acquire => intrinsics::atomic_max_acq(dst, val),
525+
Release => intrinsics::atomic_max_rel(dst, val),
526+
AcqRel => intrinsics::atomic_max_acqrel(dst, val),
527+
Relaxed => intrinsics::atomic_max_relaxed(dst, val),
528+
_ => intrinsics::atomic_max(dst, val)
529+
})
530+
}
531+
532+
533+
#[inline]
534+
pub unsafe fn atomic_min<T>(dst: &mut T, val: T, order: Ordering) -> T {
535+
let dst = cast::transmute(dst);
536+
let val = cast::transmute(val);
537+
538+
cast::transmute(match order {
539+
Acquire => intrinsics::atomic_min_acq(dst, val),
540+
Release => intrinsics::atomic_min_rel(dst, val),
541+
AcqRel => intrinsics::atomic_min_acqrel(dst, val),
542+
Relaxed => intrinsics::atomic_min_relaxed(dst, val),
543+
_ => intrinsics::atomic_min(dst, val)
544+
})
545+
}
546+
547+
#[inline]
548+
pub unsafe fn atomic_umax<T>(dst: &mut T, val: T, order: Ordering) -> T {
549+
let dst = cast::transmute(dst);
550+
let val = cast::transmute(val);
551+
552+
cast::transmute(match order {
553+
Acquire => intrinsics::atomic_umax_acq(dst, val),
554+
Release => intrinsics::atomic_umax_rel(dst, val),
555+
AcqRel => intrinsics::atomic_umax_acqrel(dst, val),
556+
Relaxed => intrinsics::atomic_umax_relaxed(dst, val),
557+
_ => intrinsics::atomic_umax(dst, val)
558+
})
559+
}
560+
561+
562+
#[inline]
563+
pub unsafe fn atomic_umin<T>(dst: &mut T, val: T, order: Ordering) -> T {
564+
let dst = cast::transmute(dst);
565+
let val = cast::transmute(val);
566+
567+
cast::transmute(match order {
568+
Acquire => intrinsics::atomic_umin_acq(dst, val),
569+
Release => intrinsics::atomic_umin_rel(dst, val),
570+
AcqRel => intrinsics::atomic_umin_acqrel(dst, val),
571+
Relaxed => intrinsics::atomic_umin_relaxed(dst, val),
572+
_ => intrinsics::atomic_umin(dst, val)
573+
})
574+
}
575+
494576
/**
495577
* An atomic fence.
496578
*

branches/snap-stage3/src/libsyntax/ext/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ pub fn std_macros() -> @str {
683683
($cond:expr) => {
684684
if !$cond {
685685
::std::sys::FailWithCause::fail_with(
686-
\"assertion failed: \" + stringify!($cond), file!(), line!())
686+
~\"assertion failed: \" + stringify!($cond), file!(), line!())
687687
}
688688
};
689689
($cond:expr, $msg:expr) => {

branches/snap-stage3/src/test/bench/msgsend-pipes.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
extern mod extra;
1818

19-
use std::comm::{PortSet, Chan, stream};
19+
use std::comm::{SharedChan, Chan, stream};
2020
use std::io;
2121
use std::os;
2222
use std::task;
@@ -30,7 +30,7 @@ enum request {
3030
stop
3131
}
3232

33-
fn server(requests: &PortSet<request>, responses: &Chan<uint>) {
33+
fn server(requests: &Port<request>, responses: &Chan<uint>) {
3434
let mut count: uint = 0;
3535
let mut done = false;
3636
while !done {
@@ -50,18 +50,16 @@ fn server(requests: &PortSet<request>, responses: &Chan<uint>) {
5050

5151
fn run(args: &[~str]) {
5252
let (from_child, to_parent) = stream();
53-
let (from_parent_, to_child) = stream();
54-
let from_parent = PortSet::new();
55-
from_parent.add(from_parent_);
53+
let (from_parent, to_child) = stream();
54+
let to_child = SharedChan::new(to_child);
5655

5756
let size = uint::from_str(args[1]).get();
5857
let workers = uint::from_str(args[2]).get();
5958
let num_bytes = 100;
6059
let start = extra::time::precise_time_s();
6160
let mut worker_results = ~[];
6261
for uint::range(0, workers) |_i| {
63-
let (from_parent_, to_child) = stream();
64-
from_parent.add(from_parent_);
62+
let to_child = to_child.clone();
6563
let mut builder = task::task();
6664
builder.future_result(|r| worker_results.push(r));
6765
do builder.spawn {

branches/snap-stage3/src/test/bench/shootout-pfib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,24 @@ use std::u64;
3333
use std::uint;
3434

3535
fn fib(n: int) -> int {
36-
fn pfib(c: &Chan<int>, n: int) {
36+
fn pfib(c: &SharedChan<int>, n: int) {
3737
if n == 0 {
3838
c.send(0);
3939
} else if n <= 2 {
4040
c.send(1);
4141
} else {
42-
let p = PortSet::new();
43-
let ch = p.chan();
42+
let (pp, cc) = stream();
43+
let cc = SharedChan::new(cc);
44+
let ch = cc.clone();
4445
task::spawn(|| pfib(&ch, n - 1) );
45-
let ch = p.chan();
46+
let ch = cc.clone();
4647
task::spawn(|| pfib(&ch, n - 2) );
47-
c.send(p.recv() + p.recv());
48+
c.send(pp.recv() + pp.recv());
4849
}
4950
}
5051

5152
let (p, ch) = stream();
53+
let ch = SharedChan::new(ch);
5254
let _t = task::spawn(|| pfib(&ch, n) );
5355
p.recv()
5456
}

branches/snap-stage3/src/test/run-pass/task-comm-14.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ use std::comm;
1414
use std::task;
1515

1616
pub fn main() {
17-
let po = comm::PortSet::new();
17+
let (po, ch) = comm::stream();
18+
let ch = comm::SharedChan::new(ch);
1819

1920
// Spawn 10 tasks each sending us back one int.
2021
let mut i = 10;
2122
while (i > 0) {
2223
info!(i);
23-
let (p, ch) = comm::stream();
24-
po.add(p);
24+
let ch = ch.clone();
2525
task::spawn({let i = i; || child(i, &ch)});
2626
i = i - 1;
2727
}
@@ -39,7 +39,7 @@ pub fn main() {
3939
info!("main thread exiting");
4040
}
4141

42-
fn child(x: int, ch: &comm::Chan<int>) {
42+
fn child(x: int, ch: &comm::SharedChan<int>) {
4343
info!(x);
4444
ch.send(x);
4545
}

0 commit comments

Comments
 (0)