Skip to content

Commit 4cf0634

Browse files
committed
---
yaml --- r: 77823 b: refs/heads/master c: 1f9bd62 h: refs/heads/master i: 77821: a49ba5a 77819: bb503fe 77815: be9b047 77807: 7b7e3b6 77791: 2aee5cd 77759: 74dfbc8 77695: cbfc9fc 77567: 3bb6c9e 77311: 550e548 76799: 3017d5f 75775: 6fc9a78 73727: d50f3f3 v: v3
1 parent 7017384 commit 4cf0634

File tree

9 files changed

+29
-75
lines changed

9 files changed

+29
-75
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: c7a269fedc7476ff2bce205c6b782290c89befa3
2+
refs/heads/master: 1f9bd62fd6d63689b2d4bb4338625addf0e09bdd
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 60fba4d7d677ec098e6a43014132fe99f7547363
55
refs/heads/try: ebfe63cd1c0b5d23f7ea60c69b4fde2e30cfd42a

trunk/doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ break
209209
do
210210
else enum extern
211211
false fn for
212-
if impl in
212+
if impl
213213
let loop
214214
match mod mut
215215
priv pub

trunk/src/libextra/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ fn get_concurrency() -> uint {
745745
let opt_n: Option<uint> = FromStr::from_str(s);
746746
match opt_n {
747747
Some(n) if n > 0 => n,
748-
_ => fail!("RUST_TEST_TASKS is `%s`, should be a non-negative integer.", s)
748+
_ => fail!("RUST_TEST_TASKS is `%s`, should be a positive integer.", s)
749749
}
750750
}
751751
None => {

trunk/src/libstd/rt/args.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ pub fn clone() -> Option<~[~str]> {
5555
mod imp {
5656
use libc;
5757
use option::{Option, Some, None};
58-
use iterator::{Iterator, range};
58+
use iterator::Iterator;
5959
use str;
6060
use unstable::finally::Finally;
6161
use util;
62+
use vec;
6263

6364
pub unsafe fn init(argc: int, argv: **u8) {
6465
let args = load_argc_and_argv(argc, argv);
@@ -111,11 +112,9 @@ mod imp {
111112

112113
// Copied from `os`.
113114
unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~str] {
114-
let mut args = ~[];
115-
for i in range(0u, argc as uint) {
116-
args.push(str::raw::from_c_str(*(argv as **libc::c_char).offset(i as int)));
115+
do vec::from_fn(argc as uint) |i| {
116+
str::raw::from_c_str(*(argv as **libc::c_char).offset(i as int))
117117
}
118-
args
119118
}
120119

121120
#[cfg(stage0)]

trunk/src/libstd/rt/local_ptr.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,27 +121,20 @@ pub unsafe fn borrow<T>(f: &fn(&mut T)) {
121121
/// For the Scheduler pointer to be aliased
122122
pub unsafe fn unsafe_borrow<T>() -> *mut T {
123123
let key = tls_key();
124-
let mut void_ptr: *mut c_void = tls::get(key);
124+
let void_ptr = tls::get(key);
125125
if void_ptr.is_null() {
126126
rtabort!("thread-local pointer is null. bogus!");
127127
}
128-
let ptr: *mut *mut c_void = &mut void_ptr;
129-
let ptr: *mut ~T = ptr as *mut ~T;
130-
let ptr: *mut T = &mut **ptr;
131-
return ptr;
128+
void_ptr as *mut T
132129
}
133130

134131
pub unsafe fn try_unsafe_borrow<T>() -> Option<*mut T> {
135132
let key = tls_key();
136-
let mut void_ptr: *mut c_void = tls::get(key);
133+
let void_ptr = tls::get(key);
137134
if void_ptr.is_null() {
138-
return None;
139-
}
140-
{
141-
let ptr: *mut *mut c_void = &mut void_ptr;
142-
let ptr: *mut ~T = ptr as *mut ~T;
143-
let ptr: *mut T = &mut **ptr;
144-
return Some(ptr);
135+
None
136+
} else {
137+
Some(void_ptr as *mut T)
145138
}
146139
}
147140

trunk/src/libstd/rt/mod.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Several modules in `core` are clients of `rt`:
5959
use cell::Cell;
6060
use clone::Clone;
6161
use container::Container;
62-
use iterator::{Iterator, range};
62+
use iterator::Iterator;
6363
use option::{Option, None, Some};
6464
use ptr::RawPtr;
6565
use rt::local::Local;
@@ -71,7 +71,8 @@ use rt::work_queue::WorkQueue;
7171
use rt::uv::uvio::UvEventLoop;
7272
use unstable::atomics::{AtomicInt, SeqCst};
7373
use unstable::sync::UnsafeArc;
74-
use vec::{OwnedVector, MutableVector};
74+
use vec;
75+
use vec::{OwnedVector, MutableVector, ImmutableVector};
7576

7677
/// The global (exchange) heap.
7778
pub mod global_heap;
@@ -251,25 +252,21 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int {
251252

252253
// Create a work queue for each scheduler, ntimes. Create an extra
253254
// for the main thread if that flag is set. We won't steal from it.
254-
let mut work_queues = ~[];
255-
for _ in range(0u, nscheds) {
256-
let work_queue: WorkQueue<~Task> = WorkQueue::new();
257-
work_queues.push(work_queue);
258-
}
255+
let work_queues: ~[WorkQueue<~Task>] = vec::from_fn(nscheds, |_| WorkQueue::new());
259256

260257
// The schedulers.
261258
let mut scheds = ~[];
262259
// Handles to the schedulers. When the main task ends these will be
263260
// sent the Shutdown message to terminate the schedulers.
264261
let mut handles = ~[];
265262

266-
for i in range(0u, nscheds) {
263+
for work_queue in work_queues.iter() {
267264
rtdebug!("inserting a regular scheduler");
268265

269266
// Every scheduler is driven by an I/O event loop.
270267
let loop_ = ~UvEventLoop::new();
271268
let mut sched = ~Scheduler::new(loop_,
272-
work_queues[i].clone(),
269+
work_queue.clone(),
273270
work_queues.clone(),
274271
sleepers.clone());
275272
let handle = sched.make_handle();
@@ -358,9 +355,8 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int {
358355
}
359356

360357
// Run each remaining scheduler in a thread.
361-
while !scheds.is_empty() {
358+
for sched in scheds.move_rev_iter() {
362359
rtdebug!("creating regular schedulers");
363-
let sched = scheds.pop();
364360
let sched_cell = Cell::new(sched);
365361
let thread = do Thread::start {
366362
let mut sched = sched_cell.take();

trunk/src/libstd/rt/util.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use container::Container;
1212
use from_str::FromStr;
1313
use libc;
14-
use option::{Some, None};
14+
use option::{Some, None, Option};
1515
use os;
1616
use str::StrSlice;
1717
use unstable::atomics::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
@@ -57,7 +57,13 @@ pub fn limit_thread_creation_due_to_osx_and_valgrind() -> bool {
5757
/// either `RUST_THREADS` or `num_cpus`.
5858
pub fn default_sched_threads() -> uint {
5959
match os::getenv("RUST_THREADS") {
60-
Some(nstr) => FromStr::from_str(nstr).unwrap(),
60+
Some(nstr) => {
61+
let opt_n: Option<uint> = FromStr::from_str(nstr);
62+
match opt_n {
63+
Some(n) if n > 0 => n,
64+
_ => rtabort!("`RUST_THREADS` is `%s`, should be a positive integer", nstr)
65+
}
66+
}
6167
None => {
6268
if limit_thread_creation_due_to_osx_and_valgrind() {
6369
1

trunk/src/libstd/str.rs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -907,46 +907,6 @@ pub fn with_capacity(capacity: uint) -> ~str {
907907
}
908908
}
909909

910-
/// As char_len but for a slice of a string
911-
///
912-
/// # Arguments
913-
///
914-
/// * s - A valid string
915-
/// * start - The position inside `s` where to start counting in bytes
916-
/// * end - The position where to stop counting
917-
///
918-
/// # Return value
919-
///
920-
/// The number of Unicode characters in `s` between the given indices.
921-
pub fn count_chars(s: &str, start: uint, end: uint) -> uint {
922-
assert!(s.is_char_boundary(start));
923-
assert!(s.is_char_boundary(end));
924-
let mut i = start;
925-
let mut len = 0u;
926-
while i < end {
927-
let next = s.char_range_at(i).next;
928-
len += 1u;
929-
i = next;
930-
}
931-
return len;
932-
}
933-
934-
/// Counts the number of bytes taken by the first `n` chars in `s`
935-
/// starting from `start`.
936-
pub fn count_bytes<'b>(s: &'b str, start: uint, n: uint) -> uint {
937-
assert!(s.is_char_boundary(start));
938-
let mut end = start;
939-
let mut cnt = n;
940-
let l = s.len();
941-
while cnt > 0u {
942-
assert!(end < l);
943-
let next = s.char_range_at(end).next;
944-
cnt -= 1u;
945-
end = next;
946-
}
947-
end - start
948-
}
949-
950910
// https://tools.ietf.org/html/rfc3629
951911
static UTF8_CHAR_WIDTH: [u8, ..256] = [
952912
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,

trunk/src/test/run-fail/test-threads-invalid-value.rs renamed to trunk/src/test/run-fail/test-tasks-invalid-value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// This checks that RUST_TEST_TASKS not being 1, 2, ... is detected
1212
// properly.
1313

14-
// error-pattern:should be a non-negative integer
14+
// error-pattern:should be a positive integer
1515
// compile-flags: --test
1616
// exec-env:RUST_TEST_TASKS=foo
1717

0 commit comments

Comments
 (0)