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    bad_style,
8    overflowing_literals,
9    improper_ctypes,
10    // This lint is renamed but we run CI for old stable rustc so should be here.
11    redundant_semicolon,
12    redundant_semicolons,
13    unused_macros,
14    unused_macro_rules,
15    // FIXME: temporarily allow dead_code to fix CI:
16    // - https://github.com/rust-lang/libc/issues/3740
17    // - https://github.com/rust-lang/rust/pull/126456
18    dead_code,
19)]
20#![cfg_attr(libc_deny_warnings, deny(warnings))]
21// Attributes needed when building as part of the standard library
22#![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))]
23#![cfg_attr(libc_thread_local, feature(thread_local))]
24// Enable extra lints:
25#![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))]
26#![deny(missing_copy_implementations, safe_packed_borrows)]
27#![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)]
28#![cfg_attr(feature = "rustc-dep-of-std", no_core)]
29#![cfg_attr(libc_const_extern_fn_unstable, feature(const_extern_fn))]
30
31#[macro_use]
32mod macros;
33
34cfg_if! {
35    if #[cfg(feature = "rustc-dep-of-std")] {
36        extern crate rustc_std_workspace_core as core;
37        #[allow(unused_imports)]
38        use core::iter;
39        #[allow(unused_imports)]
40        use core::ops;
41        #[allow(unused_imports)]
42        use core::option;
43    }
44}
45
46cfg_if! {
47    if #[cfg(libc_priv_mod_use)] {
48        #[cfg(libc_core_cvoid)]
49        #[allow(unused_imports)]
50        use core::ffi;
51        #[allow(unused_imports)]
52        use core::fmt;
53        #[allow(unused_imports)]
54        use core::hash;
55        #[allow(unused_imports)]
56        use core::num;
57        #[allow(unused_imports)]
58        use core::mem;
59        #[doc(hidden)]
60        #[allow(unused_imports)]
61        use core::clone::Clone;
62        #[doc(hidden)]
63        #[allow(unused_imports)]
64        use core::marker::{Copy, Send, Sync};
65        #[doc(hidden)]
66        #[allow(unused_imports)]
67        use core::option::Option;
68    } else {
69        #[doc(hidden)]
70        #[allow(unused_imports)]
71        pub use core::fmt;
72        #[doc(hidden)]
73        #[allow(unused_imports)]
74        pub use core::hash;
75        #[doc(hidden)]
76        #[allow(unused_imports)]
77        pub use core::num;
78        #[doc(hidden)]
79        #[allow(unused_imports)]
80        pub use core::mem;
81        #[doc(hidden)]
82        #[allow(unused_imports)]
83        pub use core::clone::Clone;
84        #[doc(hidden)]
85        #[allow(unused_imports)]
86        pub use core::marker::{Copy, Send, Sync};
87        #[doc(hidden)]
88        #[allow(unused_imports)]
89        pub use core::option::Option;
90    }
91}
92
93cfg_if! {
94    if #[cfg(windows)] {
95        mod fixed_width_ints;
96        pub use fixed_width_ints::*;
97
98        mod windows;
99        pub use windows::*;
100    } else if #[cfg(target_os = "fuchsia")] {
101        mod fixed_width_ints;
102        pub use fixed_width_ints::*;
103
104        mod fuchsia;
105        pub use fuchsia::*;
106    } else if #[cfg(target_os = "switch")] {
107        mod fixed_width_ints;
108        pub use fixed_width_ints::*;
109
110        mod switch;
111        pub use switch::*;
112    } else if #[cfg(target_os = "psp")] {
113        mod fixed_width_ints;
114        pub use fixed_width_ints::*;
115
116        mod psp;
117        pub use psp::*;
118    } else if #[cfg(target_os = "vxworks")] {
119        mod fixed_width_ints;
120        pub use fixed_width_ints::*;
121
122        mod vxworks;
123        pub use vxworks::*;
124    } else if #[cfg(target_os = "solid_asp3")] {
125        mod fixed_width_ints;
126        pub use fixed_width_ints::*;
127
128        mod solid;
129        pub use solid::*;
130    } else if #[cfg(unix)] {
131        mod fixed_width_ints;
132        pub use fixed_width_ints::*;
133
134        mod unix;
135        pub use unix::*;
136    } else if #[cfg(target_os = "hermit")] {
137        mod fixed_width_ints;
138        pub use fixed_width_ints::*;
139
140        mod hermit;
141        pub use hermit::*;
142    } else if #[cfg(target_os = "teeos")] {
143        mod fixed_width_ints;
144        pub use fixed_width_ints::*;
145
146        mod teeos;
147        pub use teeos::*;
148    } else if #[cfg(target_os = "trusty")] {
149        mod fixed_width_ints;
150        pub use fixed_width_ints::*;
151
152        mod trusty;
153        pub use trusty::*;
154    } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
155        mod fixed_width_ints;
156        pub use fixed_width_ints::*;
157
158        mod sgx;
159        pub use sgx::*;
160    } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
161        mod fixed_width_ints;
162        pub use fixed_width_ints::*;
163
164        mod wasi;
165        pub use wasi::*;
166    } else if #[cfg(target_os = "xous")] {
167        mod fixed_width_ints;
168        pub use fixed_width_ints::*;
169
170        mod xous;
171        pub use xous::*;
172    } else {
173        // non-supported targets: empty...
174    }
175}