diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2018-06-13 16:28:43 +0200 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2018-06-14 04:19:17 +0200 |
commit | c94c2b6f7684ee5430450d658e7d14ae0f19d700 (patch) | |
tree | 31c1ed7022d4550f5a70c5a6958bc52971670cef /components/allocator/lib.rs | |
parent | 5c4f54c4035d316eba55eda0186e2f2e010042d5 (diff) | |
download | servo-c94c2b6f7684ee5430450d658e7d14ae0f19d700.tar.gz servo-c94c2b6f7684ee5430450d658e7d14ae0f19d700.zip |
Upgrade to rustc 1.28.0-nightly (b68432d56 2018-06-12)
Diffstat (limited to 'components/allocator/lib.rs')
-rw-r--r-- | components/allocator/lib.rs | 47 |
1 files changed, 13 insertions, 34 deletions
diff --git a/components/allocator/lib.rs b/components/allocator/lib.rs index c2f2d9796a4..135bfd90edd 100644 --- a/components/allocator/lib.rs +++ b/components/allocator/lib.rs @@ -4,20 +4,17 @@ //! Selecting the default global allocator for Servo -#![cfg_attr(feature = "unstable", feature(global_allocator, allocator_api, alloc_system))] - -#[cfg(feature = "unstable")] #[global_allocator] static ALLOC: Allocator = Allocator; pub use platform::*; -#[cfg(all(feature = "unstable", not(windows)))] +#[cfg(not(windows))] mod platform { extern crate jemalloc_sys as ffi; - use std::alloc::{GlobalAlloc, Layout, Opaque}; + use std::alloc::{GlobalAlloc, Layout}; use std::os::raw::{c_int, c_void}; /// Get the size of a heap block. @@ -65,44 +62,43 @@ mod platform { unsafe impl GlobalAlloc for Allocator { #[inline] - unsafe fn alloc(&self, layout: Layout) -> *mut Opaque { + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { let flags = layout_to_flags(layout.align(), layout.size()); - ffi::mallocx(layout.size(), flags) as *mut Opaque + ffi::mallocx(layout.size(), flags) as *mut u8 } #[inline] - unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut Opaque { + unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() { - ffi::calloc(1, layout.size()) as *mut Opaque + ffi::calloc(1, layout.size()) as *mut u8 } else { let flags = layout_to_flags(layout.align(), layout.size()) | ffi::MALLOCX_ZERO; - ffi::mallocx(layout.size(), flags) as *mut Opaque + ffi::mallocx(layout.size(), flags) as *mut u8 } } #[inline] - unsafe fn dealloc(&self, ptr: *mut Opaque, layout: Layout) { + unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { let flags = layout_to_flags(layout.align(), layout.size()); ffi::sdallocx(ptr as *mut _, layout.size(), flags) } #[inline] unsafe fn realloc(&self, - ptr: *mut Opaque, + ptr: *mut u8, layout: Layout, - new_size: usize) -> *mut Opaque { + new_size: usize) -> *mut u8 { let flags = layout_to_flags(layout.align(), new_size); - ffi::rallocx(ptr as *mut _, new_size, flags) as *mut Opaque + ffi::rallocx(ptr as *mut _, new_size, flags) as *mut u8 } } } -#[cfg(all(feature = "unstable", windows))] +#[cfg(windows)] mod platform { - extern crate alloc_system; extern crate kernel32; - pub use self::alloc_system::System as Allocator; + pub use std::alloc::System as Allocator; use self::kernel32::{GetProcessHeap, HeapSize, HeapValidate}; use std::os::raw::c_void; @@ -117,20 +113,3 @@ mod platform { HeapSize(heap, 0, ptr) as usize } } - -#[cfg(not(feature = "unstable"))] -mod platform { - use std::os::raw::c_void; - - /// Without `#[global_allocator]` we cannot be certain of what allocator is used - /// or how it is linked. We therefore disable memory reporting. (Return zero.) - pub unsafe extern "C" fn usable_size(_ptr: *const c_void) -> usize { - 0 - } - - /// Memory allocation APIs compatible with libc - pub mod libc_compat { - extern crate libc; - pub use self::libc::{malloc, realloc, free}; - } -} |