Skip to content

Commit 9a7fe60

Browse files
committed
---
yaml --- r: 139981 b: refs/heads/try2 c: 51a68eb h: refs/heads/master i: 139979: b216364 v: v3
1 parent 45ba01b commit 9a7fe60

33 files changed

+289
-344
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: f0afe23dce9699f2776907d2adde126baea58f30
8+
refs/heads/try2: 51a68eb9b14f5d6f8ac358eed8c11e8567d5f87b
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/at_vec.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub mod rustrt {
4141
pub fn capacity<T>(v: @[T]) -> uint {
4242
unsafe {
4343
let repr: **raw::VecRepr =
44-
::cast::reinterpret_cast(&addr_of(&v));
44+
::cast::transmute(addr_of(&v));
4545
(**repr).unboxed.alloc / sys::size_of::<T>()
4646
}
4747
}
@@ -208,7 +208,7 @@ pub mod raw {
208208
*/
209209
#[inline(always)]
210210
pub unsafe fn set_len<T>(v: @[T], new_len: uint) {
211-
let repr: **mut VecRepr = ::cast::reinterpret_cast(&addr_of(&v));
211+
let repr: **mut VecRepr = ::cast::transmute(addr_of(&v));
212212
(**repr).unboxed.fill = new_len * sys::size_of::<T>();
213213
}
214214

@@ -226,7 +226,7 @@ pub mod raw {
226226

227227
#[inline(always)] // really pretty please
228228
pub unsafe fn push_fast<T>(v: &mut @[T], initval: T) {
229-
let repr: **mut VecRepr = ::cast::reinterpret_cast(&v);
229+
let repr: **mut VecRepr = ::cast::transmute(v);
230230
let fill = (**repr).unboxed.fill;
231231
(**repr).unboxed.fill += sys::size_of::<T>();
232232
let p = addr_of(&((**repr).unboxed.data));
@@ -322,4 +322,4 @@ mod test {
322322
assert!(from_slice([@"abc", @"123"]) == @[@"abc", @"123"]);
323323
assert!(from_slice([@[42]]) == @[@[42]]);
324324
}
325-
}
325+
}

branches/try2/src/libcore/gc.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ pub mod rustrt {
7777
}
7878

7979
unsafe fn bump<T, U>(ptr: *T, count: uint) -> *U {
80-
return cast::reinterpret_cast(&ptr::offset(ptr, count));
80+
return cast::transmute(ptr::offset(ptr, count));
8181
}
8282

8383
unsafe fn align_to_pointer<T>(ptr: *T) -> *T {
8484
let align = sys::min_align_of::<*T>();
85-
let ptr: uint = cast::reinterpret_cast(&ptr);
85+
let ptr: uint = cast::transmute(ptr);
8686
let ptr = (ptr + (align - 1)) & -align;
87-
return cast::reinterpret_cast(&ptr);
87+
return cast::transmute(ptr);
8888
}
8989

9090
unsafe fn get_safe_point_count() -> uint {
@@ -129,8 +129,8 @@ type Visitor<'self> = &'self fn(root: **Word, tydesc: *Word) -> bool;
129129
// Walks the list of roots for the given safe point, and calls visitor
130130
// on each root.
131131
unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) {
132-
let fp_bytes: *u8 = cast::reinterpret_cast(&fp);
133-
let sp_meta: *u32 = cast::reinterpret_cast(&sp.sp_meta);
132+
let fp_bytes: *u8 = cast::transmute(fp);
133+
let sp_meta: *u32 = cast::transmute(sp.sp_meta);
134134

135135
let num_stack_roots = *sp_meta as uint;
136136
let num_reg_roots = *ptr::offset(sp_meta, 1) as uint;
@@ -171,9 +171,9 @@ unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) {
171171

172172
// Is fp contained in segment?
173173
unsafe fn is_frame_in_segment(fp: *Word, segment: *StackSegment) -> bool {
174-
let begin: Word = cast::reinterpret_cast(&segment);
175-
let end: Word = cast::reinterpret_cast(&(*segment).end);
176-
let frame: Word = cast::reinterpret_cast(&fp);
174+
let begin: Word = cast::transmute(segment);
175+
let end: Word = cast::transmute((*segment).end);
176+
let frame: Word = cast::transmute(fp);
177177

178178
return begin <= frame && frame <= end;
179179
}
@@ -339,7 +339,7 @@ pub fn cleanup_stack_for_failure() {
339339
// own stack roots on the stack anyway.
340340
let sentinel_box = ~0;
341341
let sentinel: **Word = if expect_sentinel() {
342-
cast::reinterpret_cast(&ptr::addr_of(&sentinel_box))
342+
cast::transmute(ptr::addr_of(&sentinel_box))
343343
} else {
344344
ptr::null()
345345
};

branches/try2/src/libcore/iterator.rs

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ pub trait IteratorUtil<A> {
3939
fn take_while<'r>(self, predicate: &'r fn(&A) -> bool) -> TakeWhileIterator<'r, A, Self>;
4040
fn skip(self, n: uint) -> SkipIterator<Self>;
4141
fn take(self, n: uint) -> TakeIterator<Self>;
42-
fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option<B>)
43-
-> ScanIterator<'r, A, B, Self, St>;
4442
fn advance(&mut self, f: &fn(A) -> bool);
4543
}
4644

@@ -95,12 +93,6 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
9593
TakeIterator{iter: self, n: n}
9694
}
9795

98-
#[inline(always)]
99-
fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option<B>)
100-
-> ScanIterator<'r, A, B, T, St> {
101-
ScanIterator{iter: self, f: f, state: initial_state}
102-
}
103-
10496
/// A shim implementing the `for` loop iteration protocol for iterator objects
10597
#[inline]
10698
fn advance(&mut self, f: &fn(A) -> bool) {
@@ -314,13 +306,12 @@ impl<A, T: Iterator<A>> Iterator<A> for TakeIterator<T> {
314306

315307
pub struct UnfoldrIterator<'self, A, St> {
316308
priv f: &'self fn(&mut St) -> Option<A>,
317-
state: St
309+
priv state: St
318310
}
319311

320312
pub impl<'self, A, St> UnfoldrIterator<'self, A, St> {
321313
#[inline]
322-
fn new(f: &'self fn(&mut St) -> Option<A>, initial_state: St)
323-
-> UnfoldrIterator<'self, A, St> {
314+
fn new(f: &'self fn(&mut St) -> Option<A>, initial_state: St) -> UnfoldrIterator<'self, A, St> {
324315
UnfoldrIterator {
325316
f: f,
326317
state: initial_state
@@ -335,19 +326,6 @@ impl<'self, A, St> Iterator<A> for UnfoldrIterator<'self, A, St> {
335326
}
336327
}
337328

338-
pub struct ScanIterator<'self, A, B, T, St> {
339-
priv iter: T,
340-
priv f: &'self fn(&mut St, A) -> Option<B>,
341-
state: St
342-
}
343-
344-
impl<'self, A, B, T: Iterator<A>, St> Iterator<B> for ScanIterator<'self, A, B, T, St> {
345-
#[inline]
346-
fn next(&mut self) -> Option<B> {
347-
self.iter.next().chain(|a| (self.f)(&mut self.state, a))
348-
}
349-
}
350-
351329
#[cfg(test)]
352330
mod tests {
353331
use super::*;
@@ -428,25 +406,6 @@ mod tests {
428406
assert_eq!(i, ys.len());
429407
}
430408

431-
#[test]
432-
fn test_iterator_scan() {
433-
// test the type inference
434-
fn add(old: &mut int, new: &uint) -> Option<float> {
435-
*old += *new as int;
436-
Some(*old as float)
437-
}
438-
let xs = [0u, 1, 2, 3, 4];
439-
let ys = [0f, 1f, 3f, 6f, 10f];
440-
441-
let mut it = xs.iter().scan(0, add);
442-
let mut i = 0;
443-
for it.advance |x| {
444-
assert_eq!(x, ys[i]);
445-
i += 1;
446-
}
447-
assert_eq!(i, ys.len());
448-
}
449-
450409
#[test]
451410
fn test_unfoldr() {
452411
fn count(st: &mut uint) -> Option<uint> {

branches/try2/src/libcore/num/f32.rs

Lines changed: 72 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010

1111
//! Operations and constants for `f32`
1212
13+
use cmath;
14+
use libc::{c_float, c_int};
1315
use num::strconv;
1416
use num;
1517
use option::Option;
18+
use unstable::intrinsics::floorf32;
1619
use from_str;
1720
use to_str;
1821

@@ -21,93 +24,79 @@ use to_str;
2124

2225
pub use cmath::c_float_targ_consts::*;
2326

24-
// An inner module is required to get the #[inline(always)] attribute on the
25-
// functions.
26-
pub use self::delegated::*;
27-
2827
macro_rules! delegate(
2928
(
30-
$(
31-
fn $name:ident(
32-
$(
33-
$arg:ident : $arg_ty:ty
34-
),*
35-
) -> $rv:ty = $bound_name:path
36-
),*
37-
) => (
38-
mod delegated {
39-
use cmath::c_float_utils;
40-
use libc::{c_float, c_int};
41-
use unstable::intrinsics;
42-
29+
fn $name:ident(
4330
$(
44-
#[inline(always)]
45-
pub fn $name($( $arg : $arg_ty ),*) -> $rv {
46-
unsafe {
47-
$bound_name($( $arg ),*)
48-
}
49-
}
50-
)*
31+
$arg:ident : $arg_ty:ty
32+
),*
33+
) -> $rv:ty = $bound_name:path
34+
) => (
35+
pub fn $name($( $arg : $arg_ty ),*) -> $rv {
36+
unsafe {
37+
$bound_name($( $arg ),*)
38+
}
5139
}
5240
)
5341
)
5442

55-
delegate!(
56-
// intrinsics
57-
fn abs(n: f32) -> f32 = intrinsics::fabsf32,
58-
fn cos(n: f32) -> f32 = intrinsics::cosf32,
59-
fn exp(n: f32) -> f32 = intrinsics::expf32,
60-
fn exp2(n: f32) -> f32 = intrinsics::exp2f32,
61-
fn floor(x: f32) -> f32 = intrinsics::floorf32,
62-
fn ln(n: f32) -> f32 = intrinsics::logf32,
63-
fn log10(n: f32) -> f32 = intrinsics::log10f32,
64-
fn log2(n: f32) -> f32 = intrinsics::log2f32,
65-
fn mul_add(a: f32, b: f32, c: f32) -> f32 = intrinsics::fmaf32,
66-
fn pow(n: f32, e: f32) -> f32 = intrinsics::powf32,
67-
fn powi(n: f32, e: c_int) -> f32 = intrinsics::powif32,
68-
fn sin(n: f32) -> f32 = intrinsics::sinf32,
69-
fn sqrt(n: f32) -> f32 = intrinsics::sqrtf32,
70-
71-
// LLVM 3.3 required to use intrinsics for these four
72-
fn ceil(n: c_float) -> c_float = c_float_utils::ceil,
73-
fn trunc(n: c_float) -> c_float = c_float_utils::trunc,
74-
/*
75-
fn ceil(n: f32) -> f32 = intrinsics::ceilf32,
76-
fn trunc(n: f32) -> f32 = intrinsics::truncf32,
77-
fn rint(n: f32) -> f32 = intrinsics::rintf32,
78-
fn nearbyint(n: f32) -> f32 = intrinsics::nearbyintf32,
79-
*/
80-
81-
// cmath
82-
fn acos(n: c_float) -> c_float = c_float_utils::acos,
83-
fn asin(n: c_float) -> c_float = c_float_utils::asin,
84-
fn atan(n: c_float) -> c_float = c_float_utils::atan,
85-
fn atan2(a: c_float, b: c_float) -> c_float = c_float_utils::atan2,
86-
fn cbrt(n: c_float) -> c_float = c_float_utils::cbrt,
87-
fn copysign(x: c_float, y: c_float) -> c_float = c_float_utils::copysign,
88-
fn cosh(n: c_float) -> c_float = c_float_utils::cosh,
89-
fn erf(n: c_float) -> c_float = c_float_utils::erf,
90-
fn erfc(n: c_float) -> c_float = c_float_utils::erfc,
91-
fn expm1(n: c_float) -> c_float = c_float_utils::expm1,
92-
fn abs_sub(a: c_float, b: c_float) -> c_float = c_float_utils::abs_sub,
93-
fn fmax(a: c_float, b: c_float) -> c_float = c_float_utils::fmax,
94-
fn fmin(a: c_float, b: c_float) -> c_float = c_float_utils::fmin,
95-
fn nextafter(x: c_float, y: c_float) -> c_float = c_float_utils::nextafter,
96-
fn frexp(n: c_float, value: &mut c_int) -> c_float = c_float_utils::frexp,
97-
fn hypot(x: c_float, y: c_float) -> c_float = c_float_utils::hypot,
98-
fn ldexp(x: c_float, n: c_int) -> c_float = c_float_utils::ldexp,
99-
fn lgamma(n: c_float, sign: &mut c_int) -> c_float = c_float_utils::lgamma,
100-
fn log_radix(n: c_float) -> c_float = c_float_utils::log_radix,
101-
fn ln1p(n: c_float) -> c_float = c_float_utils::ln1p,
102-
fn ilog_radix(n: c_float) -> c_int = c_float_utils::ilog_radix,
103-
fn modf(n: c_float, iptr: &mut c_float) -> c_float = c_float_utils::modf,
104-
fn round(n: c_float) -> c_float = c_float_utils::round,
105-
fn ldexp_radix(n: c_float, i: c_int) -> c_float = c_float_utils::ldexp_radix,
106-
fn sinh(n: c_float) -> c_float = c_float_utils::sinh,
107-
fn tan(n: c_float) -> c_float = c_float_utils::tan,
108-
fn tanh(n: c_float) -> c_float = c_float_utils::tanh,
109-
fn tgamma(n: c_float) -> c_float = c_float_utils::tgamma)
110-
43+
delegate!(fn acos(n: c_float) -> c_float = cmath::c_float_utils::acos)
44+
delegate!(fn asin(n: c_float) -> c_float = cmath::c_float_utils::asin)
45+
delegate!(fn atan(n: c_float) -> c_float = cmath::c_float_utils::atan)
46+
delegate!(fn atan2(a: c_float, b: c_float) -> c_float =
47+
cmath::c_float_utils::atan2)
48+
delegate!(fn cbrt(n: c_float) -> c_float = cmath::c_float_utils::cbrt)
49+
delegate!(fn ceil(n: c_float) -> c_float = cmath::c_float_utils::ceil)
50+
delegate!(fn copysign(x: c_float, y: c_float) -> c_float =
51+
cmath::c_float_utils::copysign)
52+
delegate!(fn cos(n: c_float) -> c_float = cmath::c_float_utils::cos)
53+
delegate!(fn cosh(n: c_float) -> c_float = cmath::c_float_utils::cosh)
54+
delegate!(fn erf(n: c_float) -> c_float = cmath::c_float_utils::erf)
55+
delegate!(fn erfc(n: c_float) -> c_float = cmath::c_float_utils::erfc)
56+
delegate!(fn exp(n: c_float) -> c_float = cmath::c_float_utils::exp)
57+
delegate!(fn expm1(n: c_float) -> c_float = cmath::c_float_utils::expm1)
58+
delegate!(fn exp2(n: c_float) -> c_float = cmath::c_float_utils::exp2)
59+
delegate!(fn abs(n: c_float) -> c_float = cmath::c_float_utils::abs)
60+
delegate!(fn abs_sub(a: c_float, b: c_float) -> c_float =
61+
cmath::c_float_utils::abs_sub)
62+
delegate!(fn mul_add(a: c_float, b: c_float, c: c_float) -> c_float =
63+
cmath::c_float_utils::mul_add)
64+
delegate!(fn fmax(a: c_float, b: c_float) -> c_float =
65+
cmath::c_float_utils::fmax)
66+
delegate!(fn fmin(a: c_float, b: c_float) -> c_float =
67+
cmath::c_float_utils::fmin)
68+
delegate!(fn nextafter(x: c_float, y: c_float) -> c_float =
69+
cmath::c_float_utils::nextafter)
70+
delegate!(fn frexp(n: c_float, value: &mut c_int) -> c_float =
71+
cmath::c_float_utils::frexp)
72+
delegate!(fn hypot(x: c_float, y: c_float) -> c_float =
73+
cmath::c_float_utils::hypot)
74+
delegate!(fn ldexp(x: c_float, n: c_int) -> c_float =
75+
cmath::c_float_utils::ldexp)
76+
delegate!(fn lgamma(n: c_float, sign: &mut c_int) -> c_float =
77+
cmath::c_float_utils::lgamma)
78+
delegate!(fn ln(n: c_float) -> c_float = cmath::c_float_utils::ln)
79+
delegate!(fn log_radix(n: c_float) -> c_float =
80+
cmath::c_float_utils::log_radix)
81+
delegate!(fn ln1p(n: c_float) -> c_float = cmath::c_float_utils::ln1p)
82+
delegate!(fn log10(n: c_float) -> c_float = cmath::c_float_utils::log10)
83+
delegate!(fn log2(n: c_float) -> c_float = cmath::c_float_utils::log2)
84+
delegate!(fn ilog_radix(n: c_float) -> c_int =
85+
cmath::c_float_utils::ilog_radix)
86+
delegate!(fn modf(n: c_float, iptr: &mut c_float) -> c_float =
87+
cmath::c_float_utils::modf)
88+
delegate!(fn pow(n: c_float, e: c_float) -> c_float =
89+
cmath::c_float_utils::pow)
90+
delegate!(fn round(n: c_float) -> c_float = cmath::c_float_utils::round)
91+
delegate!(fn ldexp_radix(n: c_float, i: c_int) -> c_float =
92+
cmath::c_float_utils::ldexp_radix)
93+
delegate!(fn sin(n: c_float) -> c_float = cmath::c_float_utils::sin)
94+
delegate!(fn sinh(n: c_float) -> c_float = cmath::c_float_utils::sinh)
95+
delegate!(fn sqrt(n: c_float) -> c_float = cmath::c_float_utils::sqrt)
96+
delegate!(fn tan(n: c_float) -> c_float = cmath::c_float_utils::tan)
97+
delegate!(fn tanh(n: c_float) -> c_float = cmath::c_float_utils::tanh)
98+
delegate!(fn tgamma(n: c_float) -> c_float = cmath::c_float_utils::tgamma)
99+
delegate!(fn trunc(n: c_float) -> c_float = cmath::c_float_utils::trunc)
111100

112101
// These are not defined inside consts:: for consistency with
113102
// the integer types
@@ -154,6 +143,9 @@ pub fn ge(x: f32, y: f32) -> bool { return x >= y; }
154143
#[inline(always)]
155144
pub fn gt(x: f32, y: f32) -> bool { return x > y; }
156145

146+
/// Returns `x` rounded down
147+
#[inline(always)]
148+
pub fn floor(x: f32) -> f32 { unsafe { floorf32(x) } }
157149

158150
// FIXME (#1999): replace the predicates below with llvm intrinsics or
159151
// calls to the libmath macros in the rust runtime for performance.

0 commit comments

Comments
 (0)