From 48e3a6b75b6de35344f4cab3efe779a4c3ab1305 Mon Sep 17 00:00:00 2001 From: Meziu Date: Fri, 29 Oct 2021 17:07:42 +0200 Subject: [PATCH] Working condition --- .cargo/config.toml | 2 ++ .gitignore | 3 +++ Cargo.toml | 14 ++++++++++++++ README.md | 13 +++++++++++++ src/lib.rs | 21 +++++++++++++++++++++ 5 files changed, 53 insertions(+) create mode 100644 .cargo/config.toml create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 README.md create mode 100644 src/lib.rs diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..4782581 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +rustc = "/home/andrea/Desktop/ProgrammingStuff/Rust/rust-3ds/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..46bf68e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +target +Cargo.lock + diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..e030862 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "linker-fix-3ds" +authors = [ "Andrea Ciliberti " ] +version = "0.1.0" +license = "MIT/Apache 2.0" +edition = "2018" + +[lib] +name = "linker_fix_3ds" +path = "src/lib.rs" +crate-type = ["staticlib"] + +[dependencies.libc] +path = "../libc" diff --git a/README.md b/README.md new file mode 100644 index 0000000..20a8bb5 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# rust3ds-hello-world + +`Hello World` example of my Rust implementation for the Nintendo 3DS. + +# Build + +Make sure you have the latest Rust nightly toolchain and activate it (by defaulting it or overriding for the rust3ds-hello-world folder) +Do `rustup component add rust-src` to download the Rust source code. + +Download the `ctru-sys` repository from my github profile and put it in the same directory as this git repo (support with crates.io may be thought of in the future). +Run `cargo +nightly build -Zbuild-std=core,alloc --target armv6k-nintendo-3ds.json --release` and it should build an .elf file in the target folder. Use the 3dsxtool from the devkitPRO toolchain to build it into a .3dsx and then transfer it to your console or run it in an emulator (Quicker building methods will be implemented, it just works for now). + +STILL WIP. diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..9ab24b7 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,21 @@ +extern crate libc; + +#[no_mangle] +extern "C" fn posix_memalign(memptr: *mut *mut libc::c_void, align: libc::size_t, size: libc::size_t) -> libc::c_int { + unsafe { + *memptr = libc::memalign(align, size); + } + + 0 +} + + +#[no_mangle] +unsafe extern "C" fn realpath( + path: *const libc::c_char, + resolved_path: *mut libc::c_char +) -> *mut libc::c_char { + libc::memcpy(resolved_path as _, path as _, libc::strlen(path)); + + resolved_path +}