Skip to content

Commit 88258e9

Browse files
committed
---
yaml --- r: 77273 b: refs/heads/snap-stage3 c: c2bc59e h: refs/heads/master i: 77271: da7be3c v: v3
1 parent bb3fdbd commit 88258e9

21 files changed

+233
-207
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: f1132496dddbdd88f321a7919eec3d65136b3f75
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 3ab0561b00d2993706d11bfbbce4a357110195dd
4+
refs/heads/snap-stage3: c2bc59e0869889d9b996da99915f95ae89ddff00
55
refs/heads/try: ebfe63cd1c0b5d23f7ea60c69b4fde2e30cfd42a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use sync;
4444
use sync::{Mutex, RWLock};
4545

4646
use std::cast;
47-
use std::unstable::sync::UnsafeArc;
47+
use std::unstable::sync::UnsafeAtomicRcBox;
4848
use std::task;
4949
use std::borrow;
5050

@@ -108,7 +108,7 @@ impl<'self> Condvar<'self> {
108108
****************************************************************************/
109109

110110
/// An atomically reference counted wrapper for shared immutable state.
111-
pub struct Arc<T> { priv x: UnsafeArc<T> }
111+
pub struct Arc<T> { priv x: UnsafeAtomicRcBox<T> }
112112

113113

114114
/**
@@ -118,7 +118,7 @@ pub struct Arc<T> { priv x: UnsafeArc<T> }
118118
impl<T:Freeze+Send> Arc<T> {
119119
/// Create an atomically reference counted wrapper.
120120
pub fn new(data: T) -> Arc<T> {
121-
Arc { x: UnsafeArc::new(data) }
121+
Arc { x: UnsafeAtomicRcBox::new(data) }
122122
}
123123

124124
pub fn get<'a>(&'a self) -> &'a T {
@@ -160,7 +160,7 @@ impl<T:Freeze + Send> Clone for Arc<T> {
160160
#[doc(hidden)]
161161
struct MutexArcInner<T> { priv lock: Mutex, priv failed: bool, priv data: T }
162162
/// An Arc with mutable data protected by a blocking mutex.
163-
struct MutexArc<T> { priv x: UnsafeArc<MutexArcInner<T>> }
163+
struct MutexArc<T> { priv x: UnsafeAtomicRcBox<MutexArcInner<T>> }
164164

165165

166166
impl<T:Send> Clone for MutexArc<T> {
@@ -187,7 +187,7 @@ impl<T:Send> MutexArc<T> {
187187
lock: Mutex::new_with_condvars(num_condvars),
188188
failed: false, data: user_data
189189
};
190-
MutexArc { x: UnsafeArc::new(data) }
190+
MutexArc { x: UnsafeAtomicRcBox::new(data) }
191191
}
192192

193193
/**
@@ -309,7 +309,7 @@ struct RWArcInner<T> { priv lock: RWLock, priv failed: bool, priv data: T }
309309
*/
310310
#[no_freeze]
311311
struct RWArc<T> {
312-
priv x: UnsafeArc<RWArcInner<T>>,
312+
priv x: UnsafeAtomicRcBox<RWArcInner<T>>,
313313
}
314314
315315
impl<T:Freeze + Send> Clone for RWArc<T> {
@@ -335,7 +335,7 @@ impl<T:Freeze + Send> RWArc<T> {
335335
lock: RWLock::new_with_condvars(num_condvars),
336336
failed: false, data: user_data
337337
};
338-
RWArc { x: UnsafeArc::new(data), }
338+
RWArc { x: UnsafeAtomicRcBox::new(data), }
339339
}
340340
341341
/**

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

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::comm;
2121
use std::comm::SendDeferred;
2222
use std::comm::{GenericPort, Peekable};
2323
use std::task;
24-
use std::unstable::sync::{Exclusive, UnsafeArc};
24+
use std::unstable::sync::{Exclusive, UnsafeAtomicRcBox};
2525
use std::unstable::atomics;
2626
use std::unstable::finally::Finally;
2727
use std::util;
@@ -135,7 +135,9 @@ impl<Q:Send> Sem<Q> {
135135
do task::unkillable {
136136
do (|| {
137137
self.acquire();
138-
do task::rekillable { blk() }
138+
unsafe {
139+
do task::rekillable { blk() }
140+
}
139141
}).finally {
140142
self.release();
141143
}
@@ -232,8 +234,10 @@ impl<'self> Condvar<'self> {
232234
// signaller already sent -- I mean 'unconditionally' in contrast
233235
// with acquire().)
234236
do (|| {
235-
do task::rekillable {
236-
let _ = WaitEnd.take_unwrap().recv();
237+
unsafe {
238+
do task::rekillable {
239+
let _ = WaitEnd.take_unwrap().recv();
240+
}
237241
}
238242
}).finally {
239243
// Reacquire the condvar. Note this is back in the unkillable
@@ -444,7 +448,7 @@ struct RWLockInner {
444448
pub struct RWLock {
445449
priv order_lock: Semaphore,
446450
priv access_lock: Sem<~[WaitQueue]>,
447-
priv state: UnsafeArc<RWLockInner>,
451+
priv state: UnsafeAtomicRcBox<RWLockInner>,
448452
}
449453

450454
impl RWLock {
@@ -456,7 +460,7 @@ impl RWLock {
456460
* Similar to mutex_with_condvars.
457461
*/
458462
pub fn new_with_condvars(num_condvars: uint) -> RWLock {
459-
let state = UnsafeArc::new(RWLockInner {
463+
let state = UnsafeAtomicRcBox::new(RWLockInner {
460464
read_mode: false,
461465
read_count: atomics::AtomicUint::new(0),
462466
});
@@ -512,12 +516,14 @@ impl RWLock {
512516
* 'write' from other tasks will run concurrently with this one.
513517
*/
514518
pub fn write<U>(&self, blk: &fn() -> U) -> U {
515-
do task::unkillable {
516-
(&self.order_lock).acquire();
517-
do (&self.access_lock).access {
518-
(&self.order_lock).release();
519-
do task::rekillable {
520-
blk()
519+
unsafe {
520+
do task::unkillable {
521+
(&self.order_lock).acquire();
522+
do (&self.access_lock).access {
523+
(&self.order_lock).release();
524+
do task::rekillable {
525+
blk()
526+
}
521527
}
522528
}
523529
}
@@ -556,14 +562,16 @@ impl RWLock {
556562
// which can't happen until T2 finishes the downgrade-read entirely.
557563
// The astute reader will also note that making waking writers use the
558564
// order_lock is better for not starving readers.
559-
do task::unkillable {
560-
(&self.order_lock).acquire();
561-
do (&self.access_lock).access_cond |cond| {
562-
(&self.order_lock).release();
563-
do task::rekillable {
564-
let opt_lock = Just(&self.order_lock);
565-
blk(&Condvar { sem: cond.sem, order: opt_lock,
566-
token: NonCopyable::new() })
565+
unsafe {
566+
do task::unkillable {
567+
(&self.order_lock).acquire();
568+
do (&self.access_lock).access_cond |cond| {
569+
(&self.order_lock).release();
570+
do task::rekillable {
571+
let opt_lock = Just(&self.order_lock);
572+
blk(&Condvar { sem: cond.sem, order: opt_lock,
573+
token: NonCopyable::new() })
574+
}
567575
}
568576
}
569577
}
@@ -598,8 +606,10 @@ impl RWLock {
598606
(&self.access_lock).acquire();
599607
(&self.order_lock).release();
600608
do (|| {
601-
do task::rekillable {
602-
blk(RWLockWriteMode { lock: self, token: NonCopyable::new() })
609+
unsafe {
610+
do task::rekillable {
611+
blk(RWLockWriteMode { lock: self, token: NonCopyable::new() })
612+
}
603613
}
604614
}).finally {
605615
let writer_or_last_reader;

branches/snap-stage3/src/librustc/middle/ty.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3476,18 +3476,18 @@ pub fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str {
34763476
terr_ptr_mutability => ~"pointers differ in mutability",
34773477
terr_ref_mutability => ~"references differ in mutability",
34783478
terr_ty_param_size(values) => {
3479-
fmt!("expected a type with %? type params \
3480-
but found one with %? type params",
3479+
fmt!("expected a type with %u type params \
3480+
but found one with %u type params",
34813481
values.expected, values.found)
34823482
}
34833483
terr_tuple_size(values) => {
3484-
fmt!("expected a tuple with %? elements \
3485-
but found one with %? elements",
3484+
fmt!("expected a tuple with %u elements \
3485+
but found one with %u elements",
34863486
values.expected, values.found)
34873487
}
34883488
terr_record_size(values) => {
3489-
fmt!("expected a record with %? fields \
3490-
but found one with %? fields",
3489+
fmt!("expected a record with %u fields \
3490+
but found one with %u fields",
34913491
values.expected, values.found)
34923492
}
34933493
terr_record_mutability => {

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ let unwrapped_msg = match msg {
4343

4444
use clone::Clone;
4545
use cmp::{Eq,Ord};
46+
use ops::Add;
4647
use util;
4748
use num::Zero;
4849
use iterator;
@@ -76,6 +77,18 @@ impl<T: Eq + Ord> Ord for Option<T> {
7677
}
7778
}
7879

80+
impl<T: Add<T, T>> Add<Option<T>, Option<T>> for Option<T> {
81+
#[inline]
82+
fn add(&self, other: &Option<T>) -> Option<T> {
83+
match (&*self, &*other) {
84+
(&None, &None) => None,
85+
(_, &None) => None,
86+
(&None, _) => None,
87+
(&Some(ref lhs), &Some(ref rhs)) => Some(*lhs + *rhs)
88+
}
89+
}
90+
}
91+
7992
// FIXME: #8242 implementing manually because deriving doesn't work for some reason
8093
impl<T: ToStr> ToStr for Option<T> {
8194
fn to_str(&self) -> ~str {

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

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -75,35 +75,50 @@ impl Repr for bool {
7575
}
7676
}
7777

78-
macro_rules! int_repr(($ty:ident) => (impl Repr for $ty {
78+
impl Repr for int {
79+
fn write_repr(&self, writer: @Writer) {
80+
do ::int::to_str_bytes(*self, 10u) |bits| {
81+
writer.write(bits);
82+
}
83+
}
84+
}
85+
86+
macro_rules! int_repr(($ty:ident, $suffix:expr) => (impl Repr for $ty {
7987
fn write_repr(&self, writer: @Writer) {
8088
do ::$ty::to_str_bytes(*self, 10u) |bits| {
8189
writer.write(bits);
90+
writer.write(bytes!($suffix));
8291
}
8392
}
8493
}))
8594

86-
int_repr!(int)
87-
int_repr!(i8)
88-
int_repr!(i16)
89-
int_repr!(i32)
90-
int_repr!(i64)
91-
int_repr!(uint)
92-
int_repr!(u8)
93-
int_repr!(u16)
94-
int_repr!(u32)
95-
int_repr!(u64)
96-
97-
macro_rules! num_repr(($ty:ident) => (impl Repr for $ty {
95+
int_repr!(i8, "i8")
96+
int_repr!(i16, "i16")
97+
int_repr!(i32, "i32")
98+
int_repr!(i64, "i64")
99+
int_repr!(uint, "u")
100+
int_repr!(u8, "u8")
101+
int_repr!(u16, "u16")
102+
int_repr!(u32, "u32")
103+
int_repr!(u64, "u64")
104+
105+
impl Repr for float {
106+
fn write_repr(&self, writer: @Writer) {
107+
let s = self.to_str();
108+
writer.write(s.as_bytes());
109+
}
110+
}
111+
112+
macro_rules! num_repr(($ty:ident, $suffix:expr) => (impl Repr for $ty {
98113
fn write_repr(&self, writer: @Writer) {
99114
let s = self.to_str();
100115
writer.write(s.as_bytes());
116+
writer.write(bytes!($suffix));
101117
}
102118
}))
103119

104-
num_repr!(float)
105-
num_repr!(f32)
106-
num_repr!(f64)
120+
num_repr!(f32, "f32")
121+
num_repr!(f64, "f64")
107122

108123
// New implementation using reflect::MovePtr
109124

@@ -602,7 +617,7 @@ fn test_repr() {
602617
exact_test(&(@[1,2,3,4,5,6,7,8]),
603618
"@[1, 2, 3, 4, 5, 6, 7, 8]");
604619
exact_test(&(@[1u8,2u8,3u8,4u8]),
605-
"@[1, 2, 3, 4]");
620+
"@[1u8, 2u8, 3u8, 4u8]");
606621
exact_test(&(@["hi", "there"]),
607622
"@[\"hi\", \"there\"]");
608623
exact_test(&(~["hi", "there"]),
@@ -615,14 +630,14 @@ fn test_repr() {
615630
"@{a: 10, b: 1.234}");
616631
exact_test(&(~P{a:10, b:1.234}),
617632
"~{a: 10, b: 1.234}");
618-
exact_test(&(10_u8, ~"hello"),
619-
"(10, ~\"hello\")");
620-
exact_test(&(10_u16, ~"hello"),
621-
"(10, ~\"hello\")");
622-
exact_test(&(10_u32, ~"hello"),
623-
"(10, ~\"hello\")");
624-
exact_test(&(10_u64, ~"hello"),
625-
"(10, ~\"hello\")");
633+
exact_test(&(10u8, ~"hello"),
634+
"(10u8, ~\"hello\")");
635+
exact_test(&(10u16, ~"hello"),
636+
"(10u16, ~\"hello\")");
637+
exact_test(&(10u32, ~"hello"),
638+
"(10u32, ~\"hello\")");
639+
exact_test(&(10u64, ~"hello"),
640+
"(10u64, ~\"hello\")");
626641

627642
struct Foo;
628643
exact_test(&(~[Foo, Foo, Foo]), "~[{}, {}, {}]");

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rt::local::Local;
2121
use rt::select::{SelectInner, SelectPortInner};
2222
use select::{Select, SelectPort};
2323
use unstable::atomics::{AtomicUint, AtomicOption, Acquire, Relaxed, SeqCst};
24-
use unstable::sync::UnsafeArc;
24+
use unstable::sync::UnsafeAtomicRcBox;
2525
use util::Void;
2626
use comm::{GenericChan, GenericSmartChan, GenericPort, Peekable};
2727
use cell::Cell;
@@ -567,14 +567,14 @@ impl<'self, T> SelectPort<T> for &'self Port<T> { }
567567

568568
pub struct SharedChan<T> {
569569
// Just like Chan, but a shared AtomicOption instead of Cell
570-
priv next: UnsafeArc<AtomicOption<StreamChanOne<T>>>
570+
priv next: UnsafeAtomicRcBox<AtomicOption<StreamChanOne<T>>>
571571
}
572572

573573
impl<T> SharedChan<T> {
574574
pub fn new(chan: Chan<T>) -> SharedChan<T> {
575575
let next = chan.next.take();
576576
let next = AtomicOption::new(~next);
577-
SharedChan { next: UnsafeArc::new(next) }
577+
SharedChan { next: UnsafeAtomicRcBox::new(next) }
578578
}
579579
}
580580

@@ -620,7 +620,7 @@ impl<T> Clone for SharedChan<T> {
620620

621621
pub struct SharedPort<T> {
622622
// The next port on which we will receive the next port on which we will receive T
623-
priv next_link: UnsafeArc<AtomicOption<PortOne<StreamPortOne<T>>>>
623+
priv next_link: UnsafeAtomicRcBox<AtomicOption<PortOne<StreamPortOne<T>>>>
624624
}
625625

626626
impl<T> SharedPort<T> {
@@ -630,7 +630,7 @@ impl<T> SharedPort<T> {
630630
let (next_link_port, next_link_chan) = oneshot();
631631
next_link_chan.send(next_data_port);
632632
let next_link = AtomicOption::new(~next_link_port);
633-
SharedPort { next_link: UnsafeArc::new(next_link) }
633+
SharedPort { next_link: UnsafeAtomicRcBox::new(next_link) }
634634
}
635635
}
636636

0 commit comments

Comments
 (0)