From 0abdc827c9aa9e3f64d31d62663ea232863e4e76 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 12 May 2019 02:39:08 +0200 Subject: Safe libc test code --- src/main.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main.rs (limited to 'src/main.rs') 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() } +} -- cgit v1.2.3