File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ use core::usize;
2121pub use core:: alloc:: * ;
2222
2323extern "Rust" {
24+ // These are the magic symbols to call the global allocator. rustc generates
25+ // them from the `#[global_allocator]` attribute if there is one, or uses the
26+ // default implementations in libstd (`__rdl_alloc` etc in `src/libstd/alloc.rs`)
27+ // otherwise.
2428 #[ allocator]
2529 #[ rustc_allocator_nounwind]
2630 fn __rust_alloc ( size : usize , align : usize ) -> * mut u8 ;
Original file line number Diff line number Diff line change @@ -142,6 +142,7 @@ pub use alloc_crate::alloc::*;
142142#[ derive( Debug , Copy , Clone ) ]
143143pub struct System ;
144144
145+ // The Alloc impl just forwards to the GlobalAlloc impl, which is in `std::sys::*::alloc`.
145146#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
146147unsafe impl Alloc for System {
147148 #[ inline]
@@ -226,6 +227,10 @@ pub fn rust_oom(layout: Layout) -> ! {
226227#[ unstable( feature = "alloc_internals" , issue = "0" ) ]
227228pub mod __default_lib_allocator {
228229 use super :: { System , Layout , GlobalAlloc } ;
230+ // These magic symbol names are used as a fallback for implementing the
231+ // `__rust_alloc` etc symbols (see `src/liballoc/alloc.rs) when there is
232+ // no `#[global_allocator]` attribute.
233+
229234 // for symbol names src/librustc/middle/allocator.rs
230235 // for signatures src/librustc_allocator/lib.rs
231236
You can’t perform that action at this time.
0 commit comments