From 6cd9b88a2559c1c8276275ab7a278827f949bfdd Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 9 Oct 2020 11:17:08 +0200 Subject: [PATCH 1/3] fix __rust_alloc_error_handler comment --- library/alloc/src/alloc.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index ce70de6ebdd63..f40bc2c96cffd 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -26,8 +26,6 @@ extern "Rust" { fn __rust_realloc(ptr: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8; #[rustc_allocator_nounwind] fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8; - #[rustc_allocator_nounwind] - fn __rust_alloc_error_handler(size: usize, align: usize) -> !; } /// The global memory allocator. @@ -323,6 +321,16 @@ pub(crate) unsafe fn box_free(ptr: Unique) { } } +// # Allocation error handler + +extern "Rust" { + // This is the magic symbol to call the global alloc error handler. rustc generates + // it to call `__rg_oom` if there is a `#[alloc_error_handler]`, or to call the + // default implementations below (`__rdl_oom`) otherwise. + #[rustc_allocator_nounwind] + fn __rust_alloc_error_handler(size: usize, align: usize) -> !; +} + /// Abort on memory allocation error or failure. /// /// Callers of memory allocation APIs wishing to abort computation From 1911d2186683e4b9818ea16225b4f909c6e2b070 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 9 Oct 2020 11:31:54 +0200 Subject: [PATCH 2/3] also extend global allocator comment --- library/alloc/src/alloc.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index f40bc2c96cffd..82c9e4482d5d5 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -14,8 +14,9 @@ mod tests; extern "Rust" { // These are the magic symbols to call the global allocator. rustc generates - // them from the `#[global_allocator]` attribute if there is one, or uses the - // default implementations in libstd (`__rdl_alloc` etc in `src/libstd/alloc.rs`) + // them to call `__rg_alloc` etc if there is a `#[global_allocator]` attribute + // (the code expanding that attribute macro generates those functions), or to call + // the default implementations in libstd (`__rdl_alloc` etc in `src/libstd/alloc.rs`) // otherwise. #[rustc_allocator] #[rustc_allocator_nounwind] From b6bedc80c9922833d92e81c6bf91eb5b24e11c86 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 9 Oct 2020 11:39:28 +0200 Subject: [PATCH 3/3] rename __default_lib_allocator -> __default_alloc_error_handler --- library/alloc/src/alloc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index 82c9e4482d5d5..4646d4a833525 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -376,7 +376,7 @@ pub fn handle_alloc_error(layout: Layout) -> ! { #[doc(hidden)] #[allow(unused_attributes)] #[unstable(feature = "alloc_internals", issue = "none")] -pub mod __default_lib_allocator { +pub mod __alloc_error_handler { use crate::alloc::Layout; // called via generated `__rust_alloc_error_handler`