diff options
| author | mark <markm@cs.wisc.edu> | 2020-06-11 21:31:49 -0500 | 
|---|---|---|
| committer | mark <markm@cs.wisc.edu> | 2020-07-27 19:51:13 -0500 | 
| commit | 2c31b45ae878b821975c4ebd94cc1e49f6073fd0 (patch) | |
| tree | 14f64e683e3f64dcbcfb8c2c7cb45ac7592e6e09 /src/libstd/sys_common/alloc.rs | |
| parent | 9be8ffcb0206fc1558069a7b4766090df7877659 (diff) | |
| download | rust-2c31b45ae878b821975c4ebd94cc1e49f6073fd0.tar.gz rust-2c31b45ae878b821975c4ebd94cc1e49f6073fd0.zip | |
mv std libs to library/
Diffstat (limited to 'src/libstd/sys_common/alloc.rs')
| -rw-r--r-- | src/libstd/sys_common/alloc.rs | 46 | 
1 files changed, 0 insertions, 46 deletions
| diff --git a/src/libstd/sys_common/alloc.rs b/src/libstd/sys_common/alloc.rs deleted file mode 100644 index c6694100785..00000000000 --- a/src/libstd/sys_common/alloc.rs +++ /dev/null @@ -1,46 +0,0 @@ -#![allow(dead_code)] - -use crate::alloc::{GlobalAlloc, Layout, System}; -use crate::cmp; -use crate::ptr; - -// The minimum alignment guaranteed by the architecture. This value is used to -// add fast paths for low alignment values. -#[cfg(all(any( - target_arch = "x86", - target_arch = "arm", - target_arch = "mips", - target_arch = "powerpc", - target_arch = "powerpc64", - target_arch = "asmjs", - target_arch = "wasm32", - target_arch = "hexagon" -)))] -pub const MIN_ALIGN: usize = 8; -#[cfg(all(any( - target_arch = "x86_64", - target_arch = "aarch64", - target_arch = "mips64", - target_arch = "s390x", - target_arch = "sparc64", - target_arch = "riscv64" -)))] -pub const MIN_ALIGN: usize = 16; - -pub unsafe fn realloc_fallback( - alloc: &System, - ptr: *mut u8, - old_layout: Layout, - new_size: usize, -) -> *mut u8 { - // Docs for GlobalAlloc::realloc require this to be valid: - let new_layout = Layout::from_size_align_unchecked(new_size, old_layout.align()); - - let new_ptr = GlobalAlloc::alloc(alloc, new_layout); - if !new_ptr.is_null() { - let size = cmp::min(old_layout.size(), new_size); - ptr::copy_nonoverlapping(ptr, new_ptr, size); - GlobalAlloc::dealloc(alloc, ptr, old_layout); - } - new_ptr -} | 
