#![feature(linkage)]
#![allow(internal_features)]
#![feature(rustc_attrs)]
#[cfg(RUST_ALLOCATOR_USES_ALLOCATOR_IMPLS_H)]
mod cpp_allocator {
use allocator_impls_ffi::root::rust_allocator_internal as ffi;
use std::alloc::{GlobalAlloc, Layout};
struct Allocator;
unsafe impl GlobalAlloc for Allocator {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
unsafe { ffi::alloc(layout.size(), layout.align()) }
}
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
unsafe {
ffi::dealloc(ptr, layout.size(), layout.align());
}
}
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
unsafe { ffi::alloc_zeroed(layout.size(), layout.align()) }
}
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
unsafe { ffi::realloc(ptr, layout.size(), layout.align(), new_size) }
}
}
#[global_allocator]
static GLOBAL: Allocator = Allocator;
}
#[cfg(not(RUST_ALLOCATOR_USES_ALLOCATOR_IMPLS_H))]
mod rust_allocator {
#[global_allocator]
static GLOBAL: std::alloc::System = std::alloc::System;
}
mod both_allocators {
use alloc_error_handler_impl_ffi::root::rust_allocator_internal as ffi;
#[rustc_std_internal_symbol]
#[linkage = "weak"]
fn __rust_no_alloc_shim_is_unstable_v2() {}
#[cfg(not(RUST_ALLOCATOR_NIGHTLY_CAPABILITY))]
#[rustc_std_internal_symbol]
#[linkage = "weak"]
fn __rust_no_alloc_shim_is_unstable() {}
#[rustc_std_internal_symbol]
#[linkage = "weak"]
fn __rust_alloc_error_handler_should_panic_v2() -> u8 {
0
}
#[cfg(not(RUST_ALLOCATOR_NIGHTLY_CAPABILITY))]
#[rustc_std_internal_symbol]
#[linkage = "weak"]
fn __rust_alloc_error_handler_should_panic() -> u8 {
0
}
#[rustc_std_internal_symbol]
#[allow(non_upper_case_globals)]
#[linkage = "weak"]
fn __rust_alloc_error_handler(_size: usize, _align: usize) {
unsafe { ffi::alloc_error_handler_impl() }
}
}