]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/smallest-hello-world.rs
c7db8068785feb3a3b80a63834e4f6e9b515e258
[rust.git] / src / test / run-pass / smallest-hello-world.rs
1 // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Smallest "hello world" with a libc runtime
12
13 #![feature(intrinsics, lang_items, start, no_std, libc)]
14 #![no_std]
15
16 extern crate libc;
17
18 extern { fn puts(s: *const u8); }
19 extern "rust-intrinsic" { fn transmute<T, U>(t: T) -> U; }
20
21 #[lang = "stack_exhausted"] extern fn stack_exhausted() {}
22 #[lang = "eh_personality"] extern fn eh_personality() {}
23 #[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }
24
25 #[start]
26 #[no_stack_check]
27 fn main(_: int, _: *const *const u8) -> int {
28     unsafe {
29         let (ptr, _): (*const u8, uint) = transmute("Hello!\0");
30         puts(ptr);
31     }
32     return 0;
33 }
34
35 #[cfg(target_os = "android")]
36 #[link(name="gcc")]
37 extern { }