ctru_sys/
lib.rs

1#![no_std]
2#![expect(unnecessary_transmutes)]
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6#![allow(clippy::all)]
7#![allow(unexpected_cfgs)] // Read below why we necessate a check for rust_analyzer.
8#![deny(ambiguous_glob_reexports)]
9#![cfg_attr(test, feature(custom_test_frameworks))]
10#![cfg_attr(test, test_runner(test_runner::run_gdb))]
11#![doc(
12    html_favicon_url = "https://user-images.githubusercontent.com/11131775/225929072-2fa1741c-93ae-4b47-9bdf-af70f3d59910.png"
13)]
14#![doc(
15    html_logo_url = "https://user-images.githubusercontent.com/11131775/225929072-2fa1741c-93ae-4b47-9bdf-af70f3d59910.png"
16)]
17#![doc(html_root_url = "https://rust3ds.github.io/ctru-rs/crates")]
18
19// Prevent linking errors from the standard `test` library when running `cargo 3ds test --lib`.
20// See https://github.com/rust-lang/rust-analyzer/issues/14167 for why we use `not(rust_analyzer)`
21#[cfg(all(test, not(rust_analyzer)))]
22extern crate shim_3ds;
23
24pub mod result;
25pub use result::*;
26
27// By only exporting the `libc` module in tests, we can catch any potential conflicts between
28// generated bindings and existing `libc` types, since we use #[deny(ambiguous_glob_reexports)].
29#[cfg(test)]
30pub use libc::*;
31
32mod bindings {
33    // Meanwhile, make sure generated bindings can still refer to libc types if needed:
34    use libc::*;
35
36    include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
37}
38
39pub use bindings::*;
40
41/// In lieu of a proper errno function exposed by libc
42/// (<https://github.com/rust-lang/libc/issues/1995>).
43pub unsafe fn errno() -> s32 {
44    return unsafe { *__errno() };
45}