Skip to content

Commit 1ff7942

Browse files
committed
---
yaml --- r: 98129 b: refs/heads/master c: 1dd6906 h: refs/heads/master i: 98127: b22ebb6 v: v3
1 parent 6cce34e commit 1ff7942

File tree

33 files changed

+332
-72
lines changed

33 files changed

+332
-72
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: bf2ab22cd0eda8e019cb243916e6c127708739cf
2+
refs/heads/master: 1dd6906db2e6749bc3f113068e7493070b276feb
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b6400f998497c3958f40997a71756ead344a776d
55
refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36

trunk/src/etc/vim/syntax/rust.vim

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ syn keyword rustTrait OrdIterator MutableDoubleEndedIterator ExactSize
8383
syn keyword rustTrait Times
8484

8585
syn keyword rustTrait Algebraic Trigonometric Exponential Hyperbolic
86-
syn keyword rustTrait Bitwise BitCount Bounded
87-
syn keyword rustTrait Integer Fractional Real RealExt
86+
syn keyword rustTrait Bitwise Bounded Integer Fractional Real RealExt
8887
syn keyword rustTrait Num NumCast CheckedAdd CheckedSub CheckedMul
8988
syn keyword rustTrait Orderable Signed Unsigned Round
9089
syn keyword rustTrait Primitive Int Float ToStrRadix ToPrimitive FromPrimitive

trunk/src/libextra/enum_set.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
//! This module defines a container which uses an efficient bit mask
1414
//! representation to hold C-like enum variants.
1515
16+
use std::num::Bitwise;
17+
1618
#[deriving(Clone, Eq, IterBytes, ToStr, Encodable, Decodable)]
1719
/// A specialized Set implementation to use enum types.
1820
pub struct EnumSet<E> {

trunk/src/libextra/num/bigint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ A `BigInt` is a combination of `BigUint` and `Sign`.
2222
use std::cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
2323
use std::num;
2424
use std::num::{Zero, One, ToStrRadix, FromStrRadix, Orderable};
25-
use std::num::{ToPrimitive, FromPrimitive};
25+
use std::num::{Bitwise, ToPrimitive, FromPrimitive};
2626
use std::rand::Rng;
2727
use std::str;
2828
use std::uint;

trunk/src/libnative/lib.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,30 @@ static OS_DEFAULT_STACK_ESTIMATE: uint = 1 << 20;
3939
#[cfg(unix, not(android))]
4040
static OS_DEFAULT_STACK_ESTIMATE: uint = 2 * (1 << 20);
4141

42+
43+
// XXX: this should not exist here
44+
#[cfg(stage0, nativestart)]
45+
#[lang = "start"]
46+
pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int {
47+
use std::cast;
48+
use std::task;
49+
50+
do start(argc, argv) {
51+
// Instead of invoking main directly on this thread, invoke it on
52+
// another spawned thread that we are guaranteed to know the size of the
53+
// stack of. Currently, we do not have a method of figuring out the size
54+
// of the main thread's stack, so for stack overflow detection to work
55+
// we must spawn the task in a subtask which we know the stack size of.
56+
let main: extern "Rust" fn() = unsafe { cast::transmute(main) };
57+
let mut task = task::task();
58+
task.name("<main>");
59+
match do task.try { main() } {
60+
Ok(()) => { os::set_exit_status(0); }
61+
Err(..) => { os::set_exit_status(rt::DEFAULT_ERROR_CODE); }
62+
}
63+
}
64+
}
65+
4266
/// Executes the given procedure after initializing the runtime with the given
4367
/// argc/argv.
4468
///

trunk/src/librustc/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] {
10111011
for details)", "FEATURE"),
10121012
optopt("", "android-cross-path",
10131013
"The path to the Android NDK", "PATH"),
1014-
optmulti("W", "warn",
1014+
optflagopt("W", "warn",
10151015
"Set lint warnings", "OPT"),
10161016
optmulti("A", "allow",
10171017
"Set lint allowed", "OPT"),

trunk/src/librustc/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,14 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
227227
return;
228228
}
229229

