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// Some targets don't need `link_cfg` and emit a warning.
31#![cfg_attr(feature = "rustc-dep-of-std", allow(unused_features))]
32// DIFF(1.0): The thread local references that raise this lint were removed in 1.0
33#![cfg_attr(feature = "rustc-dep-of-std", allow(static_mut_refs))]
34#![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)]
35#![cfg_attr(feature = "rustc-dep-of-std", no_core)]
36
37#[macro_use]
38mod macros;
39mod new;
40
41cfg_if! {
42    if #[cfg(feature = "rustc-dep-of-std")] {
43        extern crate rustc_std_workspace_core as core;
44    }
45}
46
47pub use core::ffi::c_void;
48
49#[allow(unused_imports)] // needed while the module is empty on some platforms
50pub use new::*;
51
52cfg_if! {
53    if #[cfg(windows)] {
54        mod primitives;
55        pub use crate::primitives::*;
56
57        mod windows;
58        pub use crate::windows::*;
59
60        prelude!();
61    } else if #[cfg(target_os = "fuchsia")] {
62        mod primitives;
63        pub use crate::primitives::*;
64
65        mod fuchsia;
66        pub use crate::fuchsia::*;
67
68        prelude!();
69    } else if #[cfg(target_os = "switch")] {
70        mod primitives;
71        pub use primitives::*;
72
73        mod switch;
74        pub use switch::*;
75
76        prelude!();
77    } else if #[cfg(target_os = "psp")] {
78        mod primitives;
79        pub use primitives::*;
80
81        mod psp;
82        pub use crate::psp::*;
83
84        prelude!();
85    } else if #[cfg(target_os = "vxworks")] {
86        mod primitives;
87        pub use crate::primitives::*;
88
89        mod vxworks;
90        pub use crate::vxworks::*;
91
92        prelude!();
93    } else if #[cfg(target_os = "qurt")] {
94        mod primitives;
95        pub use crate::primitives::*;
96
97        mod qurt;
98        pub use crate::qurt::*;
99
100        prelude!();
101    } else if #[cfg(target_os = "solid_asp3")] {
102        mod primitives;
103        pub use crate::primitives::*;
104
105        mod solid;
106        pub use crate::solid::*;
107
108        prelude!();
109    } else if #[cfg(unix)] {
110        mod primitives;
111        pub use crate::primitives::*;
112
113        mod unix;
114        pub use crate::unix::*;
115
116        prelude!();
117    } else if #[cfg(target_os = "hermit")] {
118        mod primitives;
119        pub use crate::primitives::*;
120
121        mod hermit;
122        pub use crate::hermit::*;
123
124        prelude!();
125    } else if #[cfg(target_os = "teeos")] {
126        mod primitives;
127        pub use primitives::*;
128
129        mod teeos;
130        pub use teeos::*;
131
132        prelude!();
133    } else if #[cfg(target_os = "trusty")] {
134        mod primitives;
135        pub use crate::primitives::*;
136
137        mod trusty;
138        pub use crate::trusty::*;
139
140        prelude!();
141    } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
142        mod primitives;
143        pub use crate::primitives::*;
144
145        mod sgx;
146        pub use crate::sgx::*;
147
148        prelude!();
149    } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
150        mod primitives;
151        pub use crate::primitives::*;
152
153        mod wasi;
154        pub use crate::wasi::*;
155
156        prelude!();
157    } else if #[cfg(target_os = "xous")] {
158        mod primitives;
159        pub use crate::primitives::*;
160
161        mod xous;
162        pub use crate::xous::*;
163
164        prelude!();
165    } else {
166        // non-supported targets: empty...
167    }
168}