From f67a7227b7052608a23d1e324c29f8ec6addf58a Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 26 Dec 2014 01:38:07 +0100 Subject: [PATCH 1/5] liballoc does not need liblibc under certain configurations --- src/liballoc/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index ba6e89cdd76..3de77b05228 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -69,6 +69,8 @@ #[macro_use] extern crate core; + +#[cfg(all(not(external_funcs), not(external_crate)))] extern crate libc; // Allow testing this library From efaa43ade5cbc6636c955581384324c8f7ace940 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 26 Dec 2014 23:28:04 +0100 Subject: [PATCH 2/5] liballoc's "external_funcs" and "external_crate" are now features This allows the vanilla libary to built for kernel use with Cargo. --- src/liballoc/heap.rs | 10 +++++----- src/liballoc/lib.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index c57435cdc8c..1df06520549 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -124,7 +124,7 @@ const MIN_ALIGN: uint = 8; target_arch = "aarch64"))] const MIN_ALIGN: uint = 16; -#[cfg(external_funcs)] +#[cfg(feature = "external_funcs")] mod imp { extern { fn rust_allocate(size: uint, align: uint) -> *mut u8; @@ -169,14 +169,14 @@ mod imp { } } -#[cfg(external_crate)] +#[cfg(feature = "external_crate")] mod imp { extern crate external; pub use self::external::{allocate, deallocate, reallocate_inplace, reallocate}; pub use self::external::{usable_size, stats_print}; } -#[cfg(all(not(external_funcs), not(external_crate), jemalloc))] +#[cfg(all(not(feature = "external_funcs"), not(feature = "external_crate"), jemalloc))] mod imp { use core::option::Option; use core::option::Option::None; @@ -253,7 +253,7 @@ mod imp { } } -#[cfg(all(not(external_funcs), not(external_crate), not(jemalloc), unix))] +#[cfg(all(not(feature = "external_funcs"), not(feature = "external_crate"), not(jemalloc), unix))] mod imp { use core::cmp; use core::ptr; @@ -314,7 +314,7 @@ mod imp { pub fn stats_print() {} } -#[cfg(all(not(external_funcs), not(external_crate), not(jemalloc), windows))] +#[cfg(all(not(feature = "external_funcs"), not(feature = "external_crate"), not(jemalloc), windows))] mod imp { use libc::{c_void, size_t}; use libc; diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 3de77b05228..72509d34f29 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -70,7 +70,7 @@ #[macro_use] extern crate core; -#[cfg(all(not(external_funcs), not(external_crate)))] +#[cfg(all(not(feature = "external_funcs"), not(feature = "external_crate")))] extern crate libc; // Allow testing this library From 2b84e44b077339e175103979c1c6d4c26b235119 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 27 Dec 2014 00:09:04 +0100 Subject: [PATCH 3/5] Shorten cfg line lengths in liballoc --- src/liballoc/heap.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 1df06520549..69aeaf44793 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -176,7 +176,9 @@ mod imp { pub use self::external::{usable_size, stats_print}; } -#[cfg(all(not(feature = "external_funcs"), not(feature = "external_crate"), jemalloc))] +#[cfg(all(not(feature = "external_funcs"), + not(feature = "external_crate"), + jemalloc))] mod imp { use core::option::Option; use core::option::Option::None; @@ -253,7 +255,10 @@ mod imp { } } -#[cfg(all(not(feature = "external_funcs"), not(feature = "external_crate"), not(jemalloc), unix))] +#[cfg(all(not(feature = "external_funcs"), + not(feature = "external_crate"), + not(jemalloc), + unix))] mod imp { use core::cmp; use core::ptr; @@ -314,7 +319,10 @@ mod imp { pub fn stats_print() {} } -#[cfg(all(not(feature = "external_funcs"), not(feature = "external_crate"), not(jemalloc), windows))] +#[cfg(all(not(feature = "external_funcs"), + not(feature = "external_crate"), + not(jemalloc), + windows))] mod imp { use libc::{c_void, size_t}; use libc; From ea9d5c96536059b232dd6aa40af7a1d181f7b196 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 27 Dec 2014 00:34:51 +0100 Subject: [PATCH 4/5] liballoc's "extern_funcs" impl mod had a duplicate and missing item --- src/liballoc/heap.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 69aeaf44793..14ba5437565 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -142,14 +142,13 @@ mod imp { } #[inline] - pub unsafe fn reallocate_inplace(ptr: *mut u8, old_size: uint, size: uint, - align: uint) -> uint { - rust_reallocate_inplace(ptr, old_size, size, align) + pub unsafe fn deallocate(ptr: *mut u8, old_size: uint, align: uint) { + rust_deallocate(ptr, old_size, align) } #[inline] - pub unsafe fn deallocate(ptr: *mut u8, old_size: uint, align: uint) { - rust_deallocate(ptr, old_size, align) + pub unsafe fn reallocate(ptr: *mut u8, old_size: uint, size: uint, align: uint) -> *mut u8 { + rust_reallocate(ptr, old_size, size, align) } #[inline] From b1b4bc90b8a1d2fc73b76cbbd0104f6c1acee33f Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 30 Dec 2014 06:13:08 +0100 Subject: [PATCH 5/5] Fix warning in liballoc about unused constant MIN_ALIGN when cfg(feature = external_*) --- src/liballoc/heap.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 14ba5437565..439bb6c55dc 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -115,13 +115,17 @@ unsafe fn exchange_free(ptr: *mut u8, old_size: uint, align: uint) { // The minimum alignment guaranteed by the architecture. This value is used to // add fast paths for low alignment values. In practice, the alignment is a // constant at the call site and the branch will be optimized out. -#[cfg(any(target_arch = "arm", - target_arch = "mips", - target_arch = "mipsel"))] +#[cfg(all(not(feature = "external_funcs"), + not(feature = "external_crate"), + any(target_arch = "arm", + target_arch = "mips", + target_arch = "mipsel")))] const MIN_ALIGN: uint = 8; -#[cfg(any(target_arch = "x86", - target_arch = "x86_64", - target_arch = "aarch64"))] +#[cfg(all(not(feature = "external_funcs"), + not(feature = "external_crate"), + any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "aarch64"))] const MIN_ALIGN: uint = 16; #[cfg(feature = "external_funcs")]