Skip to content

Commit 1479eb7

Browse files
committed
---
yaml --- r: 64895 b: refs/heads/snap-stage3 c: 11fc1fd h: refs/heads/master i: 64893: 1e3e5fa 64891: 8466d89 64887: 0c4f003 64879: b0ab78a 64863: 1670e3c 64831: 6f2e4d6 64767: 6b3415b v: v3
1 parent af94730 commit 1479eb7

21 files changed

+327
-835
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: 91f1ab48969e1b7d3f4871348db2ec302000c93a
4+
refs/heads/snap-stage3: 11fc1fd48556ff123487cdf16bfb3ab478084970
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl<T:Freeze+Send> Arc<T> {
136136
*/
137137
pub fn unwrap(self) -> T {
138138
let Arc { x: x } = self;
139-
x.unwrap()
139+
unsafe { x.unwrap() }
140140
}
141141
}
142142

@@ -250,7 +250,7 @@ impl<T:Send> MutexArc<T> {
250250
*/
251251
pub fn unwrap(self) -> T {
252252
let MutexArc { x: x } = self;
253-
let inner = x.unwrap();
253+
let inner = unsafe { x.unwrap() };
254254
let MutexArcInner { failed: failed, data: data, _ } = inner;
255255
if failed {
256256
fail!(~"Can't unwrap poisoned MutexArc - another task failed inside!");
@@ -469,7 +469,7 @@ impl<T:Freeze + Send> RWArc<T> {
469469
*/
470470
pub fn unwrap(self) -> T {
471471
let RWArc { x: x, _ } = self;
472-
let inner = x.unwrap();
472+
let inner = unsafe { x.unwrap() };
473473
let RWArcInner { failed: failed, data: data, _ } = inner;
474474
if failed {
475475
fail!(~"Can't unwrap poisoned RWArc - another task failed inside!")

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

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,11 @@ impl<Q:Send> Sem<Q> {
130130
impl Sem<()> {
131131
pub fn access<U>(&self, blk: &fn() -> U) -> U {
132132
let mut release = None;
133-
do task::unkillable {
134-
self.acquire();
135-
release = Some(SemRelease(self));
133+
unsafe {
134+
do task::unkillable {
135+
self.acquire();
136+
release = Some(SemRelease(self));
137+
}
136138
}
137139
blk()
138140
}
@@ -151,9 +153,11 @@ impl Sem<~[WaitQueue]> {
151153

152154
pub fn access_waitqueue<U>(&self, blk: &fn() -> U) -> U {
153155
let mut release = None;
154-
do task::unkillable {
155-
self.acquire();
156-
release = Some(SemAndSignalRelease(self));
156+
unsafe {
157+
do task::unkillable {
158+
self.acquire();
159+
release = Some(SemAndSignalRelease(self));
160+
}
157161
}
158162
blk()
159163
}
@@ -290,15 +294,17 @@ impl<'self> Condvar<'self> {
290294
#[unsafe_destructor]
291295
impl<'self> Drop for CondvarReacquire<'self> {
292296
fn drop(&self) {
293-
// Needs to succeed, instead of itself dying.
294-
do task::unkillable {
295-
match self.order {
296-
Just(lock) => do lock.access {
297-
self.sem.acquire();
298-
},
299-
Nothing => {
300-
self.sem.acquire();
301-
},
297+
unsafe {
298+
// Needs to succeed, instead of itself dying.
299+
do task::unkillable {
300+
match self.order {
301+
Just(lock) => do lock.access {
302+
self.sem.acquire();
303+
},
304+
Nothing => {
305+
self.sem.acquire();
306+
},
307+
}
302308
}
303309
}
304310
}
@@ -638,12 +644,14 @@ impl RWLock {
638644
// Implementation slightly different from the slicker 'write's above.
639645
// The exit path is conditional on whether the caller downgrades.
640646
let mut _release = None;
641-
do task::unkillable {
642-
(&self.order_lock).acquire();
643-
(&self.access_lock).acquire();
644-
(&self.order_lock).release();
647+
unsafe {
648+
do task::unkillable {
649+
(&self.order_lock).acquire();
650+
(&self.access_lock).acquire();
651+
(&self.order_lock).release();
652+
}
653+
_release = Some(RWLockReleaseDowngrade(self));
645654
}
646-
_release = Some(RWLockReleaseDowngrade(self));
647655
blk(RWLockWriteMode { lock: self })
648656
}
649657

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

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Numeric traits and functions for generic mathematics.
12-
//!
13-
//! These are implemented for the primitive numeric types in `std::{u8, u16,
14-
//! u32, u64, uint, i8, i16, i32, i64, int, f32, f64, float}`.
11+
//! An interface for numeric types
1512
1613
#[allow(missing_doc)];
1714

@@ -22,7 +19,9 @@ use option::Option;
2219

2320
pub mod strconv;
2421

22+
///
2523
/// The base trait for numeric types
24+
///
2625
pub trait Num: Eq + Zero + One
2726
+ Neg<Self>
2827
+ Add<Self,Self>
@@ -46,23 +45,18 @@ pub trait Orderable: Ord {
4645
fn clamp(&self, mn: &Self, mx: &Self) -> Self;
4746
}
4847

49-
#[inline(always)] pub fn min<T: Orderable>(x: T, y: T) -> T { x.min(&y) }
50-
#[inline(always)] pub fn max<T: Orderable>(x: T, y: T) -> T { x.max(&y) }
51-
#[inline(always)] pub fn clamp<T: Orderable>(value: T, mn: T, mx: T) -> T { value.clamp(&mn, &mx) }
48+
#[inline(always)] pub fn min<T: Orderable>(a: T, b: T) -> T { a.min(&b) }
49+
#[inline(always)] pub fn max<T: Orderable>(a: T, b: T) -> T { a.max(&b) }
5250

5351
pub trait Zero {
5452
fn zero() -> Self; // FIXME (#5527): This should be an associated constant
5553
fn is_zero(&self) -> bool;
5654
}
5755

58-
#[inline(always)] pub fn zero<T: Zero>() -> T { Zero::zero() }
59-
6056
pub trait One {
6157
fn one() -> Self; // FIXME (#5527): This should be an associated constant
6258
}
6359

64-
#[inline(always)] pub fn one<T: One>() -> T { One::one() }
65-
6660
pub trait Signed: Num
6761
+ Neg<Self> {
6862
fn abs(&self) -> Self;
@@ -74,7 +68,6 @@ pub trait Signed: Num
7468
}
7569

7670
#[inline(always)] pub fn abs<T: Signed>(value: T) -> T { value.abs() }
77-
#[inline(always)] pub fn abs_sub<T: Signed>(x: T, y: T) -> T { x.abs_sub(&y) }
7871
#[inline(always)] pub fn signum<T: Signed>(value: T) -> T { value.signum() }
7972

8073
pub trait Unsigned: Num {}
@@ -97,9 +90,6 @@ pub trait Integer: Num
9790
fn is_odd(&self) -> bool;
9891
}
9992

100-
#[inline(always)] pub fn gcd<T: Integer>(x: T, y: T) -> T { x.gcd(&y) }
101-
#[inline(always)] pub fn lcm<T: Integer>(x: T, y: T) -> T { x.lcm(&y) }
102-
10393
pub trait Round {
10494
fn floor(&self) -> Self;
10595
fn ceil(&self) -> Self;
@@ -123,21 +113,15 @@ pub trait Algebraic {
123113
fn hypot(&self, other: &Self) -> Self;
124114
}
125115

126-
#[inline(always)] pub fn pow<T: Algebraic>(value: T, n: T) -> T { value.pow(&n) }
127116
#[inline(always)] pub fn sqrt<T: Algebraic>(value: T) -> T { value.sqrt() }
128-
#[inline(always)] pub fn rsqrt<T: Algebraic>(value: T) -> T { value.rsqrt() }
129-
#[inline(always)] pub fn cbrt<T: Algebraic>(value: T) -> T { value.cbrt() }
130-
#[inline(always)] pub fn hypot<T: Algebraic>(x: T, y: T) -> T { x.hypot(&y) }
131117

132118
pub trait Trigonometric {
133119
fn sin(&self) -> Self;
134120
fn cos(&self) -> Self;
135121
fn tan(&self) -> Self;
136-
137122
fn asin(&self) -> Self;
138123
fn acos(&self) -> Self;
139124
fn atan(&self) -> Self;
140-
141125
fn atan2(&self, other: &Self) -> Self;
142126
fn sin_cos(&self) -> (Self, Self);
143127
}
@@ -151,12 +135,10 @@ pub trait Trigonometric {
151135
#[inline(always)] pub fn atan<T: Trigonometric>(value: T) -> T { value.atan() }
152136

153137
#[inline(always)] pub fn atan2<T: Trigonometric>(x: T, y: T) -> T { x.atan2(&y) }
154-
#[inline(always)] pub fn sin_cos<T: Trigonometric>(value: T) -> (T, T) { value.sin_cos() }
155138

156139
pub trait Exponential {
157140
fn exp(&self) -> Self;
158141
fn exp2(&self) -> Self;
159-
160142
fn ln(&self) -> Self;
161143
fn log(&self, base: &Self) -> Self;
162144
fn log2(&self) -> Self;
@@ -175,7 +157,6 @@ pub trait Hyperbolic: Exponential {
175157
fn sinh(&self) -> Self;
176158
fn cosh(&self) -> Self;
177159
fn tanh(&self) -> Self;
178-
179160
fn asinh(&self) -> Self;
180161
fn acosh(&self) -> Self;
181162
fn atanh(&self) -> Self;
@@ -189,7 +170,9 @@ pub trait Hyperbolic: Exponential {
189170
#[inline(always)] pub fn acosh<T: Hyperbolic>(value: T) -> T { value.acosh() }
190171
#[inline(always)] pub fn atanh<T: Hyperbolic>(value: T) -> T { value.atanh() }
191172

173+
///
192174
/// Defines constants and methods common to real numbers
175+
///
193176
pub trait Real: Signed
194177
+ Fractional
195178
+ Algebraic
@@ -220,7 +203,9 @@ pub trait Real: Signed
220203
fn to_radians(&self) -> Self;
221204
}
222205

206+
///
223207
/// Methods that are harder to implement and not commonly used.
208+
///
224209
pub trait RealExt: Real {
225210
// FIXME (#5527): usages of `int` should be replaced with an associated
226211
// integer type once these are implemented
@@ -238,7 +223,9 @@ pub trait RealExt: Real {
238223
fn yn(&self, n: int) -> Self;
239224
}
240225

226+
///
241227
/// Collects the bitwise operators under one trait.
228+
///
242229
pub trait Bitwise: Not<Self>
243230
+ BitAnd<Self,Self>
244231
+ BitOr<Self,Self>
@@ -258,9 +245,11 @@ pub trait Bounded {
258245
fn max_value() -> Self;
259246
}
260247

248+
///
261249
/// Specifies the available operations common to all of Rust's core numeric primitives.
262250
/// These may not always make sense from a purely mathematical point of view, but
263251
/// may be useful for systems programming.
252+
///
264253
pub trait Primitive: Num
265254
+ NumCast
266255
+ Bounded
@@ -275,13 +264,17 @@ pub trait Primitive: Num
275264
fn bytes() -> uint;
276265
}
277266

267+
///
278268
/// A collection of traits relevant to primitive signed and unsigned integers
269+
///
279270
pub trait Int: Integer
280271
+ Primitive
281272
+ Bitwise
282273
+ BitCount {}
283274

275+
///
284276
/// Used for representing the classification of floating point numbers
277+
///
285278
#[deriving(Eq)]
286279
pub enum FPCategory {
287280
/// "Not a Number", often obtained by dividing by zero
@@ -296,7 +289,9 @@ pub enum FPCategory {
296289
FPNormal,
297290
}
298291

292+
///
299293
/// Primitive floating point numbers
294+
///
300295
pub trait Float: Real
301296
+ Signed
302297
+ Primitive
@@ -330,10 +325,7 @@ pub trait Float: Real
330325
fn next_after(&self, other: Self) -> Self;
331326
}
332327

333-
#[inline(always)] pub fn exp_m1<T: Float>(value: T) -> T { value.exp_m1() }
334-
#[inline(always)] pub fn ln_1p<T: Float>(value: T) -> T { value.ln_1p() }
335-
#[inline(always)] pub fn mul_add<T: Float>(a: T, b: T, c: T) -> T { a.mul_add(b, c) }
336-
328+
///
337329
/// Cast from one machine scalar to another
338330
///
339331
/// # Example
@@ -348,7 +340,9 @@ pub fn cast<T:NumCast,U:NumCast>(n: T) -> U {
348340
NumCast::from(n)
349341
}
350342

343+
///
351344
/// An interface for casting between machine scalars
345+
///
352346
pub trait NumCast {
353347
fn from<T:NumCast>(n: T) -> Self;
354348

@@ -420,6 +414,7 @@ pub trait FromStrRadix {
420414
pub fn from_str_radix(str: &str, radix: uint) -> Option<Self>;
421415
}
422416

417+
///
423418
/// Calculates a power to a given radix, optimized for uint `pow` and `radix`.
424419
///
425420
/// Returns `radix^pow` as `T`.

0 commit comments

Comments
 (0)