@@ -34,34 +34,11 @@ mod runtime {
34
34
unsafe { core:: hint:: unreachable_unchecked ( ) }
35
35
}
36
36
37
- #[ cfg( all( not( test) , feature = "submit" ) ) ]
38
37
#[ panic_handler]
39
38
fn panic ( _pi : & core:: panic:: PanicInfo ) -> ! {
40
- unsafe { core:: hint:: unreachable_unchecked ( ) }
41
- }
42
-
43
- #[ cfg( all( not( test) , not( feature = "submit" ) ) ) ]
44
- #[ panic_handler]
45
- fn panic ( _pi : & core:: panic:: PanicInfo ) -> ! {
46
- use alloc:: string:: ToString ;
47
- use basm:: platform:: services:: write_stdio;
48
- write_stdio ( 2 , _pi. to_string ( ) . as_bytes ( ) ) ;
49
- write_stdio ( 2 , b"\n " ) ;
50
-
51
- // Rust sets an exit code of 101 when the process panicked.
52
- // Hence, we follow that practice for maximum compatibility.
53
- // Reference: https://rust-cli.github.io/book/in-depth/exit-code.html
54
- #[ cfg( all( windows, target_arch = "x86_64" ) ) ]
55
- {
56
- extern "win64" {
57
- fn ExitProcess ( uExitCode : u32 ) -> !;
58
- }
59
- unsafe { ExitProcess ( 101 ) ; }
60
- }
61
- #[ cfg( target_os = "linux" ) ] {
62
- unsafe { basm:: platform:: os:: linux:: syscall:: exit_group ( 101 ) ; }
63
- }
64
- #[ cfg( not( any( all( windows, target_arch = "x86_64" ) , target_os = "linux" ) ) ) ]
39
+ #[ cfg( not( feature = "submit" ) ) ]
40
+ unsafe { basm:: platform:: codegen:: print_panicinfo_and_exit ( _pi) }
41
+ #[ cfg( feature = "submit" ) ]
65
42
unsafe { core:: hint:: unreachable_unchecked ( ) }
66
43
}
67
44
}
0 commit comments