Skip to content

Commit 3c4ddcc

Browse files
Jorge Aparicioalexcrichton
Jorge Aparicio
authored andcommitted
---
yaml --- r: 152567 b: refs/heads/try2 c: 0439162 h: refs/heads/master i: 152565: 8d93f18 152563: 9fb10a0 152559: 48b717d v: v3
1 parent d8a7502 commit 3c4ddcc

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 88e157619019894bbd3ecda0e3a1c9be4ce89ad6
8+
refs/heads/try2: 0439162d597d4abfebf93096e71ff45242efe6f0
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/os.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ use libc::c_char;
5757
#[cfg(windows)]
5858
use str::OwnedStr;
5959

60+
/// Get the number of cores available
61+
pub fn num_cpus() -> uint {
62+
unsafe {
63+
return rust_get_num_cpus();
64+
}
65+
66+
extern {
67+
fn rust_get_num_cpus() -> libc::uintptr_t;
68+
}
69+
}
6070

6171
pub static TMPBUF_SZ : uint = 1000u;
6272
static BUF_BYTES : uint = 2048u;
@@ -1762,6 +1772,11 @@ mod tests {
17621772
n
17631773
}
17641774

1775+
#[test]
1776+
fn test_num_cpus() {
1777+
assert!(os::num_cpus() > 0);
1778+
}
1779+
17651780
#[test]
17661781
fn test_setenv() {
17671782
let n = make_rand_name();

branches/try2/src/libstd/rt/util.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,11 @@
1111
use from_str::FromStr;
1212
use from_str::from_str;
1313
use libc::uintptr_t;
14-
use libc;
1514
use option::{Some, None, Option};
1615
use os;
1716
use str::Str;
1817
use sync::atomics;
1918

20-
/// Get the number of cores available
21-
pub fn num_cpus() -> uint {
22-
unsafe {
23-
return rust_get_num_cpus();
24-
}
25-
26-
extern {
27-
fn rust_get_num_cpus() -> libc::uintptr_t;
28-
}
29-
}
30-
3119
/// Dynamically inquire about whether we're running under V.
3220
/// You should usually not use this unless your test definitely
3321
/// can't run correctly un-altered. Valgrind is there to help
@@ -81,7 +69,7 @@ pub fn default_sched_threads() -> uint {
8169
if limit_thread_creation_due_to_osx_and_valgrind() {
8270
1
8371
} else {
84-
num_cpus()
72+
os::num_cpus()
8573
}
8674
}
8775
}

0 commit comments

Comments
 (0)