mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Use Rust ABI for __rust_start_panic
and _{rdl,rg}_oom
This commit is contained in:
parent
6dd68402c5
commit
68f063bf3f
@ -398,13 +398,13 @@ pub mod __alloc_error_handler {
|
||||
|
||||
// if there is no `#[alloc_error_handler]`
|
||||
#[rustc_std_internal_symbol]
|
||||
pub unsafe extern "C-unwind" fn __rdl_oom(size: usize, _align: usize) -> ! {
|
||||
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
|
||||
panic!("memory allocation of {size} bytes failed")
|
||||
}
|
||||
|
||||
// if there is an `#[alloc_error_handler]`
|
||||
#[rustc_std_internal_symbol]
|
||||
pub unsafe extern "C-unwind" fn __rg_oom(size: usize, align: usize) -> ! {
|
||||
pub unsafe fn __rg_oom(size: usize, align: usize) -> ! {
|
||||
let layout = unsafe { Layout::from_size_align_unchecked(size, align) };
|
||||
extern "Rust" {
|
||||
#[lang = "oom"]
|
||||
|
@ -30,7 +30,7 @@ pub unsafe extern "C" fn __rust_panic_cleanup(_: *mut u8) -> *mut (dyn Any + Sen
|
||||
|
||||
// "Leak" the payload and shim to the relevant abort on the platform in question.
|
||||
#[rustc_std_internal_symbol]
|
||||
pub unsafe extern "C-unwind" fn __rust_start_panic(_payload: *mut &mut dyn BoxMeUp) -> u32 {
|
||||
pub unsafe fn __rust_start_panic(_payload: *mut &mut dyn BoxMeUp) -> u32 {
|
||||
// Android has the ability to attach a message as part of the abort.
|
||||
#[cfg(target_os = "android")]
|
||||
android::android_set_abort_message(_payload);
|
||||
|
@ -104,7 +104,7 @@ pub unsafe extern "C" fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any
|
||||
// Entry point for raising an exception, just delegates to the platform-specific
|
||||
// implementation.
|
||||
#[rustc_std_internal_symbol]
|
||||
pub unsafe extern "C-unwind" fn __rust_start_panic(payload: *mut &mut dyn BoxMeUp) -> u32 {
|
||||
pub unsafe fn __rust_start_panic(payload: *mut &mut dyn BoxMeUp) -> u32 {
|
||||
let payload = Box::from_raw((*payload).take_box());
|
||||
|
||||
imp::panic(payload)
|
||||
|
@ -47,7 +47,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
extern "C-unwind" {
|
||||
extern "Rust" {
|
||||
/// `payload` is passed through another layer of raw pointers as `&mut dyn Trait` is not
|
||||
/// FFI-safe. `BoxMeUp` lazily performs allocation only when needed (this avoids allocations
|
||||
/// when using the "abort" panic runtime).
|
||||
|
Loading…
Reference in New Issue
Block a user