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 | |
| 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
| -rw-r--r-- | 3ds.json | 6 | ||||
| -rwxr-xr-x | compile.sh | 3 | ||||
| -rw-r--r-- | src/lib.rs | 23 |
3 files changed, 16 insertions, 16 deletions
@@ -2,9 +2,9 @@ "llvm-target": "arm-none-eabihf", "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", - "os": "none", - "env": "eabi", - "vendor": "unknown", + "os": "3ds", + "env": "ctru", + "vendor": "nintendo", "arch": "arm", "target-cpu": "mpcore", "features": "+strict-align,+v6,+vfp2,-d32", @@ -1,6 +1,7 @@ cargo fmt -cargo xbuild --target 3ds.json +# cargo xbuild --target 3ds.json +cargo +3ds build -Z build-std=core,alloc,std,panic_abort --target 3ds.json arm-none-eabi-gcc -specs=3dsx.specs -g -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -Wl,-Map,rust_3ds.map -Ltarget/3ds/debug -LC:/devkitpro/libctru/lib -lrust_3ds -lctru -lm -o rust_3ds.elf @@ -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 {} -} |