Skip to content

Commit 8841bd5

Browse files
committed
---
yaml --- r: 85487 b: refs/heads/dist-snap c: 0dceabd h: refs/heads/master i: 85485: 903fc3f 85483: 394b05d 85479: a5c6999 85471: a6e5cd6 v: v3
1 parent 95b2cbb commit 8841bd5

File tree

495 files changed

+2641
-988
lines changed

Some content is hidden

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

495 files changed

+2641
-988
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 0983ebe5310d4eb6d289f636f7ed0536c08bbc0e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 6440343a6c26fca12ef2e323fa7738dce9da1986
9+
refs/heads/dist-snap: 0dceabda7f1049fd70d38cf61c80dd5148fdca4e
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/doc/rust.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ a referencing source file, or by the name of the crate itself.
582582

583583
Each source file contains a sequence of zero or more `item` definitions,
584584
and may optionally begin with any number of `attributes` that apply to the containing module.
585-
Attributes on the anonymous crate module define important metadata that influences
585+
Atributes on the anonymous crate module define important metadata that influences
586586
the behavior of the compiler.
587587

588588
~~~~~~~~
@@ -1273,7 +1273,7 @@ since the typechecker checks that any type with an implementation of `Circle` al
12731273

12741274
In type-parameterized functions,
12751275
methods of the supertrait may be called on values of subtrait-bound type parameters.
1276-
Referring to the previous example of `trait Circle : Shape`:
1276+
Refering to the previous example of `trait Circle : Shape`:
12771277

12781278
~~~
12791279
# trait Shape { fn area(&self) -> float; }
@@ -1914,7 +1914,7 @@ A field access on a record is an [lvalue](#lvalues-rvalues-and-temporaries) refe
19141914
When the field is mutable, it can be [assigned](#assignment-expressions) to.
19151915

19161916
When the type of the expression to the left of the dot is a pointer to a record or structure,
1917-
it is automatically dereferenced to make the field access possible.
1917+
it is automatically derferenced to make the field access possible.
19181918

19191919

19201920
### Vector expressions

branches/dist-snap/mk/rt.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ rt/$(1)/stage$(2)/arch/$$(HOST_$(1))/libmorestack.a: $$(MORESTACK_OBJ_$(1)_$(2))
149149
$$(Q)$(AR_$(1)) rcs $$@ $$<
150150

151151
rt/$(1)/stage$(2)/$(CFG_RUNTIME_$(1)): $$(RUNTIME_OBJS_$(1)_$(2)) $$(MKFILE_DEPS) \
152-
$$(RUNTIME_DEF_$(1)_$(2)) $$(LIBUV_LIB_$(1)_$(2))
152+
$$(RUNTIME_DEF_$(1)_$(2)) $$(LIBUV_LIB_$(1)_$(2)) $$(JEMALLOC_LIB_$(1)_$(2))
153153
@$$(call E, link: $$@)
154154
$$(Q)$$(call CFG_LINK_CXX_$(1),$$@, $$(RUNTIME_OBJS_$(1)_$(2)) \
155-
$$(CFG_GCCISH_POST_LIB_FLAGS_$(1)) $$(LIBUV_LIB_$(1)_$(2)) \
155+
$$(JEMALLOC_LIB_$(1)_$(2)) $$(CFG_GCCISH_POST_LIB_FLAGS_$(1)) $$(LIBUV_LIB_$(1)_$(2)) \
156156
$$(CFG_LIBUV_LINK_FLAGS_$(1)),$$(RUNTIME_DEF_$(1)_$(2)),$$(CFG_RUNTIME_$(1)))
157157

158158
# FIXME: For some reason libuv's makefiles can't figure out the

branches/dist-snap/mk/target.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)): \
6969
| $$(TLIB$(1)_T_$(2)_H_$(3))/
7070
@$$(call E, compile_and_link: $$@)
7171
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_GLOB_$(2)),$$(notdir $$@))
72-
$$(STAGE$(1)_T_$(2)_H_$(3)) $(BORROWCK) --out-dir $$(@D) $$< && touch $$@
72+
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) $(BORROWCK) --out-dir $$(@D) $$< && touch $$@
7373
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_GLOB_$(2)),$$(notdir $$@))
7474

