name = "alloc_jemalloc"
version = "0.0.0"
dependencies = [
+ "alloc_system 0.0.0",
"build_helper 0.1.0",
"cc 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.0.0",
#[allocator]
#[rustc_allocator_nounwind]
fn __rust_alloc(size: usize, align: usize, err: *mut u8) -> *mut u8;
+ #[cold]
+ #[rustc_allocator_nounwind]
+ fn __rust_oom(err: *const u8) -> !;
#[rustc_allocator_nounwind]
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
#[rustc_allocator_nounwind]
#[allocator]
#[rustc_allocator_nounwind]
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
+ #[cold]
+ #[rustc_allocator_nounwind]
+ fn __rust_oom() -> !;
#[rustc_allocator_nounwind]
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
#[rustc_allocator_nounwind]
Err(AllocErr)
}
}
+
+ #[inline]
+ fn oom(&mut self) -> ! {
+ unsafe {
+ #[cfg(not(stage0))]
+ __rust_oom();
+ #[cfg(stage0)]
+ __rust_oom(&mut 0);
+ }
+ }
}
/// The allocator for unique pointers.
#![feature(from_ref)]
#![feature(fundamental)]
#![feature(lang_items)]
+#![feature(libc)]
#![feature(needs_allocator)]
#![feature(nonzero)]
#![feature(optin_builtin_traits)]
doc = false
[dependencies]
+alloc_system = { path = "../liballoc_system" }
core = { path = "../libcore" }
libc = { path = "../rustc/libc_shim" }
compiler_builtins = { path = "../rustc/compiler_builtins_shim" }
reason = "this library is unlikely to be stabilized in its current \
form or name",
issue = "27783")]
+#![feature(alloc_system)]
#![feature(libc)]
#![feature(linkage)]
#![feature(staged_api)]
#![cfg_attr(not(dummy_jemalloc), feature(allocator_api))]
#![rustc_alloc_kind = "exe"]
+extern crate alloc_system;
extern crate libc;
#[cfg(not(dummy_jemalloc))]
pub use contents::*;
#[cfg(not(dummy_jemalloc))]
mod contents {
+ use core::alloc::GlobalAlloc;
+ use alloc_system::System;
use libc::{c_int, c_void, size_t};
// Note that the symbols here are prefixed by default on macOS and Windows (we
ptr
}
+ #[no_mangle]
+ #[rustc_std_internal_symbol]
+ pub unsafe extern fn __rde_oom() -> ! {
+ System.oom()
+ }
+
#[no_mangle]
#[rustc_std_internal_symbol]
pub unsafe extern fn __rde_dealloc(ptr: *mut u8,
}
}
+#[inline]
fn oom() -> ! {
write_to_stderr("fatal runtime error: memory allocation failed");
unsafe {
}
#[cfg(any(unix, target_os = "redox"))]
+#[inline]
fn write_to_stderr(s: &str) {
extern crate libc;
}
#[cfg(windows)]
+#[inline]
fn write_to_stderr(s: &str) {
use core::ptr;
}
#[cfg(not(any(windows, unix, target_os = "redox")))]
+#[inline]
fn write_to_stderr(_: &str) {}
}
new_ptr
}
+
+ fn oom(&self) -> ! {
+ unsafe { ::intrinsics::abort() }
+ }
}
/// An implementation of `Alloc` can allocate, reallocate, and
}
AllocatorTy::ResultPtr |
+ AllocatorTy::Bang |
AllocatorTy::Unit => {
panic!("can't convert AllocatorTy to an argument")
}
(self.ptr_u8(), expr)
}
+ AllocatorTy::Bang => {
+ (self.cx.ty(self.span, TyKind::Never), expr)
+ }
+
AllocatorTy::Unit => {
(self.cx.ty(self.span, TyKind::Tup(Vec::new())), expr)
}
inputs: &[AllocatorTy::Layout],
output: AllocatorTy::ResultPtr,
},
+ AllocatorMethod {
+ name: "oom",
+ inputs: &[],
+ output: AllocatorTy::Bang,
+ },
AllocatorMethod {
name: "dealloc",
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout],
}
pub enum AllocatorTy {
+ Bang,
Layout,
Ptr,
ResultPtr,
AllocatorTy::Ptr => args.push(i8p),
AllocatorTy::Usize => args.push(usize),
+ AllocatorTy::Bang |
AllocatorTy::ResultPtr |
AllocatorTy::Unit => panic!("invalid allocator arg"),
}
}
let output = match method.output {
+ AllocatorTy::Bang => None,
AllocatorTy::ResultPtr => Some(i8p),
AllocatorTy::Unit => None,
System.alloc(layout) as *mut u8
}
+ #[no_mangle]
+ #[rustc_std_internal_symbol]
+ pub unsafe extern fn __rdl_oom() -> ! {
+ System.oom()
+ }
+
#[no_mangle]
#[rustc_std_internal_symbol]
pub unsafe extern fn __rdl_dealloc(ptr: *mut u8,
//~| the trait bound `usize:
//~| the trait bound `usize:
//~| the trait bound `usize:
+//~| the trait bound `usize:
fn main() {}