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 // ANDROID: Use std to allow building as a dylib.
32 #[cfg(android_dylib)]
33 extern crate std;
34 
35 #[macro_use]
36 mod macros;
37 
38 cfg_if! {
39     if #[cfg(feature = "rustc-dep-of-std")] {
40         extern crate rustc_std_workspace_core as core;
41         #[allow(unused_imports)]
42         use core::iter;
43         #[allow(unused_imports)]
44         use core::ops;
45         #[allow(unused_imports)]
46         use core::option;
47     }
48 }
49 
50 cfg_if! {
51     if #[cfg(libc_priv_mod_use)] {
52         #[cfg(libc_core_cvoid)]
53         #[allow(unused_imports)]
54         use core::ffi;
55         #[allow(unused_imports)]
56         use core::fmt;
57         #[allow(unused_imports)]
58         use core::hash;
59         #[allow(unused_imports)]
60         use core::num;
61         #[allow(unused_imports)]
62         use core::mem;
63         #[doc(hidden)]
64         #[allow(unused_imports)]
65         use core::clone::Clone;
66         #[doc(hidden)]
67         #[allow(unused_imports)]
68         use core::marker::{Copy, Send, Sync};
69         #[doc(hidden)]
70         #[allow(unused_imports)]
71         use core::option::Option;
72     } else {
73         #[doc(hidden)]
74         #[allow(unused_imports)]
75         pub use core::fmt;
76         #[doc(hidden)]
77         #[allow(unused_imports)]
78         pub use core::hash;
79         #[doc(hidden)]
80         #[allow(unused_imports)]
81         pub use core::num;
82         #[doc(hidden)]
83         #[allow(unused_imports)]
84         pub use core::mem;
85         #[doc(hidden)]
86         #[allow(unused_imports)]
87         pub use core::clone::Clone;
88         #[doc(hidden)]
89         #[allow(unused_imports)]
90         pub use core::marker::{Copy, Send, Sync};
91         #[doc(hidden)]
92         #[allow(unused_imports)]
93         pub use core::option::Option;
94     }
95 }
96 
97 cfg_if! {
98     if #[cfg(windows)] {
99         mod fixed_width_ints;
100         pub use fixed_width_ints::*;
101 
102         mod windows;
103         pub use windows::*;
104     } else if #[cfg(target_os = "fuchsia")] {
105         mod fixed_width_ints;
106         pub use fixed_width_ints::*;
107 
108         mod fuchsia;
109         pub use fuchsia::*;
110     } else if #[cfg(target_os = "switch")] {
111         mod fixed_width_ints;
112         pub use fixed_width_ints::*;
113 
114         mod switch;
115         pub use switch::*;
116     } else if #[cfg(target_os = "psp")] {
117         mod fixed_width_ints;
118         pub use fixed_width_ints::*;
119 
120         mod psp;
121         pub use psp::*;
122     } else if #[cfg(target_os = "vxworks")] {
123         mod fixed_width_ints;
124         pub use fixed_width_ints::*;
125 
126         mod vxworks;
127         pub use vxworks::*;
128     } else if #[cfg(target_os = "solid_asp3")] {
129         mod fixed_width_ints;
130         pub use fixed_width_ints::*;
131 
132         mod solid;
133         pub use solid::*;
134     } else if #[cfg(unix)] {
135         mod fixed_width_ints;
136         pub use fixed_width_ints::*;
137 
138         mod unix;
139         pub use unix::*;
140     } else if #[cfg(target_os = "hermit")] {
141         mod fixed_width_ints;
142         pub use fixed_width_ints::*;
143 
144         mod hermit;
145         pub use hermit::*;
146     } else if #[cfg(target_os = "teeos")] {
147         mod fixed_width_ints;
148         pub use fixed_width_ints::*;
149 
150         mod teeos;
151         pub use teeos::*;
152     } else if #[cfg(target_os = "trusty")] {
153         mod fixed_width_ints;
154         pub use fixed_width_ints::*;
155 
156         mod trusty;
157         pub use trusty::*;
158     } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
159         mod fixed_width_ints;
160         pub use fixed_width_ints::*;
161 
162         mod sgx;
163         pub use sgx::*;
164     } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
165         mod fixed_width_ints;
166         pub use fixed_width_ints::*;
167 
168         mod wasi;
169         pub use wasi::*;
170     } else if #[cfg(target_os = "xous")] {
171         mod fixed_width_ints;
172         pub use fixed_width_ints::*;
173 
174         mod xous;
175         pub use xous::*;
176     } else {
177         // non-supported targets: empty...
178     }
179 }
180