diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2019-05-12 02:39:08 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2019-05-12 02:39:08 +0200 |
commit | 0abdc827c9aa9e3f64d31d62663ea232863e4e76 (patch) | |
tree | 47f3bcda0a0b9b6d2305953493f849faf31dfb80 /src/main.rs | |
download | neco-0abdc827c9aa9e3f64d31d62663ea232863e4e76.tar neco-0abdc827c9aa9e3f64d31d62663ea232863e4e76.zip |
Safe libc test code
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..7cdfb3f --- /dev/null +++ b/src/main.rs @@ -0,0 +1,19 @@ +#![no_main] +#![no_std] + +extern crate libc; + +mod c; + +#[no_mangle] +pub extern fn main(_nargs: libc::c_int, _args: *const *const libc::c_char) -> libc::c_int { + let foo = cstr!("Foo! %p\n"); + let x = c::string::CBox::new(()); + unsafe { libc::printf(foo.as_ptr(), &*x as *const ()); } + 0 +} + +#[panic_handler] +fn panic(_info: &core::panic::PanicInfo) -> ! { + unsafe { libc::abort() } +} |