7575
# Only build the compiler for host triples
@@ -90,7 +90,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): \
9090
| $$(TLIB$(1)_T_$(2)_H_$(3))/
9191
@$$(call E, compile_and_link: $$@)
9292
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@))
93-
$$(STAGE$(1)_T_$(2)_H_$(3)) --out-dir $$(@D) $$< && touch $$@
93+
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
9494
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@))
9595

9696
$$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X_$(3)): \

branches/dist-snap/mk/tools.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTDOC_$(4)): \
6767
| $$(TLIB$(1)_T_$(4)_H_$(3))/
6868
@$$(call E, compile_and_link: $$@)
6969
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTDOC_GLOB_$(4)),$$(notdir $$@))
70-
$$(STAGE$(1)_T_$(4)_H_$(3)) --out-dir $$(@D) $$< && touch $$@
70+
$$(STAGE$(1)_T_$(4)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
7171
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTDOC_GLOB_$(4)),$$(notdir $$@))
7272

7373
$$(TBIN$(1)_T_$(4)_H_$(3))/rustdoc$$(X_$(4)): \
@@ -85,7 +85,7 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTI_$(4)): \
8585
| $$(TLIB$(1)_T_$(4)_H_$(3))/
8686
@$$(call E, compile_and_link: $$@)
8787
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTI_GLOB_$(4)),$$(notdir $$@))
88-
$$(STAGE$(1)_T_$(4)_H_$(3)) --out-dir $$(@D) $$< && touch $$@
88+
$$(STAGE$(1)_T_$(4)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
8989
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTI_GLOB_$(4)),$$(notdir $$@))
9090

9191
$$(TBIN$(1)_T_$(4)_H_$(3))/rusti$$(X_$(4)): \
@@ -106,7 +106,7 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUST_$(4)): \
106106
| $$(TLIB$(1)_T_$(4)_H_$(3))/
107107
@$$(call E, compile_and_link: $$@)
108108
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUST_GLOB_$(4)),$$(notdir $$@))
109-
$$(STAGE$(1)_T_$(4)_H_$(3)) --out-dir $$(@D) $$< && touch $$@
109+
$$(STAGE$(1)_T_$(4)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
110110
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUST_GLOB_$(4)),$$(notdir $$@))
111111

112112
$$(TBIN$(1)_T_$(4)_H_$(3))/rust$$(X_$(4)): \

