1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#![no_std]
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(clippy::all)]
#![deny(ambiguous_glob_reexports)]
#![cfg_attr(test, feature(custom_test_frameworks))]
#![cfg_attr(test, test_runner(test_runner::run_gdb))]
#![doc(
    html_favicon_url = "https://user-images.githubusercontent.com/11131775/225929072-2fa1741c-93ae-4b47-9bdf-af70f3d59910.png"
)]
#![doc(
    html_logo_url = "https://user-images.githubusercontent.com/11131775/225929072-2fa1741c-93ae-4b47-9bdf-af70f3d59910.png"
)]
#![doc(html_root_url = "https://rust3ds.github.io/ctru-rs/crates")]

// Prevent linking errors from the standard `test` library when running `cargo 3ds test --lib`.
// See https://github.com/rust-lang/rust-analyzer/issues/14167 for why we use `not(rust_analyzer)`
#[cfg(all(test, not(rust_analyzer)))]
extern crate shim_3ds;

pub mod result;
pub use result::*;

// By only exporting the `libc` module in tests, we can catch any potential conflicts between
// generated bindings and existing `libc` types, since we use #[deny(ambiguous_glob_reexports)].
#[cfg(test)]
pub use libc::*;

mod bindings {
    // Meanwhile, make sure generated bindings can still refer to libc types if needed:
    use libc::*;

    include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
}

pub use bindings::*;

/// In lieu of a proper errno function exposed by libc
/// (<https://github.com/rust-lang/libc/issues/1995>).
pub unsafe fn errno() -> s32 {
    *__errno()
}