230+
// Display the available lint options if "-W help" or only "-W" is given.
230231
let lint_flags = vec::append(matches.opt_strs("W"),
231232
matches.opt_strs("warn"));
232-
if lint_flags.iter().any(|x| x == &~"help") {
233+
234+
let show_lint_options = lint_flags.iter().any(|x| x == &~"help") ||
235+
(matches.opt_present("W") && lint_flags.is_empty());
236+
237+
if show_lint_options {
233238
describe_warnings();
234239
return;
235240
}

trunk/src/librustc/util/sha2.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ static H256: [u32, ..8] = [
523523
#[cfg(test)]
524524
mod tests {
525525
use super::{Digest, Sha256, FixedBuffer};
526+
use std::num::Bounded;
526527
use std::vec;
527528
use std::rand::isaac::IsaacRng;
528529
use std::rand::Rng;

trunk/src/librustpkg/sha1.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ impl Digest for Sha1 {
445445

446446
#[cfg(test)]
447447
mod tests {
448+
use std::num::Bounded;
448449
use std::rand::{IsaacRng, Rng};
449450
use std::vec;
450451
use extra::hex::FromHex;

trunk/src/libstd/cleanup.rs

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ use unstable::raw;
1717

1818
type DropGlue<'a> = 'a |**TyDesc, *c_void|;
1919

20-
static RC_IMMORTAL : uint = 0x77777777;
21-
2220
/*
2321
* Box annihilation
2422
*
@@ -27,21 +25,24 @@ static RC_IMMORTAL : uint = 0x77777777;
2725

2826
struct AnnihilateStats {
2927
n_total_boxes: uint,
28+
n_unique_boxes: uint,
3029
n_bytes_freed: uint
3130
}
3231

3332
unsafe fn each_live_alloc(read_next_before: bool,
34-
f: |alloc: *mut raw::Box<()>| -> bool)
33+
f: |alloc: *mut raw::Box<()>, uniq: bool| -> bool)
3534
-> bool {
3635
//! Walks the internal list of allocations
3736
37+
use managed;
3838
use rt::local_heap;
3939

4040
let mut alloc = local_heap::live_allocs();
4141
while alloc != ptr::mut_null() {
4242
let next_before = (*alloc).next;
43+
let uniq = (*alloc).ref_count == managed::RC_MANAGED_UNIQUE;
4344

44-
if !f(alloc) {
45+
if !f(alloc, uniq) {
4546
return false;
4647
}
4748

@@ -69,19 +70,25 @@ fn debug_mem() -> bool {
6970
pub unsafe fn annihilate() {
7071
use rt::local_heap::local_free;
7172
use mem;
73+
use managed;
7274

7375
let mut stats = AnnihilateStats {
7476
n_total_boxes: 0,
77+
n_unique_boxes: 0,
7578
n_bytes_freed: 0
7679
};
7780

7881
// Pass 1: Make all boxes immortal.
7982
//
8083
// In this pass, nothing gets freed, so it does not matter whether
8184
// we read the next field before or after the callback.
82-
each_live_alloc(true, |alloc| {
85+
each_live_alloc(true, |alloc, uniq| {
8386
stats.n_total_boxes += 1;
84-
(*alloc).ref_count = RC_IMMORTAL;
87+
if uniq {
88+
stats.n_unique_boxes += 1;
89+
} else {
90+
(*alloc).ref_count = managed::RC_IMMORTAL;
91+
}
8592
true
8693
});
8794

@@ -90,10 +97,12 @@ pub unsafe fn annihilate() {
9097
// In this pass, unique-managed boxes may get freed, but not
9198
// managed boxes, so we must read the `next` field *after* the
9299
// callback, as the original value may have been freed.
93-
each_live_alloc(false, |alloc| {
94-
let tydesc = (*alloc).type_desc;
95-
let data = &(*alloc).data as *();
96-
((*tydesc).drop_glue)(data as *i8);
100+
each_live_alloc(false, |alloc, uniq| {
101+
if !uniq {
102+
let tydesc = (*alloc).type_desc;
103+
let data = &(*alloc).data as *();
104+
((*tydesc).drop_glue)(data as *i8);
105+
}
97106
true
98107
});
99108

@@ -103,19 +112,22 @@ pub unsafe fn annihilate() {
103112
// unique-managed boxes, though I think that none of those are
104113
// left), so we must read the `next` field before, since it will
105114
// not be valid after.
106-
each_live_alloc(true, |alloc| {
107-
stats.n_bytes_freed +=
108-
(*((*alloc).type_desc)).size
109-
+ mem::size_of::<raw::Box<()>>();
110-
local_free(alloc as *i8);
115+
each_live_alloc(true, |alloc, uniq| {
116+
if !uniq {
117+
stats.n_bytes_freed +=
118+
(*((*alloc).type_desc)).size
119+
+ mem::size_of::<raw::Box<()>>();
120+
local_free(alloc as *i8);
121+
}
111122
true
112123
});
113124

114125
if debug_mem() {
115126
// We do logging here w/o allocation.
116127
debug!("annihilator stats:\n \
117128
total boxes: {}\n \
129+
unique boxes: {}\n \
118130
bytes freed: {}",
119-
stats.n_total_boxes, stats.n_bytes_freed);
131+
stats.n_total_boxes, stats.n_unique_boxes, stats.n_bytes_freed);
120132
}
121133
}

trunk/src/libstd/managed.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ use ptr::to_unsafe_ptr;
1414

1515
#[cfg(not(test))] use cmp::*;
1616

17+
pub static RC_MANAGED_UNIQUE : uint = (-2) as uint;
18+
pub static RC_IMMORTAL : uint = 0x77777777;
19+
1720
/// Returns the refcount of a shared box (as just before calling this)
1821
#[inline]
1922
pub fn refcount<T>(t: @T) -> uint {

trunk/src/libstd/num/f32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use cmath;
1717
use default::Default;
1818
use libc::{c_float, c_int};
1919
use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal};
20-
use num::{Zero, One, strconv};
20+
use num::{Zero, One, Bounded, strconv};
2121
use num;
2222
use to_str;
2323
use unstable::intrinsics;

trunk/src/libstd/num/f64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use cmath;
1818
use default::Default;
1919
use libc::{c_double, c_int};
2020
use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal};
21-
use num::{Zero, One, strconv};
21+
use num::{Zero, One, Bounded, strconv};
2222
use num;
2323
use to_str;
2424
use unstable::intrinsics;

trunk/src/libstd/num/i16.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use prelude::*;
1616

1717
use default::Default;
18-
use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul};
18+
use num::{Bitwise, Bounded, CheckedAdd, CheckedSub, CheckedMul};
1919
use num::{CheckedDiv, Zero, One, strconv};
2020
use num::{ToStrRadix, FromStrRadix};
2121
use option::{Option, Some, None};
@@ -24,7 +24,7 @@ use unstable::intrinsics;
2424

2525
int_module!(i16, 16)
2626

27-
impl BitCount for i16 {
27+
impl Bitwise for i16 {
2828
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
2929
#[inline]
3030
fn population_count(&self) -> i16 { unsafe { intrinsics::ctpop16(*self) } }

trunk/src/libstd/num/i32.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use prelude::*;
1616

1717
use default::Default;
18-
use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul};
18+
use num::{Bitwise, Bounded, CheckedAdd, CheckedSub, CheckedMul};
1919
use num::{CheckedDiv, Zero, One, strconv};
2020
use num::{ToStrRadix, FromStrRadix};
2121
use option::{Option, Some, None};
@@ -24,7 +24,7 @@ use unstable::intrinsics;
2424

2525
int_module!(i32, 32)
2626

27-
impl BitCount for i32 {
27+
impl Bitwise for i32 {
2828
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
2929
#[inline]
3030
fn population_count(&self) -> i32 { unsafe { intrinsics::ctpop32(*self) } }

trunk/src/libstd/num/i64.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use prelude::*;
1717
use default::Default;
1818
#[cfg(target_word_size = "64")]
1919
use num::CheckedMul;
20-
use num::{BitCount, CheckedAdd, CheckedSub};
20+
use num::{Bitwise, Bounded, CheckedAdd, CheckedSub};
2121
use num::{CheckedDiv, Zero, One, strconv};
2222
use num::{ToStrRadix, FromStrRadix};
2323
use option::{Option, Some, None};
@@ -26,7 +26,7 @@ use unstable::intrinsics;
2626

2727
int_module!(i64, 64)
2828

29-
impl BitCount for i64 {
29+
impl Bitwise for i64 {
3030
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
3131
#[inline]
3232
fn population_count(&self) -> i64 { unsafe { intrinsics::ctpop64(*self) } }

trunk/src/libstd/num/i8.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use prelude::*;
1616

1717
use default::Default;
18-
use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul};
18+
use num::{Bitwise, Bounded, CheckedAdd, CheckedSub, CheckedMul};
1919
use num::{CheckedDiv, Zero, One, strconv};
2020
use num::{ToStrRadix, FromStrRadix};
2121
use option::{Option, Some, None};
@@ -24,7 +24,7 @@ use unstable::intrinsics;
2424

2525
int_module!(i8, 8)
2626

27-
impl BitCount for i8 {
27+
impl Bitwise for i8 {
2828
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
2929
#[inline]
3030
fn population_count(&self) -> i8 { unsafe { intrinsics::ctpop8(*self) } }

trunk/src/libstd/num/int.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use prelude::*;
1616

1717
use default::Default;
18-
use num::{BitCount, CheckedAdd, CheckedSub, CheckedMul};
18+
use num::{Bitwise, Bounded, CheckedAdd, CheckedSub, CheckedMul};
1919
use num::{CheckedDiv, Zero, One, strconv};
2020
use num::{ToStrRadix, FromStrRadix};
2121
use option::{Option, Some, None};
@@ -26,7 +26,7 @@ use unstable::intrinsics;
2626
#[cfg(target_word_size = "64")] int_module!(int, 64)
2727

2828
#[cfg(target_word_size = "32")]
29-
impl BitCount for int {
29+
impl Bitwise for int {
3030
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
3131
#[inline]
3232
fn population_count(&self) -> int { (*self as i32).population_count() as int }
@@ -41,7 +41,7 @@ impl BitCount for int {
4141
}
4242

4343
#[cfg(target_word_size = "64")]
44-
impl BitCount for int {
44+
impl Bitwise for int {
4545
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
4646
#[inline]
4747
fn population_count(&self) -> int { (*self as i64).population_count() as int }

trunk/src/libstd/num/int_macros.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,13 @@ impl Integer for $T {
308308

309309
/// Returns `true` if the number is divisible by `2`
310310
#[inline]
311-
fn is_even(&self) -> bool { self & 1 == 0 }
311+
fn is_even(&self) -> bool { self.is_multiple_of(&2) }
312312

313313
/// Returns `true` if the number is not divisible by `2`
314314
#[inline]
315315
fn is_odd(&self) -> bool { !self.is_even() }
316316
}
317317

318-
impl Bitwise for $T {}
319-
320318
#[cfg(not(test))]
321319
impl BitOr<$T,$T> for $T {
322320
#[inline]
@@ -446,6 +444,7 @@ mod tests {
446444
use i32;
447445
use num;
448446
use num::CheckedDiv;
447+
use num::Bitwise;
449448
use mem;
450449

451450
#[test]

0 commit comments

Comments
 (0)