diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs index 5f86a61..67d8baa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,30 +1,29 @@ #![no_main] #![no_std] -extern crate libc; - -mod c; +use safe_libc as libc; +use libc::cstr; use core::fmt::Write; #[no_mangle] pub extern "C" fn main(_nargs: libc::c_int, _args: *const *const libc::c_char) -> libc::c_int { - let mut stdout = unsafe { c::stdio::stdout() }; - let x = c::string::CString::from("foo"); + let mut stdout = unsafe { libc::stdio::stdout() }; + let x = libc::string::CString::from("foo"); let l = x.len(); let y = x.into_raw(); let z = unsafe { - c::string::CBox::slice_from_raw_parts(y, l) + libc::boxed::CBox::slice_from_raw_parts(y, l) }; //let y = unsafe { c::string::CBox::from_raw(x) }; - //let foo = cstr!("Foo! %p\n"); - //c::stdio::stdout().puts(foo); + let foo = cstr!("Foo!\n"); + stdout.puts(foo); let _ = writeln!(stdout, "Foo: {} {} {}", z[0], z[1], z[2]); 0 } #[panic_handler] fn panic(info: &core::panic::PanicInfo) -> ! { - let _ = writeln!(unsafe { c::stdio::stderr() }, "Panic: {}", info); + let _ = writeln!(unsafe { libc::stdio::stderr() }, "Panic: {}", info); unsafe { libc::abort() } } |