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 = [
2301
2301
name = " panic_abort"
2302
2302
version = " 0.0.0"
2303
2303
dependencies = [
2304
+ " cfg-if" ,
2304
2305
" compiler_builtins" ,
2305
2306
" core" ,
2306
2307
" libc" ,
Original file line number Diff line number Diff line change @@ -14,3 +14,4 @@ doc = false
14
14
core = { path = " ../libcore" }
15
15
libc = { version = " 0.2" , default-features = false }
16
16
compiler_builtins = " 0.1.0"
17
+ cfg-if = " 0.1.8"
Original file line number Diff line number Diff line change 20
20
21
21
use core:: any:: Any ;
22
22
23
+ // We need the definition of TryPayload for __rust_panic_cleanup.
24
+ include ! ( "../libpanic_unwind/payload.rs" ) ;
25
+
23
26
#[ 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 ) {
25
28
unreachable ! ( )
26
29
}
27
30
Original file line number Diff line number Diff line change @@ -6,8 +6,6 @@ use alloc::boxed::Box;
6
6
use core:: any:: Any ;
7
7
use core:: intrinsics;
8
8
9
- pub type Payload = * mut u8 ;
10
-
11
9
pub unsafe fn cleanup ( _ptr : * mut u8 ) -> Box < dyn Any + Send > {
12
10
intrinsics:: abort ( )
13
11
}
Original file line number Diff line number Diff line change @@ -48,8 +48,6 @@ static EXCEPTION_TYPE_INFO: TypeInfo = TypeInfo {
48
48
name : b"rust_panic\0 " . as_ptr ( ) ,
49
49
} ;
50
50
51
- pub type Payload = * mut u8 ;
52
-
53
51
pub unsafe fn cleanup ( ptr : * mut u8 ) -> Box < dyn Any + Send > {
54
52
assert ! ( !ptr. is_null( ) ) ;
55
53
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 {
81
81
}
82
82
}
83
83
84
- pub type Payload = * mut u8 ;
85
-
86
84
pub unsafe fn cleanup ( ptr : * mut u8 ) -> Box < dyn Any + Send > {
87
85
let my_ep = ptr as * mut Exception ;
88
86
let cause = ( * my_ep) . cause . take ( ) ;
Original file line number Diff line number Diff line change @@ -6,8 +6,6 @@ use alloc::boxed::Box;
6
6
use core:: any:: Any ;
7
7
use core:: ptr;
8
8
9
- pub type Payload = * mut u8 ;
10
-
11
9
pub unsafe fn cleanup ( _ptr : * mut u8 ) -> Box < dyn Any + Send > {
12
10
extern "C" {
13
11
pub fn __rust_abort ( ) -> !;
Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ use alloc::boxed::Box;
34
34
use core:: any:: Any ;
35
35
use core:: panic:: BoxMeUp ;
36
36
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.
39
39
cfg_if:: cfg_if! {
40
40
if #[ cfg( target_os = "emscripten" ) ] {
41
41
#[ path = "emcc.rs" ]
@@ -61,12 +61,14 @@ cfg_if::cfg_if! {
61
61
}
62
62
}
63
63
64
+ include ! ( "payload.rs" ) ;
65
+
64
66
mod dwarf;
65
67
66
68
#[ 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 ) {
70
72
Box :: into_raw ( imp:: cleanup ( payload) )
71
73
}
72
74
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 {
264
264
_CxxThrowException ( throw_ptr, & mut THROW_INFO as * mut _ as * mut _ ) ;
265
265
}
266
266
267
- pub type Payload = [ u64 ; 2 ] ;
268
-
269
267
pub unsafe fn cleanup ( payload : [ u64 ; 2 ] ) -> Box < dyn Any + Send > {
270
268
mem:: transmute ( raw:: TraitObject { data : payload[ 0 ] as * mut _ , vtable : payload[ 1 ] as * mut _ } )
271
269
}
You can’t perform that action at this time.
0 commit comments