File tree Expand file tree Collapse file tree 12 files changed +40
-68
lines changed Expand file tree Collapse file tree 12 files changed +40
-68
lines changed Original file line number Diff line number Diff line change @@ -2301,6 +2301,7 @@ dependencies = [
23012301name = " panic_abort"
23022302version = " 0.0.0"
23032303dependencies = [
2304+ " cfg-if" ,
23042305 " compiler_builtins" ,
23052306 " core" ,
23062307 " libc" ,
Original file line number Diff line number Diff line change @@ -14,3 +14,4 @@ doc = false
1414core = { path = " ../libcore" }
1515libc = { version = " 0.2" , default-features = false }
1616compiler_builtins = " 0.1.0"
17+ cfg-if = " 0.1.8"
Original file line number Diff line number Diff line change 2020
2121use core:: any:: Any ;
2222
23+ // We need the definition of TryPayload for __rust_panic_cleanup.
24+ include ! ( "../libpanic_unwind/payload.rs" ) ;
25+
2326#[ rustc_std_internal_symbol]
24- pub unsafe extern "C" fn __rust_panic_cleanup ( _: * mut u8 ) -> * mut ( dyn Any + Send + ' static ) {
27+ pub unsafe extern "C" fn __rust_panic_cleanup ( _: TryPayload ) -> * mut ( dyn Any + Send + ' static ) {
2528 unreachable ! ( )
2629}
2730
Original file line number Diff line number Diff line change @@ -6,8 +6,6 @@ use alloc::boxed::Box;
66use core:: any:: Any ;
77use core:: intrinsics;
88
9- pub type Payload = * mut u8 ;
10-
119pub unsafe fn cleanup ( _ptr : * mut u8 ) -> Box < dyn Any + Send > {
1210 intrinsics:: abort ( )
1311}
Original file line number Diff line number Diff line change @@ -48,8 +48,6 @@ static EXCEPTION_TYPE_INFO: TypeInfo = TypeInfo {
4848 name : b"rust_panic\0 " . as_ptr ( ) ,
4949} ;
5050
51- pub type Payload = * mut u8 ;
52-
5351pub unsafe fn cleanup ( ptr : * mut u8 ) -> Box < dyn Any + Send > {
5452 assert ! ( !ptr. is_null( ) ) ;
5553 let adjusted_ptr = __cxa_begin_catch ( ptr as * mut libc:: c_void ) ;
Original file line number Diff line number Diff line change @@ -81,8 +81,6 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
8181 }
8282}
8383
84- pub type Payload = * mut u8 ;
85-
8684pub unsafe fn cleanup ( ptr : * mut u8 ) -> Box < dyn Any + Send > {
8785 let my_ep = ptr as * mut Exception ;
8886 let cause = ( * my_ep) . cause . take ( ) ;
Original file line number Diff line number Diff line change @@ -6,8 +6,6 @@ use alloc::boxed::Box;
66use core:: any:: Any ;
77use core:: ptr;
88
9- pub type Payload = * mut u8 ;
10-
119pub unsafe fn cleanup ( _ptr : * mut u8 ) -> Box < dyn Any + Send > {
1210 extern "C" {
1311 pub fn __rust_abort ( ) -> !;
Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ use alloc::boxed::Box;
3434use core:: any:: Any ;
3535use core:: panic:: BoxMeUp ;
3636
37- // If adding to this list, you should also look at libstd::panicking's identical
38- // list of Payload types and likely add to there as well.
37+ // If adding to this list, you should also look at the list of TryPayload types
38+ // defined in payload.rs and likely add to there as well.
3939cfg_if:: cfg_if! {
4040 if #[ cfg( target_os = "emscripten" ) ] {
4141 #[ path = "emcc.rs" ]
@@ -61,12 +61,14 @@ cfg_if::cfg_if! {
6161 }
6262}
6363
64+ include ! ( "payload.rs" ) ;
65+
6466mod dwarf;
6567
6668#[ no_mangle]
67- pub unsafe extern "C" fn __rust_panic_cleanup ( payload : * mut u8 ) -> * mut ( dyn Any + Send + ' static ) {
68- let payload = payload as * mut imp :: Payload ;
69- let payload = * ( payload ) ;
69+ pub unsafe extern "C" fn __rust_panic_cleanup (
70+ payload : TryPayload ,
71+ ) -> * mut ( dyn Any + Send + ' static ) {
7072 Box :: into_raw ( imp:: cleanup ( payload) )
7173}
7274
Original file line number Diff line number Diff line change 1+ // Type definition for the payload argument of the try intrinsic.
2+ //
3+ // This must be kept in sync with the implementations of the try intrinsic.
4+ //
5+ // This file is included by both panic runtimes and libstd. It is part of the
6+ // panic runtime ABI.
7+ cfg_if:: cfg_if! {
8+ if #[ cfg( target_os = "emscripten" ) ] {
9+ type TryPayload = * mut u8 ;
10+ } else if #[ cfg( target_arch = "wasm32" ) ] {
11+ type TryPayload = * mut u8 ;
12+ } else if #[ cfg( target_os = "hermit" ) ] {
13+ type TryPayload = * mut u8 ;
14+ } else if #[ cfg( all( target_env = "msvc" , target_arch = "aarch64" ) ) ] {
15+ type TryPayload = * mut u8 ;
16+ } else if #[ cfg( target_env = "msvc" ) ] {
17+ type TryPayload = [ u64 ; 2 ] ;
18+ } else {
19+ type TryPayload = * mut u8 ;
20+ }
21+ }
Original file line number Diff line number Diff line change @@ -264,8 +264,6 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
264264 _CxxThrowException ( throw_ptr, & mut THROW_INFO as * mut _ as * mut _ ) ;
265265}
266266
267- pub type Payload = [ u64 ; 2 ] ;
268-
269267pub unsafe fn cleanup ( payload : [ u64 ; 2 ] ) -> Box < dyn Any + Send > {
270268 mem:: transmute ( raw:: TraitObject { data : payload[ 0 ] as * mut _ , vtable : payload[ 1 ] as * mut _ } )
271269}
You can’t perform that action at this time.
0 commit comments