Skip to content

Commit 41a017a

Browse files
committed
---
yaml --- r: 71989 b: refs/heads/dist-snap c: 685c4d0 h: refs/heads/master i: 71987: 6db50b0 v: v3
1 parent 5a46a62 commit 41a017a

Some content is hidden

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

75 files changed

+2187
-1582
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10-
refs/heads/dist-snap: 8978643f92fc8780515d838a9797f9454386618b
10+
refs/heads/dist-snap: 685c4d0b76b26439905b0676069818e757913319
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libcore/comm.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,16 @@ impl<T: Owned> Peekable<T> for Port<T> {
188188
189189
#[inline(always)]
190190
fn port_peek<T:Owned>(self: &Port<T>) -> bool {
191-
let mut endp = None;
192-
endp <-> self.endp;
193-
let peek = match &endp {
194-
&Some(ref endp) => peek(endp),
195-
&None => fail!(~"peeking empty stream")
196-
};
197-
self.endp <-> endp;
198-
peek
191+
unsafe {
192+
let mut endp = None;
193+
endp <-> self.endp;
194+
let peek = match &endp {
195+
&Some(ref endp) => peek(endp),
196+
&None => fail!(~"peeking empty stream")
197+
};
198+
self.endp <-> endp;
199+
peek
200+
}
199201
}
200202
201203
impl<T: Owned> Selectable for Port<T> {

branches/dist-snap/src/libcore/core.rc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub use vec::{OwnedVector, OwnedCopyableVector};
9999
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
100100
pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times};
101101

102-
pub use num::{Num, NumCast};
102+
pub use num::NumCast;
103103
pub use ptr::Ptr;
104104
pub use to_str::ToStr;
105105
pub use clone::Clone;
@@ -176,7 +176,6 @@ pub mod from_str;
176176
#[path = "num/num.rs"]
177177
pub mod num;
178178
pub mod iter;
179-
pub mod iterator;
180179
pub mod to_str;
181180
pub mod to_bytes;
182181
pub mod clone;

branches/dist-snap/src/libcore/io.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,8 +1536,11 @@ pub fn with_bytes_writer(f: &fn(@Writer)) -> ~[u8] {
15361536
pub fn with_str_writer(f: &fn(@Writer)) -> ~str {
15371537
let mut v = with_bytes_writer(f);
15381538
1539-
// Make sure the vector has a trailing null and is proper utf8.
1540-
v.push(0);
1539+
// FIXME (#3758): This should not be needed.
1540+
unsafe {
1541+
// Make sure the vector has a trailing null and is proper utf8.
1542+
v.push(0);
1543+
}
15411544
assert!(str::is_utf8(v));
15421545
15431546
unsafe { ::cast::transmute(v) }
@@ -1637,14 +1640,16 @@ pub mod fsync {
16371640
// outer res
16381641
pub fn FILE_res_sync(file: &FILERes, opt_level: Option<Level>,
16391642
blk: &fn(v: Res<*libc::FILE>)) {
1640-
blk(Res(Arg {
1641-
val: file.f, opt_level: opt_level,
1642-
fsync_fn: |file, l| {
1643-
unsafe {
1644-
os::fsync_fd(libc::fileno(file), l) as int
1643+
unsafe {
1644+
blk(Res(Arg {
1645+
val: file.f, opt_level: opt_level,
1646+
fsync_fn: |file, l| {
1647+
unsafe {
1648+
os::fsync_fd(libc::fileno(file), l) as int
1649+
}
16451650
}
1646-
}
1647-
}));
1651+
}));
1652+
}
16481653
}
16491654

16501655
// fsync fd after executing blk

branches/dist-snap/src/libcore/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub fn foldl<A,B,IA:BaseIter<A>>(self: &IA, b0: B, blk: &fn(&B, &A) -> B)
161161

162162
#[inline(always)]
163163
pub fn to_vec<A:Copy,IA:BaseIter<A>>(self: &IA) -> ~[A] {
164-
map_to_vec(self, |&x| x)
164+
foldl::<A,~[A],IA>(self, ~[], |r, a| vec::append(copy (*r), ~[*a]))
165165
}
166166

167167
#[inline(always)]

branches/dist-snap/src/libcore/iterator.rs

Lines changed: 0 additions & 101 deletions
This file was deleted.

branches/dist-snap/src/libcore/libc.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,6 @@ pub mod consts {
863863
pub static F_TEST : int = 3;
864864
pub static F_TLOCK : int = 2;
865865
pub static F_ULOCK : int = 0;
866-
pub static SIGKILL : int = 9;
867-
pub static SIGTERM : int = 15;
868866
}
869867
pub mod posix01 {
870868
}
@@ -932,8 +930,6 @@ pub mod consts {
932930
pub static F_TEST : int = 3;
933931
pub static F_TLOCK : int = 2;
934932
pub static F_ULOCK : int = 0;
935-
pub static SIGKILL : int = 9;
936-
pub static SIGTERM : int = 15;
937933
}
938934
pub mod posix01 {
939935
}
@@ -1002,8 +998,6 @@ pub mod consts {
1002998
pub static F_TEST : int = 3;
1003999
pub static F_TLOCK : int = 2;
10041000
pub static F_ULOCK : int = 0;
1005-
pub static SIGKILL : int = 9;
1006-
pub static SIGTERM : int = 15;
10071001
}
10081002
pub mod posix01 {
10091003
}
@@ -1488,17 +1482,6 @@ pub mod funcs {
14881482
-> ssize_t;
14891483
}
14901484
}
1491-
1492-
#[nolink]
1493-
#[abi = "cdecl"]
1494-
pub mod signal {
1495-
use libc::types::os::arch::c95::{c_int};
1496-
use libc::types::os::arch::posix88::{pid_t};
1497-
1498-
pub extern {
1499-
unsafe fn kill(pid: pid_t, sig: c_int) -> c_int;
1500-
}
1501-
}
15021485
}
15031486

15041487
#[cfg(target_os = "linux")]
@@ -1640,7 +1623,6 @@ pub mod funcs {
16401623
pub mod extra {
16411624

16421625
pub mod kernel32 {
1643-
use libc::types::os::arch::c95::{c_uint};
16441626
use libc::types::os::arch::extra::{BOOL, DWORD, HMODULE};
16451627
use libc::types::os::arch::extra::{LPCWSTR, LPWSTR, LPTCH};
16461628
use libc::types::os::arch::extra::{LPSECURITY_ATTRIBUTES};
@@ -1681,7 +1663,6 @@ pub mod funcs {
16811663
findFileData: HANDLE)
16821664
-> BOOL;
16831665
unsafe fn FindClose(findFile: HANDLE) -> BOOL;
1684-
unsafe fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint) -> BOOL;
16851666
}
16861667
}
16871668

branches/dist-snap/src/libcore/managed.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ pub mod raw {
3838
#[inline(always)]
3939
pub fn ptr_eq<T>(a: @T, b: @T) -> bool {
4040
//! Determine if two shared boxes point to the same object
41-
ptr::addr_of(&(*a)) == ptr::addr_of(&(*b))
41+
unsafe { ptr::addr_of(&(*a)) == ptr::addr_of(&(*b)) }
4242
}
4343

4444
#[inline(always)]
4545
pub fn mut_ptr_eq<T>(a: @mut T, b: @mut T) -> bool {
4646
//! Determine if two mutable shared boxes point to the same object
47-
ptr::addr_of(&(*a)) == ptr::addr_of(&(*b))
47+
unsafe { ptr::addr_of(&(*a)) == ptr::addr_of(&(*b)) }
4848
}
4949

5050
#[cfg(notest)]

branches/dist-snap/src/libcore/num/f32.rs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1313
use cmath;
1414
use libc::{c_float, c_int};
15+
use num::NumCast;
1516
use num::strconv;
1617
use num;
1718
use option::Option;
@@ -286,6 +287,30 @@ impl num::One for f32 {
286287
fn one() -> f32 { 1.0 }
287288
}
288289

290+
impl NumCast for f32 {
291+
/**
292+
* Cast `n` to an `f32`
293+
*/
294+
#[inline(always)]
295+
fn from<N:NumCast>(n: N) -> f32 { n.to_f32() }
296+
297+
#[inline(always)] fn to_u8(&self) -> u8 { *self as u8 }
298+
#[inline(always)] fn to_u16(&self) -> u16 { *self as u16 }
299+
#[inline(always)] fn to_u32(&self) -> u32 { *self as u32 }
300+
#[inline(always)] fn to_u64(&self) -> u64 { *self as u64 }
301+
#[inline(always)] fn to_uint(&self) -> uint { *self as uint }
302+
303+
#[inline(always)] fn to_i8(&self) -> i8 { *self as i8 }
304+
#[inline(always)] fn to_i16(&self) -> i16 { *self as i16 }
305+
#[inline(always)] fn to_i32(&self) -> i32 { *self as i32 }
306+
#[inline(always)] fn to_i64(&self) -> i64 { *self as i64 }
307+
#[inline(always)] fn to_int(&self) -> int { *self as int }
308+
309+
#[inline(always)] fn to_f32(&self) -> f32 { *self }
310+
#[inline(always)] fn to_f64(&self) -> f64 { *self as f64 }
311+
#[inline(always)] fn to_float(&self) -> float { *self as float }
312+
}
313+
289314
#[cfg(notest)]
290315
impl ops::Add<f32,f32> for f32 {
291316
fn add(&self, other: &f32) -> f32 { *self + *other }
@@ -555,6 +580,63 @@ impl num::FromStrRadix for f32 {
555580
}
556581
}
557582

583+
#[test]
584+
pub fn test_num() {
585+
let ten: f32 = num::cast(10);
586+
let two: f32 = num::cast(2);
587+
588+
assert!((ten.add(&two) == num::cast(12)));
589+
assert!((ten.sub(&two) == num::cast(8)));
590+
assert!((ten.mul(&two) == num::cast(20)));
591+
assert!((ten.div(&two) == num::cast(5)));
592+
assert!((ten.modulo(&two) == num::cast(0)));
593+
}
594+
595+
#[test]
596+
fn test_numcast() {
597+
assert!((20u == 20f32.to_uint()));
598+
assert!((20u8 == 20f32.to_u8()));
599+
assert!((20u16 == 20f32.to_u16()));
600+
assert!((20u32 == 20f32.to_u32()));
601+
assert!((20u64 == 20f32.to_u64()));
602+
assert!((20i == 20f32.to_int()));
603+
assert!((20i8 == 20f32.to_i8()));
604+
assert!((20i16 == 20f32.to_i16()));
605+
assert!((20i32 == 20f32.to_i32()));
606+
assert!((20i64 == 20f32.to_i64()));
607+
assert!((20f == 20f32.to_float()));
608+
assert!((20f32 == 20f32.to_f32()));
609+
assert!((20f64 == 20f32.to_f64()));
610+
611+
assert!((20f32 == NumCast::from(20u)));
612+
assert!((20f32 == NumCast::from(20u8)));
613+
assert!((20f32 == NumCast::from(20u16)));
614+
assert!((20f32 == NumCast::from(20u32)));
615+
assert!((20f32 == NumCast::from(20u64)));
616+
assert!((20f32 == NumCast::from(20i)));
617+
assert!((20f32 == NumCast::from(20i8)));
618+
assert!((20f32 == NumCast::from(20i16)));
619+
assert!((20f32 == NumCast::from(20i32)));
620+
assert!((20f32 == NumCast::from(20i64)));
621+
assert!((20f32 == NumCast::from(20f)));
622+
assert!((20f32 == NumCast::from(20f32)));
623+
assert!((20f32 == NumCast::from(20f64)));
624+
625+
assert!((20f32 == num::cast(20u)));
626+
assert!((20f32 == num::cast(20u8)));
627+
assert!((20f32 == num::cast(20u16)));
628+
assert!((20f32 == num::cast(20u32)));
629+
assert!((20f32 == num::cast(20u64)));
630+
assert!((20f32 == num::cast(20i)));
631+
assert!((20f32 == num::cast(20i8)));
632+
assert!((20f32 == num::cast(20i16)));
633+
assert!((20f32 == num::cast(20i32)));
634+
assert!((20f32 == num::cast(20i64)));
635+
assert!((20f32 == num::cast(20f)));
636+
assert!((20f32 == num::cast(20f32)));
637+
assert!((20f32 == num::cast(20f64)));
638+
}
639+
558640
//
559641
// Local Variables:
560642
// mode: rust

0 commit comments

Comments
 (0)