File tree 2 files changed +9
-0
lines changed
2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ use core::usize;
21
21
pub use core:: alloc:: * ;
22
22
23
23
extern "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.
24
28
#[ allocator]
25
29
#[ rustc_allocator_nounwind]
26
30
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::*;
142
142
#[ derive( Debug , Copy , Clone ) ]
143
143
pub struct System ;
144
144
145
+ // The Alloc impl just forwards to the GlobalAlloc impl, which is in `std::sys::*::alloc`.
145
146
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
146
147
unsafe impl Alloc for System {
147
148
#[ inline]
@@ -226,6 +227,10 @@ pub fn rust_oom(layout: Layout) -> ! {
226
227
#[ unstable( feature = "alloc_internals" , issue = "0" ) ]
227
228
pub mod __default_lib_allocator {
228
229
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
+
229
234
// for symbol names src/librustc/middle/allocator.rs
230
235
// for signatures src/librustc_allocator/lib.rs
231
236
You can’t perform that action at this time.
0 commit comments