xref: /rust-libc-0.2.174/src/lib.rs (revision 1a418edf)
183298283Sgnzlbg //! libc - Raw FFI bindings to platforms' system libraries
2f7efe341SAlex Crichton #![crate_name = "libc"]
383298283Sgnzlbg #![crate_type = "rlib"]
4bde74be6Sgnzlbg #![allow(
520fabe6bSYuki Okushi     renamed_and_removed_lints, // Keep this order.
620fabe6bSYuki Okushi     unknown_lints, // Keep this order.
72742aaa1Sgnzlbg     bad_style,
82742aaa1Sgnzlbg     overflowing_literals,
92742aaa1Sgnzlbg     improper_ctypes,
10d55d5930SAmanieu d'Antras     unused_macros,
11d55d5930SAmanieu d'Antras     unused_macro_rules,
12bde74be6Sgnzlbg )]
13f83c97ecSYuki Okushi #![cfg_attr(libc_deny_warnings, deny(warnings))]
14f7efe341SAlex Crichton // Attributes needed when building as part of the standard library
15dc02daaeSAmanieu d'Antras #![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))]
163fa021d7SJoe Richey #![cfg_attr(libc_thread_local, feature(thread_local))]
174ca22fa9STrevor Gross #![cfg_attr(feature = "rustc-dep-of-std", allow(internal_features))]
1870b1487bSTrevor Gross // DIFF(1.0): The thread local references that raise this lint were removed in 1.0
1970b1487bSTrevor Gross #![cfg_attr(feature = "rustc-dep-of-std", allow(static_mut_refs))]
2083298283Sgnzlbg // Enable extra lints:
21*53301c20STrevor Gross #![cfg_attr(feature = "extra_traits", warn(missing_debug_implementations))]
22*53301c20STrevor Gross #![warn(missing_copy_implementations, safe_packed_borrows)]
2348c4482bSIsaac Woods #![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)]
245049a971SAlex Crichton #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
25f7efe341SAlex Crichton 
26aca32d99Sgnzlbg #[macro_use]
27aca32d99Sgnzlbg mod macros;
28d1457314Sgnzlbg 
29a17a91cdSgnzlbg cfg_if! {
30a17a91cdSgnzlbg     if #[cfg(feature = "rustc-dep-of-std")] {
31a17a91cdSgnzlbg         extern crate rustc_std_workspace_core as core;
32a17a91cdSgnzlbg     }
33a17a91cdSgnzlbg }
34a17a91cdSgnzlbg 
35da089f78STrevor Gross pub use core::ffi::c_void;
3631504843SAlex Crichton 
379fea17aaSTrevor Gross cfg_if! {
3850a42e20SAlex Crichton     if #[cfg(windows)] {
39e2f92909SAphek         mod primitives;
40e2f92909SAphek         pub use crate::primitives::*;
4108a45197Sgnzlbg 
4250a42e20SAlex Crichton         mod windows;
43643182f7SEduardo Sánchez Muñoz         pub use crate::windows::*;
44877b6f6eSTrevor Gross 
45877b6f6eSTrevor Gross         prelude!();
465e9c614bSTaylor Cramer     } else if #[cfg(target_os = "fuchsia")] {
47e2f92909SAphek         mod primitives;
48e2f92909SAphek         pub use crate::primitives::*;
4908a45197Sgnzlbg 
50f7f9be31STaylor Cramer         mod fuchsia;
51643182f7SEduardo Sánchez Muñoz         pub use crate::fuchsia::*;
52877b6f6eSTrevor Gross 
53877b6f6eSTrevor Gross         prelude!();
548ff70b6aSroblabla     } else if #[cfg(target_os = "switch")] {
55e2f92909SAphek         mod primitives;
56e2f92909SAphek         pub use primitives::*;
5708a45197Sgnzlbg 
588ff70b6aSroblabla         mod switch;
598ff70b6aSroblabla         pub use switch::*;
60877b6f6eSTrevor Gross 
61877b6f6eSTrevor Gross         prelude!();
625dfe0132SMarko Mijalkovic     } else if #[cfg(target_os = "psp")] {
63e2f92909SAphek         mod primitives;
64e2f92909SAphek         pub use primitives::*;
655dfe0132SMarko Mijalkovic 
665dfe0132SMarko Mijalkovic         mod psp;
67643182f7SEduardo Sánchez Muñoz         pub use crate::psp::*;
68877b6f6eSTrevor Gross 
69877b6f6eSTrevor Gross         prelude!();
70636d86a9STaehyun Lee     } else if #[cfg(target_os = "vxworks")] {
71e2f92909SAphek         mod primitives;
72e2f92909SAphek         pub use crate::primitives::*;
73d18003a2SBaoshan Pang 
74636d86a9STaehyun Lee         mod vxworks;
75643182f7SEduardo Sánchez Muñoz         pub use crate::vxworks::*;
76877b6f6eSTrevor Gross 
77877b6f6eSTrevor Gross         prelude!();
7826afb61aSTomoaki Kawada     } else if #[cfg(target_os = "solid_asp3")] {
79e2f92909SAphek         mod primitives;
80e2f92909SAphek         pub use crate::primitives::*;
819e27ce67STomoaki Kawada 
829e27ce67STomoaki Kawada         mod solid;
83643182f7SEduardo Sánchez Muñoz         pub use crate::solid::*;
84877b6f6eSTrevor Gross 
85877b6f6eSTrevor Gross         prelude!();
8666c33753SKamal Marhubi     } else if #[cfg(unix)] {
87e2f92909SAphek         mod primitives;
88e2f92909SAphek         pub use crate::primitives::*;
8908a45197Sgnzlbg 
9050a42e20SAlex Crichton         mod unix;
91643182f7SEduardo Sánchez Muñoz         pub use crate::unix::*;
92877b6f6eSTrevor Gross 
93877b6f6eSTrevor Gross         prelude!();
9492b24f5fSStefan Lankes     } else if #[cfg(target_os = "hermit")] {
95e2f92909SAphek         mod primitives;
96e2f92909SAphek         pub use crate::primitives::*;
9708a45197Sgnzlbg 
98585d45a1SStefan Lankes         mod hermit;
99643182f7SEduardo Sánchez Muñoz         pub use crate::hermit::*;
100877b6f6eSTrevor Gross 
101877b6f6eSTrevor Gross         prelude!();
102f054dcfeS袁浩     } else if #[cfg(target_os = "teeos")] {
103e2f92909SAphek         mod primitives;
104e2f92909SAphek         pub use primitives::*;
105f054dcfeS袁浩 
106f054dcfeS袁浩         mod teeos;
107f054dcfeS袁浩         pub use teeos::*;
108877b6f6eSTrevor Gross 
109877b6f6eSTrevor Gross         prelude!();
1105b539cebSTrevor Gross     } else if #[cfg(target_os = "trusty")] {
111e2f92909SAphek         mod primitives;
112e2f92909SAphek         pub use crate::primitives::*;
1135b539cebSTrevor Gross 
1145b539cebSTrevor Gross         mod trusty;
115643182f7SEduardo Sánchez Muñoz         pub use crate::trusty::*;
116877b6f6eSTrevor Gross 
117877b6f6eSTrevor Gross         prelude!();
11821503efaSYu Ding     } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
119e2f92909SAphek         mod primitives;
120e2f92909SAphek         pub use crate::primitives::*;
12108a45197Sgnzlbg 
12292172d91Sgnzlbg         mod sgx;
123643182f7SEduardo Sánchez Muñoz         pub use crate::sgx::*;
124877b6f6eSTrevor Gross 
125877b6f6eSTrevor Gross         prelude!();
12630ed9835SDan Gohman     } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
127e2f92909SAphek         mod primitives;
128e2f92909SAphek         pub use crate::primitives::*;
12908a45197Sgnzlbg 
13087def1fbSAlex Crichton         mod wasi;
131643182f7SEduardo Sánchez Muñoz         pub use crate::wasi::*;
132877b6f6eSTrevor Gross 
133877b6f6eSTrevor Gross         prelude!();
134be1d79deSSean Cross     } else if #[cfg(target_os = "xous")] {
135e2f92909SAphek         mod primitives;
136e2f92909SAphek         pub use crate::primitives::*;
137be1d79deSSean Cross 
138be1d79deSSean Cross         mod xous;
139643182f7SEduardo Sánchez Muñoz         pub use crate::xous::*;
140877b6f6eSTrevor Gross 
141877b6f6eSTrevor Gross         prelude!();
14266c33753SKamal Marhubi     } else {
1435c1a6b8aSgnzlbg         // non-supported targets: empty...
14450a42e20SAlex Crichton     }
14550a42e20SAlex Crichton }
146