File tree Expand file tree Collapse file tree 2 files changed +16
-13
lines changed Expand file tree Collapse file tree 2 files changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,16 @@ use libc::c_char;
5757#[ cfg( windows) ]
5858use 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
6171pub static TMPBUF_SZ : uint = 1000 u;
6272static BUF_BYTES : uint = 2048 u;
@@ -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 ( ) ;
Original file line number Diff line number Diff line change 1111use from_str:: FromStr ;
1212use from_str:: from_str;
1313use libc:: uintptr_t;
14- use libc;
1514use option:: { Some , None , Option } ;
1615use os;
1716use str:: Str ;
1817use 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 }
You can’t perform that action at this time.
0 commit comments