libc/
lib.rs

1//! libc - Raw FFI bindings to platforms' system libraries
2#![crate_name = "libc"]
3#![crate_type = "rlib"]
4#![allow(
5    renamed_and_removed_lints, // Keep this order.
6    unknown_lints, // Keep this order.
7    nonstandard_style,
8    overflowing_literals,
9    unused_macros,
10    unused_macro_rules,
11)]
12#![warn(
13    missing_copy_implementations,
14    missing_debug_implementations,
15    safe_packed_borrows
16)]
17// Prepare for a future upgrade
18#![warn(rust_2024_compatibility)]
19// Things missing for 2024 that are blocked on MSRV or breakage
20#![allow(
21    missing_unsafe_on_extern,
22    edition_2024_expr_fragment_specifier,
23    // Allowed globally, the warning is enabled in individual modules as we work through them
24    unsafe_op_in_unsafe_fn
25)]
26#![cfg_attr(libc_deny_warnings, deny(warnings))]
27// Attributes needed when building as part of the standard library
28#![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))]
29#![cfg_attr(feature = "rustc-dep-of-std", allow(internal_features))]
30// DIFF(1.0): The thread local references that raise this lint were removed in 1.0
31#![cfg_attr(feature = "rustc-dep-of-std", allow(static_mut_refs))]
32#![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)]
33#![cfg_attr(feature = "rustc-dep-of-std", no_core)]
34
35#[macro_use]
36mod macros;
37mod new;
38
39cfg_if! {
40    if #[cfg(feature = "rustc-dep-of-std")] {
41        extern crate rustc_std_workspace_core as core;
42    }
43}
44
45pub use core::ffi::c_void;
46
47#[allow(unused_imports)] // needed while the module is empty on some platforms
48pub use new::*;
49
50cfg_if! {
51    if #[cfg(windows)] {
52        mod primitives;
53        pub use crate::primitives::*;
54
55        mod windows;
56        pub use crate::windows::*;
57
58        prelude!();
59    } else if #[cfg(target_os = "fuchsia")] {
60        mod primitives;
61        pub use crate::primitives::*;
62
63        mod fuchsia;
64        pub use crate::fuchsia::*;
65
66        prelude!();
67    } else if #[cfg(target_os = "switch")] {
68        mod primitives;
69        pub use primitives::*;
70
71        mod switch;
72        pub use switch::*;
73
74        prelude!();
75    } else if #[cfg(target_os = "psp")] {
76        mod primitives;
77        pub use primitives::*;
78
79        mod psp;
80        pub use crate::psp::*;
81
82        prelude!();
83    } else if #[cfg(target_os = "vxworks")] {
84        mod primitives;
85        pub use crate::primitives::*;
86
87        mod vxworks;
88        pub use crate::vxworks::*;
89
90        prelude!();
91    } else if #[cfg(target_os = "solid_asp3")] {
92        mod primitives;
93        pub use crate::primitives::*;
94
95        mod solid;
96        pub use crate::solid::*;
97
98        prelude!();
99    } else if #[cfg(unix)] {
100        mod primitives;
101        pub use crate::primitives::*;
102
103        mod unix;
104        pub use crate::unix::*;
105
106        prelude!();
107    } else if #[cfg(target_os = "hermit")] {
108        mod primitives;
109        pub use crate::primitives::*;
110
111        mod hermit;
112        pub use crate::hermit::*;
113
114        prelude!();
115    } else if #[cfg(target_os = "teeos")] {
116        mod primitives;
117        pub use primitives::*;
118
119        mod teeos;
120        pub use teeos::*;
121
122        prelude!();
123    } else if #[cfg(target_os = "trusty")] {
124        mod primitives;
125        pub use crate::primitives::*;
126
127        mod trusty;
128        pub use crate::trusty::*;
129
130        prelude!();
131    } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
132        mod primitives;
133        pub use crate::primitives::*;
134
135        mod sgx;
136        pub use crate::sgx::*;
137
138        prelude!();
139    } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
140        mod primitives;
141        pub use crate::primitives::*;
142
143        mod wasi;
144        pub use crate::wasi::*;
145
146        prelude!();
147    } else if #[cfg(target_os = "xous")] {
148        mod primitives;
149        pub use crate::primitives::*;
150
151        mod xous;
152        pub use crate::xous::*;
153
154        prelude!();
155    } else {
156        // non-supported targets: empty...
157    }
158}