]>
Commit | Line | Data |
---|---|---|
353b0b11 | 1 | #![feature(start, core_intrinsics, alloc_error_handler)] |
29967ef6 XL |
2 | #![no_std] |
3 | ||
4 | extern crate alloc; | |
5 | extern crate alloc_system; | |
6 | ||
c295e0f8 | 7 | use alloc::boxed::Box; |
29967ef6 XL |
8 | |
9 | use alloc_system::System; | |
10 | ||
11 | #[global_allocator] | |
12 | static ALLOC: System = System; | |
13 | ||
5869c6ff XL |
14 | #[cfg_attr(unix, link(name = "c"))] |
15 | #[cfg_attr(target_env = "msvc", link(name = "msvcrt"))] | |
29967ef6 XL |
16 | extern "C" { |
17 | fn puts(s: *const u8) -> i32; | |
18 | } | |
19 | ||
20 | #[panic_handler] | |
21 | fn panic_handler(_: &core::panic::PanicInfo) -> ! { | |
22 | core::intrinsics::abort(); | |
23 | } | |
24 | ||
25 | #[alloc_error_handler] | |
26 | fn alloc_error_handler(_: alloc::alloc::Layout) -> ! { | |
27 | core::intrinsics::abort(); | |
28 | } | |
29 | ||
30 | #[start] | |
31 | fn main(_argc: isize, _argv: *const *const u8) -> isize { | |
353b0b11 | 32 | let world: Box<&str> = Box::new("Hello World!\0"); |
29967ef6 XL |
33 | unsafe { |
34 | puts(*world as *const str as *const u8); | |
35 | } | |
36 | ||
37 | 0 | |
38 | } |