branches/dist-snap/src/compiletest/procsrv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn run(lib_path: &str,
4949

5050
let env = env + target_env(lib_path, prog);
5151
let mut proc = run::Process::new(prog, args, run::ProcessOptions {
52-
env: Some(env.slice(0, env.len())),
52+
env: Some(env),
5353
dir: None,
5454
in_fd: None,
5555
out_fd: None,

branches/dist-snap/src/compiletest/runtest.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,30 @@ use procsrv;
2020
use util;
2121
use util::logv;
2222

23+
use std::cell::Cell;
2324
use std::io;
2425
use std::os;
2526
use std::str;
27+
use std::task::{spawn_sched, SingleThreaded};
2628
use std::vec;
2729

2830
use extra::test::MetricMap;
2931

3032
pub fn run(config: config, testfile: ~str) {
31-
let mut _mm = MetricMap::new();
32-
run_metrics(config, testfile, &mut _mm);
33+
let config = Cell::new(config);
34+
let testfile = Cell::new(testfile);
35+
// FIXME #6436: Creating another thread to run the test because this
36+
// is going to call waitpid. The new scheduler has some strange
37+
// interaction between the blocking tasks and 'friend' schedulers
38+
// that destroys parallelism if we let normal schedulers block.
39+
// It should be possible to remove this spawn once std::run is
40+
// rewritten to be non-blocking.
41+
do spawn_sched(SingleThreaded) {
42+
let config = config.take();
43+
let testfile = testfile.take();
44+
let mut _mm = MetricMap::new();
45+
run_metrics(config, testfile, &mut _mm);
46+
}
3347
}
3448

3549
pub fn run_metrics(config: config, testfile: ~str, mm: &mut MetricMap) {

branches/dist-snap/src/etc/cmathconsts.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <math.h>
1414
#include <stdio.h>
1515

16-
// must match std::ctypes
16+
// must match core::ctypes
1717

1818
#define C_FLT(x) (float)x
1919
#define C_DBL(x) (double)x

branches/dist-snap/src/etc/ziggurat_tables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# xfail-license
33

44
# This creates the tables used for distributions implemented using the
5-
# ziggurat algorithm in `std::rand::distributions;`. They are
5+
# ziggurat algorithm in `core::rand::distributions;`. They are
66
# (basically) the tables as used in the ZIGNOR variant (Doornik 2005).
77
# They are changed rarely, so the generated file should be checked in
88
# to git.

branches/dist-snap/src/etc/zsh/_rust

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _rustc_opts_lint=(
3636
'path-statement[path statements with no effect]'
3737
'missing-trait-doc[detects missing documentation for traits]'
3838
'missing-struct-doc[detects missing documentation for structs]'
39-
'ctypes[proper use of std::libc types in foreign modules]'
39+
'ctypes[proper use of core::libc types in foreign modules]'
4040
"unused-mut[detect mut variables which don't need to be mutable]"
4141
'unused-imports[imports that are never used]'
4242
'heap-memory[use of any (~ type or @ type) heap memory]'

branches/dist-snap/src/libextra/crypto/cryptoutil.rs

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

11-
use std::num::One;
11+
use std::num::{One, Zero, CheckedAdd};
1212
use std::vec::bytes::{MutableByteVector, copy_memory};
1313

1414

@@ -36,6 +36,18 @@ pub fn write_u32_be(dst: &mut[u8], input: u32) {
3636
}
3737
}
3838

39+
/// Write a u32 into a vector, which must be 4 bytes long. The value is written in little-endian
40+
/// format.
41+
pub fn write_u32_le(dst: &mut[u8], input: u32) {
42+
use std::cast::transmute;
43+
use std::unstable::intrinsics::to_le32;
44+
assert!(dst.len() == 4);
45+
unsafe {
46+
let x: *mut i32 = transmute(dst.unsafe_mut_ref(0));
47+
*x = to_le32(input as i32);
48+
}
49+
}
50+
3951
/// Read a vector of bytes into a vector of u64s. The values are read in big-endian format.
4052
pub fn read_u64v_be(dst: &mut[u64], input: &[u8]) {
4153
use std::cast::transmute;
@@ -68,51 +80,90 @@ pub fn read_u32v_be(dst: &mut[u32], input: &[u8]) {
6880
}
6981
}
7082

83+
/// Read a vector of bytes into a vector of u32s. The values are read in little-endian format.
84+
pub fn read_u32v_le(dst: &mut[u32], input: &[u8]) {
85+
use std::cast::transmute;
86+
use std::unstable::intrinsics::to_le32;
87+
assert!(dst.len() * 4 == input.len());
88+
unsafe {
89+
let mut x: *mut i32 = transmute(dst.unsafe_mut_ref(0));
90+
let mut y: *i32 = transmute(input.unsafe_ref(0));
91+
do dst.len().times() {
92+
*x = to_le32(*y);
93+
x = x.offset(1);
94+
y = y.offset(1);
95+
}
96+
}
97+
}
98+
7199

72-
/// Returns true if adding the two parameters will result in integer overflow
73-
pub fn will_add_overflow<T: Int + Unsigned>(x: T, y: T) -> bool {
74-
// This doesn't handle negative values! Don't copy this code elsewhere without considering if
75-
// negative values are important to you!
76-
let max: T = Bounded::max_value();
77-
return x > max - y;
100+
trait ToBits {
101+
/// Convert the value in bytes to the number of bits, a tuple where the 1st item is the
102+
/// high-order value and the 2nd item is the low order value.
103+
fn to_bits(self) -> (Self, Self);
78104
}
79105

80-
/// Shifts the second parameter and then adds it to the first. fails!() if there would be unsigned
81-
/// integer overflow.
82-
pub fn shift_add_check_overflow<T: Int + Unsigned + Clone>(x: T, mut y: T, shift: T) -> T {
83-
if y.leading_zeros() < shift {
84-
fail!("Could not add values - integer overflow.");
106+
impl ToBits for u64 {
107+
fn to_bits(self) -> (u64, u64) {
108+
return (self >> 61, self << 3);
85109
}
86-
y = y << shift;
110+
}
87111

88-
if will_add_overflow(x.clone(), y.clone()) {
89-
fail!("Could not add values - integer overflow.");
90-
}
112+
/// Adds the specified number of bytes to the bit count. fail!() if this would cause numeric
113+
/// overflow.
114+
pub fn add_bytes_to_bits<T: Int + CheckedAdd + ToBits>(bits: T, bytes: T) -> T {
115+
let (new_high_bits, new_low_bits) = bytes.to_bits();
91116

92-
return x + y;
93-
}
117+
if new_high_bits > Zero::zero() {
118+
fail!("Numeric overflow occured.")
119+
}
94120

95-
/// Shifts the second parameter and then adds it to the first, which is a tuple where the first
96-
/// element is the high order value. fails!() if there would be unsigned integer overflow.
97-
pub fn shift_add_check_overflow_tuple
98-
<T: Int + Unsigned + Clone>
99-
(x: (T, T), mut y: T, shift: T) -> (T, T) {
100-
if y.leading_zeros() < shift {
101-
fail!("Could not add values - integer overflow.");
121+
match bits.checked_add(&new_low_bits) {
122+
Some(x) => return x,
123+
None => fail!("Numeric overflow occured.")
102124
}
103-
y = y << shift;
125+
}
104126

105-
match x {
106-
(hi, low) => {
107-
let one: T = One::one();
108-
if will_add_overflow(low.clone(), y.clone()) {
109-
if will_add_overflow(hi.clone(), one.clone()) {
110-
fail!("Could not add values - integer overflow.");
111-
} else {
112-
return (hi + one, low + y);
113-
}
127+
/// Adds the specified number of bytes to the bit count, which is a tuple where the first element is
128+
/// the high order value. fail!() if this would cause numeric overflow.
129+
pub fn add_bytes_to_bits_tuple
130+
<T: Int + Unsigned + CheckedAdd + ToBits>
131+
(bits: (T, T), bytes: T) -> (T, T) {
132+
let (new_high_bits, new_low_bits) = bytes.to_bits();
133+
let (hi, low) = bits;
134+
135+
// Add the low order value - if there is no overflow, then add the high order values
136+
// If the addition of the low order values causes overflow, add one to the high order values
137+
// before adding them.
138+
match low.checked_add(&new_low_bits) {
139+
Some(x) => {
140+
if new_high_bits == Zero::zero() {
141+
// This is the fast path - every other alternative will rarely occur in practice
142+
// considering how large an input would need to be for those paths to be used.
143+
return (hi, x);
114144
} else {
115-
return (hi, low + y);
145+
match hi.checked_add(&new_high_bits) {
146+
Some(y) => return (y, x),
147+
None => fail!("Numeric overflow occured.")
148+
}
149+
}
150+
},
151+
None => {
152+
let one: T = One::one();
153+
let z = match new_high_bits.checked_add(&one) {
154+
Some(w) => w,
155+
None => fail!("Numeric overflow occured.")
156+
};
157+
match hi.checked_add(&z) {
158+
// This re-executes the addition that was already performed earlier when overflow
159+
// occured, this time allowing the overflow to happen. Technically, this could be
160+
// avoided by using the checked add intrinsic directly, but that involves using
161+
// unsafe code and is not really worthwhile considering how infrequently code will
162+
// run in practice. This is the reason that this function requires that the type T
163+
// be Unsigned - overflow is not defined for Signed types. This function could be
164+
// implemented for signed types as well if that were needed.
165+
Some(y) => return (y, low + new_low_bits),
166+
None => fail!("Numeric overflow occured.")
116167
}
117168
}
118169
}
@@ -125,7 +176,7 @@ pub fn shift_add_check_overflow_tuple
125176
/// method that modifies the buffer directory or provides the caller with bytes that can be modifies
126177
/// results in those bytes being marked as used by the buffer.
127178
pub trait FixedBuffer {
128-
/// Input a vector of bytes. If the buffer becomes full, process it with the provided
179+
/// Input a vector of bytes. If the buffer becomes full, proccess it with the provided
129180
/// function and then clear the buffer.
130181
fn input(&mut self, input: &[u8], func: &fn(&[u8]));
131182

@@ -300,6 +351,7 @@ mod test {
300351
use std::rand::RngUtil;
301352
use std::vec;
302353

354+
use cryptoutil::{add_bytes_to_bits, add_bytes_to_bits_tuple};
303355
use digest::Digest;
304356

305357
/// Feed 1,000,000 'a's into the digest with varying input sizes and check that the result is
@@ -324,4 +376,50 @@ mod test {
324376

325377
assert!(expected == result_str);
326378
}
379+
380+
// A normal addition - no overflow occurs
381+
#[test]
382+
fn test_add_bytes_to_bits_ok() {
383+
assert!(add_bytes_to_bits::<u64>(100, 10) == 180);
384+
}
385+
386+
// A simple failure case - adding 1 to the max value
387+
#[test]
388+
#[should_fail]
389+
fn test_add_bytes_to_bits_overflow() {
390+
add_bytes_to_bits::<u64>(Bounded::max_value(), 1);
391+
}
392+
393+
// A normal addition - no overflow occurs (fast path)
394+
#[test]
395+
fn test_add_bytes_to_bits_tuple_ok() {
396+
assert!(add_bytes_to_bits_tuple::<u64>((5, 100), 10) == (5, 180));
397+
}
398+
399+
// The low order value overflows into the high order value
400+
#[test]
401+
fn test_add_bytes_to_bits_tuple_ok2() {
402+
assert!(add_bytes_to_bits_tuple::<u64>((5, Bounded::max_value()), 1) == (6, 7));
403+
}
404+
405+
// The value to add is too large to be converted into bits without overflowing its type
406+
#[test]
407+
fn test_add_bytes_to_bits_tuple_ok3() {
408+
assert!(add_bytes_to_bits_tuple::<u64>((5, 0), 0x4000000000000001) == (7, 8));
409+
}
410+
411+
// A simple failure case - adding 1 to the max value
412+
#[test]
413+
#[should_fail]
414+
fn test_add_bytes_to_bits_tuple_overflow() {
415+
add_bytes_to_bits_tuple::<u64>((Bounded::max_value(), Bounded::max_value()), 1);
416+
}
417+
418+
// The value to add is too large to convert to bytes without overflowing its type, but the high
419+
// order value from this conversion overflows when added to the existing high order value
420+
#[test]
421+
#[should_fail]
422+
fn test_add_bytes_to_bits_tuple_overflow2() {
423+
add_bytes_to_bits_tuple::<u64>((Bounded::max_value::<u64>() - 1, 0), 0x8000000000000000);
424+
}
327425
}

0 commit comments

Comments
 (0)