windows: Don't link rust_builtin
This library has no shims which are actually needed on Windows now, so translate that last easy one into Rust and then don't link it at all on Windows.
This commit is contained in:
parent
18c39e126a
commit
83ee47b054
@ -13,7 +13,6 @@ use io::prelude::*;
|
||||
use env;
|
||||
use fmt;
|
||||
use intrinsics;
|
||||
use libc::uintptr_t;
|
||||
use sync::atomic::{self, Ordering};
|
||||
use sys::stdio::Stderr;
|
||||
|
||||
@ -22,10 +21,18 @@ use sys::stdio::Stderr;
|
||||
/// can't run correctly un-altered. Valgrind is there to help
|
||||
/// you notice weirdness in normal, un-doctored code paths!
|
||||
pub fn running_on_valgrind() -> bool {
|
||||
extern {
|
||||
fn rust_running_on_valgrind() -> uintptr_t;
|
||||
return on_valgrind();
|
||||
#[cfg(windows)]
|
||||
fn on_valgrind() -> bool { false }
|
||||
|
||||
#[cfg(unix)]
|
||||
fn on_valgrind() -> bool {
|
||||
use libc::uintptr_t;
|
||||
extern {
|
||||
fn rust_running_on_valgrind() -> uintptr_t;
|
||||
}
|
||||
unsafe { rust_running_on_valgrind() != 0 }
|
||||
}
|
||||
unsafe { rust_running_on_valgrind() != 0 }
|
||||
}
|
||||
|
||||
/// Valgrind has a fixed-sized array (size around 2000) of segment descriptors
|
||||
|
@ -12,8 +12,8 @@
|
||||
//! the standard library This varies per-platform, but these libraries are
|
||||
//! necessary for running libstd.
|
||||
|
||||
// All platforms need to link to rustrt
|
||||
#[cfg(not(test))]
|
||||
// A few small shims in C that haven't been translated to Rust yet
|
||||
#[cfg(all(not(test), not(windows)))]
|
||||
#[link(name = "rust_builtin", kind = "static")]
|
||||
extern {}
|
||||
|
||||
|
@ -872,7 +872,7 @@ fn run_tests<F>(opts: &TestOpts,
|
||||
|
||||
#[allow(deprecated)]
|
||||
fn get_concurrency() -> usize {
|
||||
match env::var("RUST_TEST_THREADS") {
|
||||
return match env::var("RUST_TEST_THREADS") {
|
||||
Ok(s) => {
|
||||
let opt_n: Option<usize> = s.parse().ok();
|
||||
match opt_n {
|
||||
@ -884,10 +884,24 @@ fn get_concurrency() -> usize {
|
||||
if std::rt::util::limit_thread_creation_due_to_osx_and_valgrind() {
|
||||
1
|
||||
} else {
|
||||
extern { fn rust_get_num_cpus() -> libc::uintptr_t; }
|
||||
unsafe { rust_get_num_cpus() as usize }
|
||||
num_cpus()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#[cfg(windows)]
|
||||
fn num_cpus() -> usize {
|
||||
unsafe {
|
||||
let mut sysinfo = std::mem::zeroed();
|
||||
libc::GetSystemInfo(&mut sysinfo);
|
||||
sysinfo.dwNumberOfProcessors as usize
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn num_cpus() -> usize {
|
||||
extern { fn rust_get_num_cpus() -> libc::uintptr_t; }
|
||||
unsafe { rust_get_num_cpus() as usize }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#if !defined(_WIN32)
|
||||
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
@ -15,7 +17,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <dirent.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
@ -23,12 +24,6 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <TargetConditionals.h>
|
||||
@ -41,17 +36,8 @@
|
||||
|
||||
/* Foreign builtins. */
|
||||
//include valgrind.h after stdint.h so that uintptr_t is defined for msys2 w64
|
||||
#ifndef _WIN32
|
||||
#include "valgrind/valgrind.h"
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# define RUST_BUILTIN_API __declspec(dllexport)
|
||||
#else
|
||||
# define RUST_BUILTIN_API
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
char*
|
||||
rust_list_dir_val(struct dirent* entry_ptr) {
|
||||
return entry_ptr->d_name;
|
||||
@ -92,17 +78,8 @@ int
|
||||
rust_dirent_t_size() {
|
||||
return sizeof(struct dirent);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
int
|
||||
get_num_cpus() {
|
||||
SYSTEM_INFO sysinfo;
|
||||
GetSystemInfo(&sysinfo);
|
||||
|
||||
return (int) sysinfo.dwNumberOfProcessors;
|
||||
}
|
||||
#elif defined(__BSD__)
|
||||
#if defined(__BSD__)
|
||||
int
|
||||
get_num_cpus() {
|
||||
/* swiped from http://stackoverflow.com/questions/150355/
|
||||
@ -136,7 +113,6 @@ get_num_cpus() {
|
||||
}
|
||||
#endif
|
||||
|
||||
RUST_BUILTIN_API
|
||||
uintptr_t
|
||||
rust_get_num_cpus() {
|
||||
return get_num_cpus();
|
||||
@ -144,11 +120,7 @@ rust_get_num_cpus() {
|
||||
|
||||
uintptr_t
|
||||
rust_running_on_valgrind() {
|
||||
#ifdef _WIN32
|
||||
return 0;
|
||||
#else
|
||||
return RUNNING_ON_VALGRIND;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(__DragonFly__)
|
||||
@ -484,6 +456,8 @@ const char * rust_current_exe() {
|
||||
|
||||
#endif
|
||||
|
||||
#endif // !defined(_WIN32)
|
||||
|
||||
//
|
||||
// Local Variables:
|
||||
// mode: C++
|
||||
|
Loading…
x
Reference in New Issue
Block a user