]>
Commit | Line | Data |
---|---|---|
b7449926 XL |
1 | #![feature(panic_handler, alloc_error_handler)] |
2 | #![crate_type = "cdylib"] | |
8faf50e0 | 3 | #![no_std] |
2c00a5a8 | 4 | |
b7449926 XL |
5 | use core::alloc::*; |
6 | ||
7 | struct B; | |
8 | ||
9 | unsafe impl GlobalAlloc for B { | |
10 | unsafe fn alloc(&self, x: Layout) -> *mut u8 { | |
11 | 1 as *mut u8 | |
12 | } | |
13 | ||
14 | unsafe fn dealloc(&self, ptr: *mut u8, x: Layout) { | |
15 | } | |
16 | } | |
17 | ||
18 | #[global_allocator] | |
19 | static A: B = B; | |
20 | ||
21 | #[no_mangle] | |
22 | pub extern fn foo(a: u32) -> u32 { | |
23 | assert_eq!(a, 3); | |
24 | a * 2 | |
25 | } | |
3157f602 | 26 | |
8faf50e0 | 27 | #[alloc_error_handler] |
b7449926 | 28 | fn a(_: core::alloc::Layout) -> ! { |
8faf50e0 | 29 | loop {} |
a7813a04 XL |
30 | } |
31 | ||
b7449926 XL |
32 | #[panic_handler] |
33 | fn b(_: &core::panic::PanicInfo) -> ! { | |
34 | loop {} | |
35 | } |