Make use of unstable alloc_jemalloc crate optional

This commit is contained in:
Simon Sapin 2017-10-12 01:36:34 +02:00
parent d9a311963f
commit d6d772eba0
4 changed files with 18 additions and 11 deletions

View file

@ -9,6 +9,9 @@ publish = false
name = "profile" name = "profile"
path = "lib.rs" path = "lib.rs"
[features]
unstable = []
[dependencies] [dependencies]
profile_traits = {path = "../profile_traits"} profile_traits = {path = "../profile_traits"}
influent = "0.4" influent = "0.4"

View file

@ -2,16 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![cfg_attr(not(target_os = "windows"), feature(alloc_jemalloc))] #![cfg_attr(all(feature = "unstable", not(target_os = "windows")), feature(alloc_jemalloc))]
#![deny(unsafe_code)] #![deny(unsafe_code)]
#[allow(unused_extern_crates)] #[allow(unused_extern_crates)]
#[cfg(not(target_os = "windows"))] #[cfg(all(feature = "unstable", not(target_os = "windows")))]
extern crate alloc_jemalloc; extern crate alloc_jemalloc;
extern crate heartbeats_simple; extern crate heartbeats_simple;
extern crate influent; extern crate influent;
extern crate ipc_channel; extern crate ipc_channel;
#[allow(unused_extern_crates)]
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
extern crate libc; extern crate libc;
#[macro_use] #[macro_use]

View file

@ -353,14 +353,16 @@ impl ReportsForest {
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
mod system_reporter { mod system_reporter {
#[cfg(not(target_os = "windows"))] #[cfg(all(feature = "unstable", not(target_os = "windows")))]
use libc::{c_char, c_int, c_void, size_t}; use libc::{c_char, c_void, size_t};
#[cfg(target_os = "linux")]
use libc::c_int;
use profile_traits::mem::{Report, ReportKind, ReporterRequest}; use profile_traits::mem::{Report, ReportKind, ReporterRequest};
#[cfg(not(target_os = "windows"))] #[cfg(all(feature = "unstable", not(target_os = "windows")))]
use std::ffi::CString; use std::ffi::CString;
#[cfg(not(target_os = "windows"))] #[cfg(all(feature = "unstable", not(target_os = "windows")))]
use std::mem::size_of; use std::mem::size_of;
#[cfg(not(target_os = "windows"))] #[cfg(all(feature = "unstable", not(target_os = "windows")))]
use std::ptr::null_mut; use std::ptr::null_mut;
use super::{JEMALLOC_HEAP_ALLOCATED_STR, SYSTEM_HEAP_ALLOCATED_STR}; use super::{JEMALLOC_HEAP_ALLOCATED_STR, SYSTEM_HEAP_ALLOCATED_STR};
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
@ -457,14 +459,14 @@ mod system_reporter {
None None
} }
#[cfg(not(target_os = "windows"))] #[cfg(all(feature = "unstable", not(target_os = "windows")))]
extern { extern {
#[cfg_attr(any(target_os = "macos", target_os = "android"), link_name = "je_mallctl")] #[cfg_attr(any(target_os = "macos", target_os = "android"), link_name = "je_mallctl")]
fn mallctl(name: *const c_char, oldp: *mut c_void, oldlenp: *mut size_t, fn mallctl(name: *const c_char, oldp: *mut c_void, oldlenp: *mut size_t,
newp: *mut c_void, newlen: size_t) -> c_int; newp: *mut c_void, newlen: size_t) -> ::libc::c_int;
} }
#[cfg(not(target_os = "windows"))] #[cfg(all(feature = "unstable", not(target_os = "windows")))]
fn jemalloc_stat(value_name: &str) -> Option<usize> { fn jemalloc_stat(value_name: &str) -> Option<usize> {
// Before we request the measurement of interest, we first send an "epoch" // Before we request the measurement of interest, we first send an "epoch"
// request. Without that jemalloc gives cached statistics(!) which can be // request. Without that jemalloc gives cached statistics(!) which can be
@ -500,7 +502,7 @@ mod system_reporter {
Some(value as usize) Some(value as usize)
} }
#[cfg(target_os = "windows")] #[cfg(any(target_os = "windows", not(feature = "unstable")))]
fn jemalloc_stat(_value_name: &str) -> Option<usize> { fn jemalloc_stat(_value_name: &str) -> Option<usize> {
None None
} }

View file

@ -26,6 +26,7 @@ unstable = [
"compositing/unstable", "compositing/unstable",
"constellation/unstable", "constellation/unstable",
"gfx/unstable", "gfx/unstable",
"profile/unstable",
] ]
[dependencies] [dependencies]