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