File tree 2 files changed +16
-13
lines changed 2 files changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,16 @@ use libc::c_char;
56
56
#[ cfg( windows) ]
57
57
use str:: OwnedStr ;
58
58
59
+ /// Get the number of cores available
60
+ pub fn num_cpus ( ) -> uint {
61
+ unsafe {
62
+ return rust_get_num_cpus ( ) ;
63
+ }
64
+
65
+ extern {
66
+ fn rust_get_num_cpus ( ) -> libc:: uintptr_t ;
67
+ }
68
+ }
59
69
60
70
pub static TMPBUF_SZ : uint = 1000 u;
61
71
static BUF_BYTES : uint = 2048 u;
@@ -1751,6 +1761,11 @@ mod tests {
1751
1761
n
1752
1762
}
1753
1763
1764
+ #[ test]
1765
+ fn test_num_cpus ( ) {
1766
+ assert ! ( os:: num_cpus( ) > 0 ) ;
1767
+ }
1768
+
1754
1769
#[ test]
1755
1770
fn test_setenv ( ) {
1756
1771
let n = make_rand_name ( ) ;
Original file line number Diff line number Diff line change 11
11
use from_str:: FromStr ;
12
12
use from_str:: from_str;
13
13
use libc:: uintptr_t;
14
- use libc;
15
14
use option:: { Some , None , Option } ;
16
15
use os;
17
16
use str:: Str ;
18
17
use sync:: atomics;
19
18
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
-
31
19
/// Dynamically inquire about whether we're running under V.
32
20
/// You should usually not use this unless your test definitely
33
21
/// can't run correctly un-altered. Valgrind is there to help
@@ -81,7 +69,7 @@ pub fn default_sched_threads() -> uint {
81
69
if limit_thread_creation_due_to_osx_and_valgrind ( ) {
82
70
1
83
71
} else {
84
- num_cpus ( )
72
+ os :: num_cpus ( )
85
73
}
86
74
}
87
75
}
You can’t perform that action at this time.
0 commit comments