1 //! libc - Raw FFI bindings to platforms' system libraries
2 //!
3 //! [Documentation for other platforms][pd].
4 //!
5 //! [pd]: https://rust-lang.github.io/libc/#platform-specific-documentation
6 #![crate_name = "libc"]
7 #![crate_type = "rlib"]
8 #![allow(
9     renamed_and_removed_lints, // Keep this order.
10     unknown_lints, // Keep this order.
11     bad_style,
12     overflowing_literals,
13     improper_ctypes,
14     // This lint is renamed but we run CI for old stable rustc so should be here.
15     redundant_semicolon,
16     redundant_semicolons
17 )]
18 #![cfg_attr(libc_deny_warnings, deny(warnings))]
19 // Attributes needed when building as part of the standard library
20 #![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))]
21 #![cfg_attr(libc_thread_local, feature(thread_local))]
22 // Enable extra lints:
23 #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))]
24 #![deny(missing_copy_implementations, safe_packed_borrows)]
25 #![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)]
26 #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
27 #![cfg_attr(
28     any(feature = "rustc-dep-of-std", target_os = "redox"),
29     feature(static_nobundle)
30 )]
31 #![cfg_attr(libc_const_extern_fn, feature(const_extern_fn))]
32 
33 #[macro_use]
34 mod macros;
35 
36 cfg_if! {
37     if #[cfg(feature = "rustc-dep-of-std")] {
38         extern crate rustc_std_workspace_core as core;
39         #[allow(unused_imports)]
40         use core::iter;
41         #[allow(unused_imports)]
42         use core::ops;
43         #[allow(unused_imports)]
44         use core::option;
45     }
46 }
47 
48 cfg_if! {
49     if #[cfg(libc_priv_mod_use)] {
50         #[cfg(libc_core_cvoid)]
51         #[allow(unused_imports)]
52         use core::ffi;
53         #[allow(unused_imports)]
54         use core::fmt;
55         #[allow(unused_imports)]
56         use core::hash;
57         #[allow(unused_imports)]
58         use core::num;
59         #[allow(unused_imports)]
60         use core::mem;
61         #[doc(hidden)]
62         #[allow(unused_imports)]
63         use core::clone::Clone;
64         #[doc(hidden)]
65         #[allow(unused_imports)]
66         use core::marker::Copy;
67         #[doc(hidden)]
68         #[allow(unused_imports)]
69         use core::option::Option;
70     } else {
71         #[doc(hidden)]
72         #[allow(unused_imports)]
73         pub use core::fmt;
74         #[doc(hidden)]
75         #[allow(unused_imports)]
76         pub use core::hash;
77         #[doc(hidden)]
78         #[allow(unused_imports)]
79         pub use core::num;
80         #[doc(hidden)]
81         #[allow(unused_imports)]
82         pub use core::mem;
83         #[doc(hidden)]
84         #[allow(unused_imports)]
85         pub use core::clone::Clone;
86         #[doc(hidden)]
87         #[allow(unused_imports)]
88         pub use core::marker::Copy;
89         #[doc(hidden)]
90         #[allow(unused_imports)]
91         pub use core::option::Option;
92     }
93 }
94 
95 cfg_if! {
96     if #[cfg(windows)] {
97         mod fixed_width_ints;
98         pub use fixed_width_ints::*;
99 
100         mod windows;
101         pub use windows::*;
102     } else if #[cfg(target_os = "fuchsia")] {
103         mod fixed_width_ints;
104         pub use fixed_width_ints::*;
105 
106         mod fuchsia;
107         pub use fuchsia::*;
108     } else if #[cfg(target_os = "switch")] {
109         mod fixed_width_ints;
110         pub use fixed_width_ints::*;
111 
112         mod switch;
113         pub use switch::*;
114     } else if #[cfg(target_os = "psp")] {
115         mod fixed_width_ints;
116         pub use fixed_width_ints::*;
117 
118         mod psp;
119         pub use psp::*;
120     } else if #[cfg(target_os = "vxworks")] {
121         mod fixed_width_ints;
122         pub use fixed_width_ints::*;
123 
124         mod vxworks;
125         pub use vxworks::*;
126     } else if #[cfg(unix)] {
127         mod fixed_width_ints;
128         pub use fixed_width_ints::*;
129 
130         mod unix;
131         pub use unix::*;
132     } else if #[cfg(target_os = "hermit")] {
133         mod fixed_width_ints;
134         pub use fixed_width_ints::*;
135 
136         mod hermit;
137         pub use hermit::*;
138     } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
139         mod fixed_width_ints;
140         pub use fixed_width_ints::*;
141 
142         mod sgx;
143         pub use sgx::*;
144     } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
145         mod fixed_width_ints;
146         pub use fixed_width_ints::*;
147 
148         mod wasi;
149         pub use wasi::*;
150     } else {
151         // non-supported targets: empty...
152     }
153 }
154