Add a no_prefix feature
There are some targets that we still force a prefix since they have issues when their libc malloc is replaced in this way. Closes #39
This commit is contained in:
parent
607de93c67
commit
4f01b49922
|
@ -29,3 +29,4 @@ default = ["bg_thread"]
|
|||
profiling = ["jemalloc-sys/profiling"]
|
||||
debug = ["jemalloc-sys/debug"]
|
||||
bg_thread = ["jemalloc-sys/bg_thread"]
|
||||
no_prefix = ["jemalloc-sys/no_prefix"]
|
||||
|
|
|
@ -28,3 +28,4 @@ default = ["bg_thread"]
|
|||
profiling = []
|
||||
debug = []
|
||||
bg_thread = []
|
||||
no_prefix = []
|
||||
|
|
|
@ -173,7 +173,21 @@ fn main() {
|
|||
cmd.arg("--with-malloc-conf=background_thread:false");
|
||||
}
|
||||
|
||||
cmd.arg("--with-jemalloc-prefix=_rjem_");
|
||||
let mut use_prefix = !env::var_os("CARGO_FEATURE_NO_PREFIX").is_some();
|
||||
if !use_prefix &&
|
||||
(target.contains("android")
|
||||
|| target.contains("dragonfly")
|
||||
|| target.contains("musl")
|
||||
|| target.contains("darwin"))
|
||||
{
|
||||
println!("ignoring no_prefix feature on unsupported platform");
|
||||
use_prefix = true;
|
||||
}
|
||||
|
||||
if use_prefix {
|
||||
cmd.arg("--with-jemalloc-prefix=_rjem_");
|
||||
println!("cargo:rustc-cfg=prefixed");
|
||||
}
|
||||
|
||||
if env::var_os("CARGO_FEATURE_DEBUG").is_some() {
|
||||
println!("CARGO_FEATURE_DEBUG set");
|
||||
|
@ -181,7 +195,7 @@ fn main() {
|
|||
}
|
||||
|
||||
if env::var_os("CARGO_FEATURE_PROFILING").is_some() {
|
||||
println!("CARGO_FEATURE_PROFILING set set");
|
||||
println!("CARGO_FEATURE_PROFILING set");
|
||||
cmd.arg("--enable-prof");
|
||||
}
|
||||
cmd.arg(format!("--host={}", gnu_target(&target)));
|
||||
|
|
|
@ -18,48 +18,48 @@ pub const MALLOCX_ZERO: c_int = 0x40;
|
|||
|
||||
extern "C" {
|
||||
// Standard API
|
||||
#[link_name = "_rjem_malloc"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_malloc")]
|
||||
pub fn malloc(size: size_t) -> *mut c_void;
|
||||
#[link_name = "_rjem_calloc"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_calloc")]
|
||||
pub fn calloc(number: size_t, size: size_t) -> *mut c_void;
|
||||
#[link_name = "_rjem_posix_memalign"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_posix_memalign")]
|
||||
pub fn posix_memalign(ptr: *mut *mut c_void, alignment: size_t, size: size_t) -> c_int;
|
||||
#[link_name = "_rjem_aligned_alloc"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_aligned_alloc")]
|
||||
pub fn aligned_alloc(alignment: size_t, size: size_t) -> *mut c_void;
|
||||
#[link_name = "_rjem_realloc"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_realloc")]
|
||||
pub fn realloc(ptr: *mut c_void, size: size_t) -> *mut c_void;
|
||||
#[link_name = "_rjem_free"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_free")]
|
||||
pub fn free(ptr: *mut c_void);
|
||||
|
||||
// Non-standard API
|
||||
#[link_name = "_rjem_mallocx"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_mallocx")]
|
||||
pub fn mallocx(size: size_t, flags: c_int) -> *mut c_void;
|
||||
#[link_name = "_rjem_rallocx"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_rallocx")]
|
||||
pub fn rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void;
|
||||
#[link_name = "_rjem_xallocx"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_xallocx")]
|
||||
pub fn xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t;
|
||||
#[link_name = "_rjem_sallocx"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_sallocx")]
|
||||
pub fn sallocx(ptr: *const c_void, flags: c_int) -> size_t;
|
||||
#[link_name = "_rjem_dallocx"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_dallocx")]
|
||||
pub fn dallocx(ptr: *mut c_void, flags: c_int);
|
||||
#[link_name = "_rjem_sdallocx"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_sdallocx")]
|
||||
pub fn sdallocx(ptr: *mut c_void, size: size_t, flags: c_int);
|
||||
#[link_name = "_rjem_nallocx"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_nallocx")]
|
||||
pub fn nallocx(size: size_t, flags: c_int) -> size_t;
|
||||
#[link_name = "_rjem_malloc_usable_size"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_malloc_usable_size")]
|
||||
pub fn malloc_usable_size(ptr: *const c_void) -> size_t;
|
||||
|
||||
// mallctl
|
||||
#[link_name = "_rjem_mallctl"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_mallctl")]
|
||||
pub fn mallctl(name: *const c_char,
|
||||
oldp: *mut c_void,
|
||||
oldpenp: *mut size_t,
|
||||
newp: *mut c_void,
|
||||
newlen: size_t)
|
||||
-> c_int;
|
||||
#[link_name = "_rjem_mallctlnametomib"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_mallctlnametomib")]
|
||||
pub fn mallctlnametomib(name: *const c_char, mibp: *mut size_t, miblenp: *mut size_t) -> c_int;
|
||||
#[link_name = "_rjem_mallctlbymib"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_mallctlbymib")]
|
||||
pub fn mallctlbymib(mib: *const size_t,
|
||||
miblen: size_t,
|
||||
oldp: *mut c_void,
|
||||
|
@ -69,7 +69,7 @@ extern "C" {
|
|||
-> c_int;
|
||||
|
||||
// stats
|
||||
#[link_name = "_rjem_malloc_stats_print"]
|
||||
#[cfg_attr(prefixed, link_name = "_rjem_malloc_stats_print")]
|
||||
pub fn malloc_stats_print(write_cb: extern "C" fn(*mut c_void, *const c_char),
|
||||
cbopaque: *mut c_void,
|
||||
opts: *const c_char);
|
||||
|
|
Loading…
Reference in New Issue