Move num_cpus from std::rt::util to std::os. Closes #14707
This commit is contained in:
committed by
Alex Crichton
parent
88e1576190
commit
0439162d59
@@ -57,6 +57,16 @@ use libc::c_char;
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use str::OwnedStr;
|
use str::OwnedStr;
|
||||||
|
|
||||||
|
/// Get the number of cores available
|
||||||
|
pub fn num_cpus() -> uint {
|
||||||
|
unsafe {
|
||||||
|
return rust_get_num_cpus();
|
||||||
|
}
|
||||||
|
|
||||||
|
extern {
|
||||||
|
fn rust_get_num_cpus() -> libc::uintptr_t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub static TMPBUF_SZ : uint = 1000u;
|
pub static TMPBUF_SZ : uint = 1000u;
|
||||||
static BUF_BYTES : uint = 2048u;
|
static BUF_BYTES : uint = 2048u;
|
||||||
@@ -1762,6 +1772,11 @@ mod tests {
|
|||||||
n
|
n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_num_cpus() {
|
||||||
|
assert!(os::num_cpus() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_setenv() {
|
fn test_setenv() {
|
||||||
let n = make_rand_name();
|
let n = make_rand_name();
|
||||||
|
|||||||
@@ -11,23 +11,11 @@
|
|||||||
use from_str::FromStr;
|
use from_str::FromStr;
|
||||||
use from_str::from_str;
|
use from_str::from_str;
|
||||||
use libc::uintptr_t;
|
use libc::uintptr_t;
|
||||||
use libc;
|
|
||||||
use option::{Some, None, Option};
|
use option::{Some, None, Option};
|
||||||
use os;
|
use os;
|
||||||
use str::Str;
|
use str::Str;
|
||||||
use sync::atomics;
|
use sync::atomics;
|
||||||
|
|
||||||
/// Get the number of cores available
|
|
||||||
pub fn num_cpus() -> uint {
|
|
||||||
unsafe {
|
|
||||||
return rust_get_num_cpus();
|
|
||||||
}
|
|
||||||
|
|
||||||
extern {
|
|
||||||
fn rust_get_num_cpus() -> libc::uintptr_t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Dynamically inquire about whether we're running under V.
|
/// Dynamically inquire about whether we're running under V.
|
||||||
/// You should usually not use this unless your test definitely
|
/// You should usually not use this unless your test definitely
|
||||||
/// can't run correctly un-altered. Valgrind is there to help
|
/// can't run correctly un-altered. Valgrind is there to help
|
||||||
@@ -81,7 +69,7 @@ pub fn default_sched_threads() -> uint {
|
|||||||
if limit_thread_creation_due_to_osx_and_valgrind() {
|
if limit_thread_creation_due_to_osx_and_valgrind() {
|
||||||
1
|
1
|
||||||
} else {
|
} else {
|
||||||
num_cpus()
|
os::num_cpus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user