Skip to content

Commit 7814297

Browse files
committed
---
yaml --- r: 63647 b: refs/heads/snap-stage3 c: e65d0cb h: refs/heads/master i: 63645: 73d4551 63643: fb6312b 63639: 3e836d2 63631: bc5b088 63615: d6ba531 v: v3
1 parent f438a61 commit 7814297

File tree

5 files changed

+19
-24
lines changed

5 files changed

+19
-24
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: d071f51cdc7c3492ae2bc4180ffbf13bcdb31439
4+
refs/heads/snap-stage3: e65d0cbabebc73f2c9733a7ed158576c9702e71e
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libextra/test.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@ use core::to_str::ToStr;
3131
use core::uint;
3232
use core::vec;
3333

34-
pub mod rustrt {
35-
use core::libc::size_t;
36-
37-
#[abi = "cdecl"]
38-
pub extern {
39-
pub unsafe fn rust_sched_threads() -> size_t;
40-
}
41-
}
4234

4335
// The name of a test. By convention this follows the rules for rust
4436
// paths; i.e. it should be a series of identifiers separated by double
@@ -488,11 +480,10 @@ static sched_overcommit : uint = 1;
488480
static sched_overcommit : uint = 4u;
489481
490482
fn get_concurrency() -> uint {
491-
unsafe {
492-
let threads = rustrt::rust_sched_threads() as uint;
493-
if threads == 1 { 1 }
494-
else { threads * sched_overcommit }
495-
}
483+
use core::rt;
484+
let threads = rt::util::default_sched_threads();
485+
if threads == 1 { 1 }
486+
else { threads * sched_overcommit }
496487
}
497488
498489
#[allow(non_implicitly_copyable_typarams)]

branches/snap-stage3/src/libstd/rt/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,9 @@ Several modules in `core` are clients of `rt`:
6363
use cell::Cell;
6464
use clone::Clone;
6565
use container::Container;
66-
use from_str::FromStr;
6766
use iter::Times;
6867
use iterator::IteratorUtil;
69-
use option::{Some, None};
70-
use os;
68+
use option::Some;
7169
use ptr::RawPtr;
7270
use rt::sched::{Scheduler, Coroutine, Shutdown};
7371
use rt::sleeper_list::SleeperList;
@@ -223,10 +221,7 @@ pub fn run(main: ~fn()) -> int {
223221

224222
static DEFAULT_ERROR_CODE: int = 101;
225223

226-
let nthreads = match os::getenv("RUST_THREADS") {
227-
Some(nstr) => FromStr::from_str(nstr).get(),
228-
None => util::num_cpus()
229-
};
224+
let nthreads = util::default_sched_threads();
230225

231226
// The shared list of sleeping schedulers. Schedulers wake each other
232227
// occassionally to do new work.

branches/snap-stage3/src/libstd/rt/util.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
// except according to those terms.
1010

1111
use container::Container;
12+
use from_str::FromStr;
1213
use iterator::IteratorUtil;
1314
use libc;
15+
use option::{Some, None};
16+
use os;
1417
use str::StrSlice;
1518

1619
/// Get the number of cores available
@@ -24,6 +27,15 @@ pub fn num_cpus() -> uint {
2427
}
2528
}
2629

30+
/// Get's the number of scheduler threads requested by the environment
31+
/// either `RUST_THREADS` or `num_cpus`.
32+
pub fn default_sched_threads() -> uint {
33+
match os::getenv("RUST_THREADS") {
34+
Some(nstr) => FromStr::from_str(nstr).get(),
35+
None => num_cpus()
36+
}
37+
}
38+
2739
pub fn dumb_println(s: &str) {
2840
use io::WriterUtil;
2941
let dbg = ::libc::STDERR_FILENO as ::io::fd_t;

branches/snap-stage3/src/test/run-pass/morestack6.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,13 @@ mod rustrt {
2323
pub fn rust_get_sched_id() -> libc::intptr_t;
2424
pub fn rust_get_argc() -> libc::c_int;
2525
pub fn get_task_id() -> libc::intptr_t;
26-
pub fn rust_sched_threads();
2726
pub fn rust_get_task();
2827
}
2928
}
3029

3130
fn calllink01() { unsafe { rustrt::rust_get_sched_id(); } }
3231
fn calllink02() { unsafe { rustrt::rust_get_argc(); } }
3332
fn calllink08() { unsafe { rustrt::get_task_id(); } }
34-
fn calllink09() { unsafe { rustrt::rust_sched_threads(); } }
3533
fn calllink10() { unsafe { rustrt::rust_get_task(); } }
3634

3735
fn runtest(f: extern fn(), frame_backoff: u32) {
@@ -64,7 +62,6 @@ pub fn main() {
6462
calllink01,
6563
calllink02,
6664
calllink08,
67-
calllink09,
6865
calllink10
6966
];
7067
let mut rng = rand::rng();

0 commit comments

Comments
 (0)