|
|
|
@ -7,40 +7,28 @@
@@ -7,40 +7,28 @@
|
|
|
|
|
#![feature(nonnull_slice_from_raw_parts)] |
|
|
|
|
#![test_runner(test_runner::run)] |
|
|
|
|
|
|
|
|
|
extern "C" fn services_deinit() { |
|
|
|
|
unsafe { |
|
|
|
|
ctru_sys::psExit(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// These functions are imported to assure ´cargo´ we need to link the crates.
|
|
|
|
|
// These don't need to run to link the functions properly!
|
|
|
|
|
#[allow(unused_imports)] |
|
|
|
|
use linker_fix_3ds::init as link_init; |
|
|
|
|
#[allow(unused_imports)] |
|
|
|
|
use pthread_3ds::init as pthread_init; |
|
|
|
|
|
|
|
|
|
#[no_mangle] |
|
|
|
|
#[cfg(feature = "big-stack")] |
|
|
|
|
static __stacksize__: usize = 2 * 1024 * 1024; // 2MB
|
|
|
|
|
|
|
|
|
|
/// Call this somewhere to force Rust to link some required crates
|
|
|
|
|
/// This is also a setup for some crate integration only available at runtime
|
|
|
|
|
/// Activate ´ctru-rs´' default panic handler.
|
|
|
|
|
///
|
|
|
|
|
/// See <https://github.com/rust-lang/rust/issues/47384>
|
|
|
|
|
pub fn init() { |
|
|
|
|
linker_fix_3ds::init(); |
|
|
|
|
pthread_3ds::init(); |
|
|
|
|
|
|
|
|
|
/// With this implementation, the main thread will stop and try to print debug info to an available [console::Console].
|
|
|
|
|
/// In case it fails to find an active [console::Console], the program will just exit.
|
|
|
|
|
///
|
|
|
|
|
/// # Notes
|
|
|
|
|
///
|
|
|
|
|
/// When ´test´ is enabled, this function won't do anything, as it should be overridden by the ´test´ environment.
|
|
|
|
|
pub fn use_panic_handler() { |
|
|
|
|
#[cfg(not(test))] |
|
|
|
|
panic_hook_setup(); |
|
|
|
|
|
|
|
|
|
// Initialize the PS service for random data generation
|
|
|
|
|
unsafe { |
|
|
|
|
let ps_ret = ctru_sys::psInit(); |
|
|
|
|
if ctru_sys::R_FAILED(ps_ret) { |
|
|
|
|
panic!( |
|
|
|
|
"Failed to initialize random data generation: {:?}", |
|
|
|
|
Error::from(ps_ret) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Setup the deconstruction at the program's end
|
|
|
|
|
libc::atexit(services_deinit); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[cfg(not(test))] |
|
|
|
|