std: Refactor liballoc out of lib{std,sync}

This commit is part of the libstd facade RFC, issue #13851. This creates a new
library, liballoc, which is intended to be the core allocation library for all
of Rust. It is pinned on the basic assumption that an allocation failure is an
abort or failure.

This module has inherited the heap/libc_heap modules from std::rt, the owned/rc
modules from std, and the arc module from libsync. These three pointers are
currently the three most core pointer implementations in Rust.

The UnsafeArc type in std::sync should be considered deprecated and replaced by
Arc<Unsafe<T>>. This commit does not currently migrate to this type, but future
commits will continue this refactoring.
This commit is contained in:
Alex Crichton
2014-05-13 16:10:05 -07:00
parent 3da5a5cd18
commit 639759b7f4
16 changed files with 218 additions and 84 deletions

View File

@@ -26,23 +26,6 @@ use slice::ImmutableVector;
// FIXME: Once the runtime matures remove the `true` below to turn off rtassert, etc.
pub static ENFORCE_SANITY: bool = true || !cfg!(rtopt) || cfg!(rtdebug) || cfg!(rtassert);
#[deprecated]
#[doc(hidden)]
#[inline]
pub fn get_box_size(body_size: uint, body_align: uint) -> uint {
let header_size = ::mem::size_of::<::raw::Box<()>>();
let total_size = align_to(header_size, body_align) + body_size;
total_size
}
// Rounds |size| to the nearest |alignment|. Invariant: |alignment| is a power
// of two.
#[inline]
fn align_to(size: uint, align: uint) -> uint {
assert!(align != 0);
(size + align - 1) & !(align - 1)
}
/// Get the number of cores available
pub fn num_cpus() -> uint {
unsafe {