xref: /rust-libc-0.2.174/src/lib.rs (revision b9986d9d)
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 // FIXME: Remove this and redundant_semicolon once renamed lint reaches stable.
9 #![allow(renamed_and_removed_lints)]
10 #![allow(
11     bad_style,
12     overflowing_literals,
13     improper_ctypes,
14     unknown_lints,
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(
21     feature = "rustc-dep-of-std",
22     feature(cfg_target_vendor, link_cfg, no_core)
23 )]
24 #![cfg_attr(libc_thread_local, feature(thread_local))]
25 // Enable extra lints:
26 #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))]
27 #![deny(missing_copy_implementations, safe_packed_borrows)]
28 #![no_std]
29 #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
30 #![cfg_attr(target_os = "redox", feature(static_nobundle))]
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::option;
43     }
44 }
45 
46 cfg_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;
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;
87         #[doc(hidden)]
88         #[allow(unused_imports)]
89         pub use core::option::Option;
90     }
91 }
92 
93 cfg_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 = "cloudabi")] {
101         mod fixed_width_ints;
102         pub use fixed_width_ints::*;
103 
104         mod cloudabi;
105         pub use cloudabi::*;
106     } else if #[cfg(target_os = "fuchsia")] {
107         mod fixed_width_ints;
108         pub use fixed_width_ints::*;
109 
110         mod fuchsia;
111         pub use fuchsia::*;
112     } else if #[cfg(target_os = "switch")] {
113         mod fixed_width_ints;
114         pub use fixed_width_ints::*;
115 
116         mod switch;
117         pub use switch::*;
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(unix)] {
125         mod fixed_width_ints;
126         pub use fixed_width_ints::*;
127 
128         mod unix;
129         pub use unix::*;
130     } else if #[cfg(target_os = "hermit")] {
131         mod fixed_width_ints;
132         pub use fixed_width_ints::*;
133 
134         mod hermit;
135         pub use hermit::*;
136     } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
137         mod fixed_width_ints;
138         pub use fixed_width_ints::*;
139 
140         mod sgx;
141         pub use sgx::*;
142     } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
143         mod fixed_width_ints;
144         pub use fixed_width_ints::*;
145 
146         mod wasi;
147         pub use wasi::*;
148     } else {
149         // non-supported targets: empty...
150     }
151 }
152