File tree 4 files changed +35
-40
lines changed
4 files changed +35
-40
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ use io::prelude::*;
13
13
use env;
14
14
use fmt;
15
15
use intrinsics;
16
- use libc:: uintptr_t;
17
16
use sync:: atomic:: { self , Ordering } ;
18
17
use sys:: stdio:: Stderr ;
19
18
@@ -22,10 +21,18 @@ use sys::stdio::Stderr;
22
21
/// can't run correctly un-altered. Valgrind is there to help
23
22
/// you notice weirdness in normal, un-doctored code paths!
24
23
pub fn running_on_valgrind ( ) -> bool {
25
- extern {
26
- fn rust_running_on_valgrind ( ) -> uintptr_t ;
24
+ return on_valgrind ( ) ;
25
+ #[ cfg( windows) ]
26
+ fn on_valgrind ( ) -> bool { false }
27
+
28
+ #[ cfg( unix) ]
29
+ fn on_valgrind ( ) -> bool {
30
+ use libc:: uintptr_t;
31
+ extern {
32
+ fn rust_running_on_valgrind ( ) -> uintptr_t ;
33
+ }
34
+ unsafe { rust_running_on_valgrind ( ) != 0 }
27
35
}
28
- unsafe { rust_running_on_valgrind ( ) != 0 }
29
36
}
30
37
31
38
/// Valgrind has a fixed-sized array (size around 2000) of segment descriptors
Original file line number Diff line number Diff line change 12
12
//! the standard library This varies per-platform, but these libraries are
13
13
//! necessary for running libstd.
14
14
15
- // All platforms need to link to rustrt
16
- #[ cfg( not( test) ) ]
15
+ // A few small shims in C that haven't been translated to Rust yet
16
+ #[ cfg( all ( not( test) , not ( windows ) ) ) ]
17
17
#[ link( name = "rust_builtin" , kind = "static" ) ]
18
18
extern { }
19
19
Original file line number Diff line number Diff line change @@ -872,7 +872,7 @@ fn run_tests<F>(opts: &TestOpts,
872
872
873
873
#[ allow( deprecated) ]
874
874
fn get_concurrency ( ) -> usize {
875
- match env:: var ( "RUST_TEST_THREADS" ) {
875
+ return match env:: var ( "RUST_TEST_THREADS" ) {
876
876
Ok ( s) => {
877
877
let opt_n: Option < usize > = s. parse ( ) . ok ( ) ;
878
878
match opt_n {
@@ -884,10 +884,24 @@ fn get_concurrency() -> usize {
884
884
if std:: rt:: util:: limit_thread_creation_due_to_osx_and_valgrind ( ) {
885
885
1
886
886
} else {
887
- extern { fn rust_get_num_cpus ( ) -> libc:: uintptr_t ; }
888
- unsafe { rust_get_num_cpus ( ) as usize }
887
+ num_cpus ( )
889
888
}
890
889
}
890
+ } ;
891
+
892
+ #[ cfg( windows) ]
893
+ fn num_cpus ( ) -> usize {
894
+ unsafe {
895
+ let mut sysinfo = std:: mem:: zeroed ( ) ;
896
+ libc:: GetSystemInfo ( & mut sysinfo) ;
897
+ sysinfo. dwNumberOfProcessors as usize
898
+ }
899
+ }
900
+
901
+ #[ cfg( unix) ]
902
+ fn num_cpus ( ) -> usize {
903
+ extern { fn rust_get_num_cpus ( ) -> libc:: uintptr_t ; }
904
+ unsafe { rust_get_num_cpus ( ) as usize }
891
905
}
892
906
}
893
907
Original file line number Diff line number Diff line change 8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
+ #if !defined(_WIN32 )
12
+
11
13
#include <stdint.h>
12
14
#include <time.h>
13
15
#include <string.h>
14
16
#include <assert.h>
15
17
#include <stdlib.h>
16
18
17
19
18
- #if !defined(_WIN32 )
19
20
#include <dirent.h>
20
21
#include <pthread.h>
21
22
#include <signal.h>
22
23
#include <sys/stat.h>
23
24
#include <sys/time.h>
24
25
#include <sys/types.h>
25
26
#include <unistd.h>
26
- #else
27
- #include <windows.h>
28
- #include <wincrypt.h>
29
- #include <stdio.h>
30
- #include <tchar.h>
31
- #endif
32
27
33
28
#ifdef __APPLE__
34
29
#include <TargetConditionals.h>
41
36
42
37
/* Foreign builtins. */
43
38
//include valgrind.h after stdint.h so that uintptr_t is defined for msys2 w64
44
- #ifndef _WIN32
45
39
#include "valgrind/valgrind.h"
46
- #endif
47
-
48
- #if defined(_MSC_VER )
49
- # define RUST_BUILTIN_API __declspec(dllexport)
50
- #else
51
- # define RUST_BUILTIN_API
52
- #endif
53
40
54
- #ifndef _WIN32
55
41
char *
56
42
rust_list_dir_val (struct dirent * entry_ptr ) {
57
43
return entry_ptr -> d_name ;
92
78
rust_dirent_t_size () {
93
79
return sizeof (struct dirent );
94
80
}
95
- #endif
96
-
97
- #if defined(_WIN32 )
98
- int
99
- get_num_cpus () {
100
- SYSTEM_INFO sysinfo ;
101
- GetSystemInfo (& sysinfo );
102
81
103
- return (int ) sysinfo .dwNumberOfProcessors ;
104
- }
105
- #elif defined(__BSD__ )
82
+ #if defined(__BSD__ )
106
83
int
107
84
get_num_cpus () {
108
85
/* swiped from http://stackoverflow.com/questions/150355/
@@ -136,19 +113,14 @@ get_num_cpus() {
136
113
}
137
114
#endif
138
115
139
- RUST_BUILTIN_API
140
116
uintptr_t
141
117
rust_get_num_cpus () {
142
118
return get_num_cpus ();
143
119
}
144
120
145
121
uintptr_t
146
122
rust_running_on_valgrind () {
147
- #ifdef _WIN32
148
- return 0 ;
149
- #else
150
123
return RUNNING_ON_VALGRIND ;
151
- #endif
152
124
}
153
125
154
126
#if defined(__DragonFly__ )
@@ -484,6 +456,8 @@ const char * rust_current_exe() {
484
456
485
457
#endif
486
458
459
+ #endif // !defined(_WIN32)
460
+
487
461
//
488
462
// Local Variables:
489
463
// mode: C++
You can’t perform that action at this time.
0 commit comments