1
Fork 0

run rustfmt on liballoc_jemalloc folder

This commit is contained in:
Srinivas Reddy Thatiparthy 2016-06-05 11:39:17 +05:30
parent 382ab92cee
commit adf2c432dc
2 changed files with 26 additions and 14 deletions

View file

@ -33,18 +33,26 @@ fn main() {
jemalloc.parent().unwrap().display()); jemalloc.parent().unwrap().display());
let stem = jemalloc.file_stem().unwrap().to_str().unwrap(); let stem = jemalloc.file_stem().unwrap().to_str().unwrap();
let name = jemalloc.file_name().unwrap().to_str().unwrap(); let name = jemalloc.file_name().unwrap().to_str().unwrap();
let kind = if name.ends_with(".a") {"static"} else {"dylib"}; let kind = if name.ends_with(".a") {
"static"
} else {
"dylib"
};
println!("cargo:rustc-link-lib={}={}", kind, &stem[3..]); println!("cargo:rustc-link-lib={}={}", kind, &stem[3..]);
return return;
} }
let compiler = gcc::Config::new().get_compiler(); let compiler = gcc::Config::new().get_compiler();
let ar = build_helper::cc2ar(compiler.path(), &target); let ar = build_helper::cc2ar(compiler.path(), &target);
let cflags = compiler.args().iter().map(|s| s.to_str().unwrap()) let cflags = compiler.args()
.collect::<Vec<_>>().join(" "); .iter()
.map(|s| s.to_str().unwrap())
.collect::<Vec<_>>()
.join(" ");
let mut stack = src_dir.join("../jemalloc") let mut stack = src_dir.join("../jemalloc")
.read_dir().unwrap() .read_dir()
.unwrap()
.map(|e| e.unwrap()) .map(|e| e.unwrap())
.collect::<Vec<_>>(); .collect::<Vec<_>>();
while let Some(entry) = stack.pop() { while let Some(entry) = stack.pop() {
@ -57,7 +65,9 @@ fn main() {
} }
let mut cmd = Command::new("sh"); let mut cmd = Command::new("sh");
cmd.arg(src_dir.join("../jemalloc/configure").to_str().unwrap() cmd.arg(src_dir.join("../jemalloc/configure")
.to_str()
.unwrap()
.replace("C:\\", "/c/") .replace("C:\\", "/c/")
.replace("\\", "/")) .replace("\\", "/"))
.current_dir(&build_dir) .current_dir(&build_dir)
@ -119,7 +129,8 @@ fn main() {
run(Command::new("make") run(Command::new("make")
.current_dir(&build_dir) .current_dir(&build_dir)
.arg("build_lib_static") .arg("build_lib_static")
.arg("-j").arg(env::var("NUM_JOBS").unwrap())); .arg("-j")
.arg(env::var("NUM_JOBS").unwrap()));
if target.contains("windows") { if target.contains("windows") {
println!("cargo:rustc-link-lib=static=jemalloc"); println!("cargo:rustc-link-lib=static=jemalloc");

View file

@ -39,12 +39,12 @@ use libc::{c_int, c_void, size_t};
not(target_env = "musl")), not(target_env = "musl")),
link(name = "pthread"))] link(name = "pthread"))]
#[cfg(not(cargobuild))] #[cfg(not(cargobuild))]
extern {} extern "C" {}
// Note that the symbols here are prefixed by default on OSX and Windows (we // Note that the symbols here are prefixed by default on OSX and Windows (we
// don't explicitly request it), and on Android and DragonFly we explicitly // don't explicitly request it), and on Android and DragonFly we explicitly
// request it as unprefixing cause segfaults (mismatches in allocators). // request it as unprefixing cause segfaults (mismatches in allocators).
extern { extern "C" {
#[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
target_os = "dragonfly", target_os = "windows"), target_os = "dragonfly", target_os = "windows"),
link_name = "je_mallocx")] link_name = "je_mallocx")]
@ -136,8 +136,9 @@ pub extern "C" fn __rust_usable_size(size: usize, align: usize) -> usize {
// are available. // are available.
#[no_mangle] #[no_mangle]
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
pub extern fn pthread_atfork(_prefork: *mut u8, pub extern "C" fn pthread_atfork(_prefork: *mut u8,
_postfork_parent: *mut u8, _postfork_parent: *mut u8,
_postfork_child: *mut u8) -> i32 { _postfork_child: *mut u8)
-> i32 {
0 0
} }