diff options
| author | Dario Bartussek <[email protected]> | 2021-04-20 13:30:33 +0200 |
|---|---|---|
| committer | Dario Bartussek <[email protected]> | 2021-04-20 13:30:33 +0200 |
| commit | 0d5aa9036ca0ba441d9ca9ecaed2adb3af11846b (patch) | |
| tree | 9c783b54968c4221c90e667ce60c902b1e6a296f /src/lib.rs | |
| parent | Simple hello world program using libctru (diff) | |
| download | rust_3ds-0d5aa9036ca0ba441d9ca9ecaed2adb3af11846b.tar.xz rust_3ds-0d5aa9036ca0ba441d9ca9ecaed2adb3af11846b.zip | |
Experimental use of Rust std
print! and alloc work so far, panic causes a segfault
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 23 |
1 files changed, 11 insertions, 12 deletions
@@ -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 {} -} |