Skip to content

Commit 2230557

Browse files
committed
exit with an error is better than loop forever
1 parent 4d8c3a5 commit 2230557

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/lang_items.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
use core::intrinsics::abort;
12
use core::panic::PanicInfo;
23

34
#[panic_handler]
45
fn panic(_info: &PanicInfo) -> ! {
5-
loop {}
6+
unsafe {
7+
abort();
8+
}
69
}
710

811
pub enum c_void {}

src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#![allow(non_camel_case_types)]
33
#![allow(non_upper_case_globals)]
44
#![allow(non_snake_case)]
5+
#![feature(core_intrinsics)]
6+
7+
use core::intrinsics::abort;
58

69
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
710

@@ -32,10 +35,8 @@ pub extern "C" fn main() -> ! {
3235
}
3336

3437
gfxExit();
38+
abort();
3539
}
36-
37-
// exit(0)
38-
loop {}
3940
}
4041

4142
pub mod lang_items;

0 commit comments

Comments
 (0)