Skip to content

Commit 7d0eb93

Browse files
committed
---
yaml --- r: 140479 b: refs/heads/try2 c: 0211833 h: refs/heads/master i: 140477: b663e23 140475: d0e75f3 140471: ffecfce 140463: 8c22b1d 140447: 0deda54 140415: a96adde v: v3
1 parent c0c3b8a commit 7d0eb93

File tree

248 files changed

+5269
-14503
lines changed

Some content is hidden

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

248 files changed

+5269
-14503
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: 0ef4e860da1fb755b9fff5d1b30bee3974514ea2
8+
refs/heads/try2: 02118330084539fdc87533d46aabeef2257ee835
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/Makefile.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ endif
110110
ifdef SAVE_TEMPS
111111
CFG_RUSTC_FLAGS += --save-temps
112112
endif
113-
ifdef ASM_COMMENTS
114-
CFG_RUSTC_FLAGS += -z asm-comments
115-
endif
116113
ifdef TIME_PASSES
117114
CFG_RUSTC_FLAGS += -Z time-passes
118115
endif

branches/try2/src/libcore/cell.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn empty_cell<T>() -> Cell<T> {
4242
pub impl<T> Cell<T> {
4343
/// Yields the value, failing if the cell is empty.
4444
fn take(&self) -> T {
45-
let self = unsafe { transmute_mut(self) };
45+
let mut self = unsafe { transmute_mut(self) };
4646
if self.is_empty() {
4747
fail!(~"attempt to take an empty cell");
4848
}
@@ -54,7 +54,7 @@ pub impl<T> Cell<T> {
5454
5555
/// Returns the value, failing if the cell is full.
5656
fn put_back(&self, value: T) {
57-
let self = unsafe { transmute_mut(self) };
57+
let mut self = unsafe { transmute_mut(self) };
5858
if !self.is_empty() {
5959
fail!(~"attempt to put a value back into a full cell");
6060
}

branches/try2/src/libcore/cleanup.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use ptr::mut_null;
1515
use repr::BoxRepr;
1616
use sys::TypeDesc;
1717
use cast::transmute;
18-
#[cfg(notest)] use unstable::lang::clear_task_borrow_list;
1918

2019
#[cfg(notest)] use ptr::to_unsafe_ptr;
2120

@@ -167,8 +166,7 @@ fn debug_mem() -> bool {
167166
#[cfg(notest)]
168167
#[lang="annihilate"]
169168
pub unsafe fn annihilate() {
170-
use unstable::lang::{local_free};
171-
use unstable::lang;
169+
use unstable::lang::local_free;
172170
use io::WriterUtil;
173171
use io;
174172
use libc;
@@ -181,21 +179,15 @@ pub unsafe fn annihilate() {
181179
n_bytes_freed: 0
182180
};
183181

184-
// Quick hack: we need to free this list upon task exit, and this
185-
// is a convenient place to do it.
186-
clear_task_borrow_list();
187-
188182
// Pass 1: Make all boxes immortal.
189183
//
190184
// In this pass, nothing gets freed, so it does not matter whether
191185
// we read the next field before or after the callback.
192186
for each_live_alloc(true) |box, uniq| {
193187
stats.n_total_boxes += 1;
194188
if uniq {
195-
lang::debug_mem("Managed-uniq: ", &*box);
196189
stats.n_unique_boxes += 1;
197190
} else {
198-
lang::debug_mem("Immortalizing: ", &*box);
199191
(*box).header.ref_count = managed::raw::RC_IMMORTAL;
200192
}
201193
}
@@ -207,13 +199,9 @@ pub unsafe fn annihilate() {
207199
// callback, as the original value may have been freed.
208200
for each_live_alloc(false) |box, uniq| {
209201
if !uniq {
210-
lang::debug_mem("Invoking tydesc/glue on: ", &*box);
211202
let tydesc: *TypeDesc = transmute(copy (*box).header.type_desc);
212203
let drop_glue: DropGlue = transmute(((*tydesc).drop_glue, 0));
213-
lang::debug_mem("Box data: ", &(*box).data);
214-
lang::debug_mem("Type descriptor: ", tydesc);
215204
drop_glue(to_unsafe_ptr(&tydesc), transmute(&(*box).data));
216-
lang::debug_mem("Dropped ", &*box);
217205
}
218206
}
219207

@@ -225,7 +213,6 @@ pub unsafe fn annihilate() {
225213
// not be valid after.
226214
for each_live_alloc(true) |box, uniq| {
227215
if !uniq {
228-
lang::debug_mem("About to free: ", &*box);
229216
stats.n_bytes_freed +=
230217
(*((*box).header.type_desc)).size
231218
+ sys::size_of::<BoxRepr>();

branches/try2/src/libcore/cmp.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ totaleq_impl!(uint)
6666

6767
totaleq_impl!(char)
6868

69+
/// Trait for testing approximate equality
70+
pub trait ApproxEq<Eps> {
71+
fn approx_epsilon() -> Eps;
72+
fn approx_eq(&self, other: &Self) -> bool;
73+
fn approx_eq_eps(&self, other: &Self, approx_epsilon: &Eps) -> bool;
74+
}
75+
6976
#[deriving(Clone, Eq)]
7077
pub enum Ordering { Less = -1, Equal = 0, Greater = 1 }
7178

branches/try2/src/libcore/comm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ impl<T: Owned> Selectable for Port<T> {
205205
fn header(&self) -> *PacketHeader {
206206
unsafe {
207207
match self.endp {
208-
Some(ref endp) => endp.header(),
209-
None => fail!(~"peeking empty stream")
208+
Some(ref endp) => endp.header(),
209+
None => fail!(~"peeking empty stream")
210210
}
211211
}
212212
}

branches/try2/src/libcore/flate.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ pub mod rustrt {
2828
pub extern {
2929
unsafe fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void,
3030
src_buf_len: size_t,
31-
pout_len: *mut size_t,
31+
pout_len: *size_t,
3232
flags: c_int)
3333
-> *c_void;
3434

3535
unsafe fn tinfl_decompress_mem_to_heap(psrc_buf: *const c_void,
3636
src_buf_len: size_t,
37-
pout_len: *mut size_t,
37+
pout_len: *size_t,
3838
flags: c_int)
3939
-> *c_void;
4040
}
@@ -52,11 +52,11 @@ pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
5252
let res =
5353
rustrt::tdefl_compress_mem_to_heap(b as *c_void,
5454
len as size_t,
55-
&mut outsz,
55+
&outsz,
5656
lz_norm);
5757
assert!(res as int != 0);
5858
let out = vec::raw::from_buf_raw(res as *u8,
59-
outsz as uint);
59+
outsz as uint);
6060
libc::free(res);
6161
out
6262
}
@@ -66,11 +66,11 @@ pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
6666
pub fn inflate_bytes(bytes: &const [u8]) -> ~[u8] {
6767
do vec::as_const_buf(bytes) |b, len| {
6868
unsafe {
69-
let mut outsz : size_t = 0;
69+
let outsz : size_t = 0;
7070
let res =
7171
rustrt::tinfl_decompress_mem_to_heap(b as *c_void,
7272
len as size_t,
73-
&mut outsz,
73+
&outsz,
7474
0);
7575
assert!(res as int != 0);
7676
let out = vec::raw::from_buf_raw(res as *u8,

branches/try2/src/libcore/hashmap.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use rand;
2525
use uint;
2626
use vec;
2727
use util::unreachable;
28-
use kinds::Copy;
2928

3029
static INITIAL_CAPACITY: uint = 32u; // 2^5
3130

@@ -530,18 +529,6 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> {
530529
}
531530
}
532531

533-
pub impl<K: Hash + Eq, V: Copy> HashMap<K, V> {
534-
/// Like `find`, but returns a copy of the value.
535-
fn find_copy(&self, k: &K) -> Option<V> {
536-
self.find(k).map_consume(|v| copy *v)
537-
}
538-
539-
/// Like `get`, but returns a copy of the value.
540-
fn get_copy(&self, k: &K) -> V {
541-
copy *self.get(k)
542-
}
543-
}
544-
545532
impl<K:Hash + Eq,V:Eq> Eq for HashMap<K, V> {
546533
fn eq(&self, other: &HashMap<K, V>) -> bool {
547534
if self.len() != other.len() { return false; }

branches/try2/src/libcore/io.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ pub enum WriterType { Screen, File }
10221022
pub trait Writer {
10231023
10241024
/// Write all of the given bytes.
1025-
fn write(&self, v: &[u8]);
1025+
fn write(&self, v: &const [u8]);
10261026
10271027
/// Move the current position within the stream. The second parameter
10281028
/// determines the position that the first parameter is relative to.
@@ -1039,23 +1039,23 @@ pub trait Writer {
10391039
}
10401040
10411041
impl Writer for @Writer {
1042-
fn write(&self, v: &[u8]) { self.write(v) }
1042+
fn write(&self, v: &const [u8]) { self.write(v) }
10431043
fn seek(&self, a: int, b: SeekStyle) { self.seek(a, b) }
10441044
fn tell(&self) -> uint { self.tell() }
10451045
fn flush(&self) -> int { self.flush() }
10461046
fn get_type(&self) -> WriterType { self.get_type() }
10471047
}
10481048
10491049
impl<W:Writer,C> Writer for Wrapper<W, C> {
1050-
fn write(&self, bs: &[u8]) { self.base.write(bs); }
1050+
fn write(&self, bs: &const [u8]) { self.base.write(bs); }
10511051
fn seek(&self, off: int, style: SeekStyle) { self.base.seek(off, style); }
10521052
fn tell(&self) -> uint { self.base.tell() }
10531053
fn flush(&self) -> int { self.base.flush() }
10541054
fn get_type(&self) -> WriterType { File }
10551055
}
10561056
10571057
impl Writer for *libc::FILE {
1058-
fn write(&self, v: &[u8]) {
1058+
fn write(&self, v: &const [u8]) {
10591059
unsafe {
10601060
do vec::as_const_buf(v) |vbuf, len| {
10611061
let nout = libc::fwrite(vbuf as *c_void,
@@ -1105,7 +1105,7 @@ pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> @Writer {
11051105
}
11061106

11071107
impl Writer for fd_t {
1108-
fn write(&self, v: &[u8]) {
1108+
fn write(&self, v: &const [u8]) {
11091109
unsafe {
11101110
let mut count = 0u;
11111111
do vec::as_const_buf(v) |vbuf, len| {
@@ -1262,7 +1262,7 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint,
12621262
}
12631263
}
12641264

1265-
pub fn u64_from_be_bytes(data: &[u8],
1265+
pub fn u64_from_be_bytes(data: &const [u8],
12661266
start: uint,
12671267
size: uint)
12681268
-> u64 {
@@ -1497,7 +1497,7 @@ pub struct BytesWriter {
14971497
}
14981498
14991499
impl Writer for BytesWriter {
1500-
fn write(&self, v: &[u8]) {
1500+
fn write(&self, v: &const [u8]) {
15011501
let v_len = v.len();
15021502
let bytes_len = vec::uniq_len(&const self.bytes);
15031503

branches/try2/src/libcore/libc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ pub mod types {
268268
pub type ssize_t = i32;
269269
}
270270
pub mod posix01 {
271-
use libc::types::os::arch::c95::{c_short, c_long, time_t};
271+
use libc::types::os::arch::c95::{c_int, c_short, c_long,
272+
time_t};
272273
use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t};
273274
use libc::types::os::arch::posix88::{mode_t, off_t};
274275
use libc::types::os::arch::posix88::{uid_t};

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,22 @@ impl Eq for f32 {
210210
fn ne(&self, other: &f32) -> bool { (*self) != (*other) }
211211
}
212212

213+
#[cfg(notest)]
214+
impl ApproxEq<f32> for f32 {
215+
#[inline(always)]
216+
fn approx_epsilon() -> f32 { 1.0e-6 }
217+
218+
#[inline(always)]
219+
fn approx_eq(&self, other: &f32) -> bool {
220+
self.approx_eq_eps(other, &ApproxEq::approx_epsilon::<f32, f32>())
221+
}
222+
223+
#[inline(always)]
224+
fn approx_eq_eps(&self, other: &f32, approx_epsilon: &f32) -> bool {
225+
(*self - *other).abs() < *approx_epsilon
226+
}
227+
}
228+
213229
#[cfg(notest)]
214230
impl Ord for f32 {
215231
#[inline(always)]
@@ -974,6 +990,15 @@ mod tests {
974990
assert!(!NaN.is_negative());
975991
}
976992

993+
#[test]
994+
fn test_approx_eq() {
995+
assert!(1.0f32.approx_eq(&1f32));
996+
assert!(0.9999999f32.approx_eq(&1f32));
997+
assert!(1.000001f32.approx_eq_eps(&1f32, &1.0e-5));
998+
assert!(1.0000001f32.approx_eq_eps(&1f32, &1.0e-6));
999+
assert!(!1.0000001f32.approx_eq_eps(&1f32, &1.0e-7));
1000+
}
1001+
9771002
#[test]
9781003
fn test_primitive() {
9791004
assert_eq!(Primitive::bits::<f32>(), sys::size_of::<f32>() * 8);

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,22 @@ impl Eq for f64 {
233233
fn ne(&self, other: &f64) -> bool { (*self) != (*other) }
234234
}
235235

236+
#[cfg(notest)]
237+
impl ApproxEq<f64> for f64 {
238+
#[inline(always)]
239+
fn approx_epsilon() -> f64 { 1.0e-6 }
240+
241+
#[inline(always)]
242+
fn approx_eq(&self, other: &f64) -> bool {
243+
self.approx_eq_eps(other, &ApproxEq::approx_epsilon::<f64, f64>())
244+
}
245+
246+
#[inline(always)]
247+
fn approx_eq_eps(&self, other: &f64, approx_epsilon: &f64) -> bool {
248+
(*self - *other).abs() < *approx_epsilon
249+
}
250+
}
251+
236252
#[cfg(notest)]
237253
impl Ord for f64 {
238254
#[inline(always)]
@@ -1022,6 +1038,15 @@ mod tests {
10221038
assert!(!NaN.is_negative());
10231039
}
10241040

1041+
#[test]
1042+
fn test_approx_eq() {
1043+
assert!(1.0f64.approx_eq(&1f64));
1044+
assert!(0.9999999f64.approx_eq(&1f64));
1045+
assert!(1.000001f64.approx_eq_eps(&1f64, &1.0e-5));
1046+
assert!(1.0000001f64.approx_eq_eps(&1f64, &1.0e-6));
1047+
assert!(!1.0000001f64.approx_eq_eps(&1f64, &1.0e-7));
1048+
}
1049+
10251050
#[test]
10261051
fn test_primitive() {
10271052
assert_eq!(Primitive::bits::<f64>(), sys::size_of::<f64>() * 8);

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,22 @@ impl Eq for float {
371371
fn ne(&self, other: &float) -> bool { (*self) != (*other) }
372372
}
373373
374+
#[cfg(notest)]
375+
impl ApproxEq<float> for float {
376+
#[inline(always)]
377+
fn approx_epsilon() -> float { 1.0e-6 }
378+
379+
#[inline(always)]
380+
fn approx_eq(&self, other: &float) -> bool {
381+
self.approx_eq_eps(other, &ApproxEq::approx_epsilon::<float, float>())
382+
}
383+
384+
#[inline(always)]
385+
fn approx_eq_eps(&self, other: &float, approx_epsilon: &float) -> bool {
386+
(*self - *other).abs() < *approx_epsilon
387+
}
388+
}
389+
374390
#[cfg(notest)]
375391
impl Ord for float {
376392
#[inline(always)]
@@ -985,6 +1001,15 @@ mod tests {
9851001
assert!(!NaN.is_negative());
9861002
}
9871003
1004+
#[test]
1005+
fn test_approx_eq() {
1006+
assert!(1.0f.approx_eq(&1f));
1007+
assert!(0.9999999f.approx_eq(&1f));
1008+
assert!(1.000001f.approx_eq_eps(&1f, &1.0e-5));
1009+
assert!(1.0000001f.approx_eq_eps(&1f, &1.0e-6));
1010+
assert!(!1.0000001f.approx_eq_eps(&1f, &1.0e-7));
1011+
}
1012+
9881013
#[test]
9891014
fn test_primitive() {
9901015
assert_eq!(Primitive::bits::<float>(), sys::size_of::<float>() * 8);

0 commit comments

Comments
 (0)