From 0d5aa9036ca0ba441d9ca9ecaed2adb3af11846b Mon Sep 17 00:00:00 2001 From: Dario Bartussek Date: Tue, 20 Apr 2021 13:30:33 +0200 Subject: Experimental use of Rust std print! and alloc work so far, panic causes a segfault --- src/lib.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 1970dfd..f52e22b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,16 +1,12 @@ -#![no_std] +#![feature(restricted_std)] -use core::{panic::PanicInfo, ptr::null_mut}; +use core::ptr::null_mut; use libctru::raw::{ aptMainLoop, c_char, c_int, consoleInit, gfxExit, gfxFlushBuffers, gfxInitDefault, gfxScreen_t_GFX_TOP, gfxSwapBuffers, gspWaitForEvent, hidKeysDown, hidScanInput, GSPGPU_Event_GSPGPU_EVENT_VBlank0, KEY_START, }; -extern "C" { - fn puts(string: *const c_char); -} - #[no_mangle] pub extern "C" fn main(_argc: c_int, _argv: *const *const c_char) -> c_int { unsafe { @@ -18,7 +14,15 @@ pub extern "C" fn main(_argc: c_int, _argv: *const *const c_char) -> c_int { consoleInit(gfxScreen_t_GFX_TOP, null_mut()); - puts("Hello World from Rust".as_ptr()); + libctru::println!("Standard print in next line:"); + println!("Standard print"); + + std::thread::spawn(|| { + println!("Hello thread world"); + }) + .join(); + + libctru::println!("Check end"); while aptMainLoop() { hidScanInput(); @@ -39,8 +43,3 @@ pub extern "C" fn main(_argc: c_int, _argv: *const *const c_char) -> c_int { 0 } - -#[panic_handler] -fn panic(_info: &PanicInfo) -> ! { - loop {} -} -- cgit v1.2.3