aboutsummaryrefslogtreecommitdiff
path: root/ctr-std/src/alloc.rs
diff options
context:
space:
mode:
authorFenrirWolf <[email protected]>2018-04-21 16:39:03 -0600
committerGitHub <[email protected]>2018-04-21 16:39:03 -0600
commit159b5b9e62ce074bbbd1900137670a9f5426a8bd (patch)
tree4fecd0ca00b754c494e96b13e9837db48de93109 /ctr-std/src/alloc.rs
parentMove more implementation details to `imp` module (diff)
parentUpdate for Rust nightly 2018-04-19 (diff)
downloadctru-rs-159b5b9e62ce074bbbd1900137670a9f5426a8bd.tar.xz
ctru-rs-159b5b9e62ce074bbbd1900137670a9f5426a8bd.zip
Merge pull request #64 from FenrirWolf/nightly-update
Update for Rust nightly 2018-04-19
Diffstat (limited to 'ctr-std/src/alloc.rs')
-rw-r--r--ctr-std/src/alloc.rs121
1 files changed, 121 insertions, 0 deletions
diff --git a/ctr-std/src/alloc.rs b/ctr-std/src/alloc.rs
new file mode 100644
index 0000000..ff578ec
--- /dev/null
+++ b/ctr-std/src/alloc.rs
@@ -0,0 +1,121 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! dox
+
+#![unstable(issue = "32838", feature = "allocator_api")]
+
+#[doc(inline)] #[allow(deprecated)] pub use alloc_crate::alloc::Heap;
+#[doc(inline)] pub use alloc_crate::alloc::Global;
+#[doc(inline)] pub use alloc_system::System;
+#[doc(inline)] pub use core::alloc::*;
+
+#[cfg(not(test))]
+#[doc(hidden)]
+#[allow(unused_attributes)]
+pub mod __default_lib_allocator {
+ use super::{System, Layout, GlobalAlloc, Opaque};
+ // for symbol names src/librustc/middle/allocator.rs
+ // for signatures src/librustc_allocator/lib.rs
+
+ // linkage directives are provided as part of the current compiler allocator
+ // ABI
+
+ #[no_mangle]
+ #[rustc_std_internal_symbol]
+ pub unsafe extern fn __rdl_alloc(size: usize, align: usize) -> *mut u8 {
+ let layout = Layout::from_size_align_unchecked(size, align);
+ 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,
+ size: usize,
+ align: usize) {
+ System.dealloc(ptr as *mut Opaque, Layout::from_size_align_unchecked(size, align))
+ }
+
+ #[no_mangle]
+ #[rustc_std_internal_symbol]
+ pub unsafe extern fn __rdl_realloc(ptr: *mut u8,
+ old_size: usize,
+ align: usize,
+ new_size: usize) -> *mut u8 {
+ let old_layout = Layout::from_size_align_unchecked(old_size, align);
+ System.realloc(ptr as *mut Opaque, old_layout, new_size) as *mut u8
+ }
+
+ #[no_mangle]
+ #[rustc_std_internal_symbol]
+ pub unsafe extern fn __rdl_alloc_zeroed(size: usize, align: usize) -> *mut u8 {
+ let layout = Layout::from_size_align_unchecked(size, align);
+ System.alloc_zeroed(layout) as *mut u8
+ }
+
+ #[cfg(stage0)]
+ pub mod stage0 {
+ #[no_mangle]
+ #[rustc_std_internal_symbol]
+ pub unsafe extern fn __rdl_usable_size(_layout: *const u8,
+ _min: *mut usize,
+ _max: *mut usize) {
+ unimplemented!()
+ }
+
+ #[no_mangle]
+ #[rustc_std_internal_symbol]
+ pub unsafe extern fn __rdl_alloc_excess(_size: usize,
+ _align: usize,
+ _excess: *mut usize,
+ _err: *mut u8) -> *mut u8 {
+ unimplemented!()
+ }
+
+ #[no_mangle]
+ #[rustc_std_internal_symbol]
+ pub unsafe extern fn __rdl_realloc_excess(_ptr: *mut u8,
+ _old_size: usize,
+ _old_align: usize,
+ _new_size: usize,
+ _new_align: usize,
+ _excess: *mut usize,
+ _err: *mut u8) -> *mut u8 {
+ unimplemented!()
+ }
+
+ #[no_mangle]
+ #[rustc_std_internal_symbol]
+ pub unsafe extern fn __rdl_grow_in_place(_ptr: *mut u8,
+ _old_size: usize,
+ _old_align: usize,
+ _new_size: usize,
+ _new_align: usize) -> u8 {
+ unimplemented!()
+ }
+
+ #[no_mangle]
+ #[rustc_std_internal_symbol]
+ pub unsafe extern fn __rdl_shrink_in_place(_ptr: *mut u8,
+ _old_size: usize,
+ _old_align: usize,
+ _new_size: usize,
+ _new_align: usize) -> u8 {
+ unimplemented!()
+ }
+
+ }
+}