Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure jemalloc features properly #161

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions jemalloc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,24 +303,34 @@ fn main() {

cmd.arg("--with-private-namespace=_rjem_");

// Always pass explicit --enable or --disable so changes in jemalloc
// defaults don't break us.
if env::var("CARGO_FEATURE_DEBUG").is_ok() {
info!("CARGO_FEATURE_DEBUG set");
cmd.arg("--enable-debug");
} else {
cmd.arg("--disable-debug");
}

if env::var("CARGO_FEATURE_PROFILING").is_ok() {
info!("CARGO_FEATURE_PROFILING set");
cmd.arg("--enable-prof");
} else {
cmd.arg("--disable-prof");
}

if env::var("CARGO_FEATURE_STATS").is_ok() {
info!("CARGO_FEATURE_STATS set");
cmd.arg("--enable-stats");
} else {
cmd.arg("--disable-stats");
}

if env::var("CARGO_FEATURE_DISABLE_INITIAL_EXEC_TLS").is_ok() {
info!("CARGO_FEATURE_DISABLE_INITIAL_EXEC_TLS set");
cmd.arg("--disable-initial-exec-tls");
} else {
cmd.arg("--enable-initial-exec-tls");
}

cmd.arg(format!("--host={}", gnu_target(&target)));
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ unsafe impl GlobalAlloc for Jemalloc {

#[inline]
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
assume!(!ptr.is_null())
assume!(!ptr.is_null());
assume!(layout.size() != 0);
let flags = layout_to_flags(layout.align(), layout.size());
ffi::sdallocx(ptr as *mut c_void, layout.size(), flags)
Expand Down