Skip to content

Commit 73f33c6

Browse files
committed
---
yaml --- r: 228123 b: refs/heads/try c: 83ee47b h: refs/heads/master i: 228121: ea35dbf 228119: f31c633 v: v3
1 parent c242c85 commit 73f33c6

File tree

5 files changed

+36
-41
lines changed

5 files changed

+36
-41
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 18c39e126a833f66f58fe6cbf7b97ca4262f1c90
4+
refs/heads/try: 83ee47b054deb5939be20d7d6ce03ad33d005424
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use io::prelude::*;
1313
use env;
1414
use fmt;
1515
use intrinsics;
16-
use libc::uintptr_t;
1716
use sync::atomic::{self, Ordering};
1817
use sys::stdio::Stderr;
1918

@@ -22,10 +21,18 @@ use sys::stdio::Stderr;
2221
/// can't run correctly un-altered. Valgrind is there to help
2322
/// you notice weirdness in normal, un-doctored code paths!
2423
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 }
2735
}
28-
unsafe { rust_running_on_valgrind() != 0 }
2936
}
3037

3138
/// Valgrind has a fixed-sized array (size around 2000) of segment descriptors

branches/try/src/libstd/rtdeps.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
//! the standard library This varies per-platform, but these libraries are
1313
//! necessary for running libstd.
1414
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)))]
1717
#[link(name = "rust_builtin", kind = "static")]
1818
extern {}
1919

branches/try/src/libtest/lib.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ fn run_tests<F>(opts: &TestOpts,
872872

873873
#[allow(deprecated)]
874874
fn get_concurrency() -> usize {
875-
match env::var("RUST_TEST_THREADS") {
875+
return match env::var("RUST_TEST_THREADS") {
876876
Ok(s) => {
877877
let opt_n: Option<usize> = s.parse().ok();
878878
match opt_n {
@@ -884,10 +884,24 @@ fn get_concurrency() -> usize {
884884
if std::rt::util::limit_thread_creation_due_to_osx_and_valgrind() {
885885
1
886886
} else {
887-
extern { fn rust_get_num_cpus() -> libc::uintptr_t; }
888-
unsafe { rust_get_num_cpus() as usize }
887+
num_cpus()
889888
}
890889
}
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 }
891905
}
892906
}
893907

branches/try/src/rt/rust_builtin.c

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,22 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#if !defined(_WIN32)
12+
1113
#include <stdint.h>
1214
#include <time.h>
1315
#include <string.h>
1416
#include <assert.h>
1517
#include <stdlib.h>
1618

1719

18-
#if !defined(_WIN32)
1920
#include <dirent.h>
2021
#include <pthread.h>
2122
#include <signal.h>
2223
#include <sys/stat.h>
2324
#include <sys/time.h>
2425
#include <sys/types.h>
2526
#include <unistd.h>
26-
#else
27-
#include <windows.h>
28-
#include <wincrypt.h>
29-
#include <stdio.h>
30-
#include <tchar.h>
31-
#endif
3227

3328
#ifdef __APPLE__
3429
#include <TargetConditionals.h>
@@ -41,17 +36,8 @@
4136

4237
/* Foreign builtins. */
4338
//include valgrind.h after stdint.h so that uintptr_t is defined for msys2 w64
44-
#ifndef _WIN32
4539
#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
5340

54-
#ifndef _WIN32
5541
char*
5642
rust_list_dir_val(struct dirent* entry_ptr) {
5743
return entry_ptr->d_name;
@@ -92,17 +78,8 @@ int
9278
rust_dirent_t_size() {
9379
return sizeof(struct dirent);
9480
}
95-
#endif
96-
97-
#if defined(_WIN32)
98-
int
99-
get_num_cpus() {
100-
SYSTEM_INFO sysinfo;
101-
GetSystemInfo(&sysinfo);
10281

103-
return (int) sysinfo.dwNumberOfProcessors;
104-
}
105-
#elif defined(__BSD__)
82+
#if defined(__BSD__)
10683
int
10784
get_num_cpus() {
10885
/* swiped from http://stackoverflow.com/questions/150355/
@@ -136,19 +113,14 @@ get_num_cpus() {
136113
}
137114
#endif
138115

139-
RUST_BUILTIN_API
140116
uintptr_t
141117
rust_get_num_cpus() {
142118
return get_num_cpus();
143119
}
144120

145121
uintptr_t
146122
rust_running_on_valgrind() {
147-
#ifdef _WIN32
148-
return 0;
149-
#else
150123
return RUNNING_ON_VALGRIND;
151-
#endif
152124
}
153125

154126
#if defined(__DragonFly__)
@@ -484,6 +456,8 @@ const char * rust_current_exe() {
484456

485457
#endif
486458

459+
#endif // !defined(_WIN32)
460+
487461
//
488462
// Local Variables:
489463
// mode: C++

0 commit comments

Comments
 (0)