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