xref: /rust-libc-0.2.174/src/lib.rs (revision 4134091e)
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(1.0): 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 #![cfg_attr(feature = "rustc-dep-of-std", allow(internal_features))]
25 // DIFF(1.0): The thread local references that raise this lint were removed in 1.0
26 #![cfg_attr(feature = "rustc-dep-of-std", allow(static_mut_refs))]
27 // Enable extra lints:
28 #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))]
29 #![deny(missing_copy_implementations, safe_packed_borrows)]
30 #![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)]
31 #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
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     }
40 }
41 
42 pub use core::ffi::c_void;
43 
44 cfg_if! {
45     if #[cfg(windows)] {
46         mod primitives;
47         pub use crate::primitives::*;
48 
49         mod windows;
50         pub use crate::windows::*;
51 
52         prelude!();
53     } else if #[cfg(target_os = "fuchsia")] {
54         mod primitives;
55         pub use crate::primitives::*;
56 
57         mod fuchsia;
58         pub use crate::fuchsia::*;
59 
60         prelude!();
61     } else if #[cfg(target_os = "switch")] {
62         mod primitives;
63         pub use primitives::*;
64 
65         mod switch;
66         pub use switch::*;
67 
68         prelude!();
69     } else if #[cfg(target_os = "psp")] {
70         mod primitives;
71         pub use primitives::*;
72 
73         mod psp;
74         pub use crate::psp::*;
75 
76         prelude!();
77     } else if #[cfg(target_os = "vxworks")] {
78         mod primitives;
79         pub use crate::primitives::*;
80 
81         mod vxworks;
82         pub use crate::vxworks::*;
83 
84         prelude!();
85     } else if #[cfg(target_os = "solid_asp3")] {
86         mod primitives;
87         pub use crate::primitives::*;
88 
89         mod solid;
90         pub use crate::solid::*;
91 
92         prelude!();
93     } else if #[cfg(unix)] {
94         mod primitives;
95         pub use crate::primitives::*;
96 
97         mod unix;
98         pub use crate::unix::*;
99 
100         prelude!();
101     } else if #[cfg(target_os = "hermit")] {
102         mod primitives;
103         pub use crate::primitives::*;
104 
105         mod hermit;
106         pub use crate::hermit::*;
107 
108         prelude!();
109     } else if #[cfg(target_os = "teeos")] {
110         mod primitives;
111         pub use primitives::*;
112 
113         mod teeos;
114         pub use teeos::*;
115 
116         prelude!();
117     } else if #[cfg(target_os = "trusty")] {
118         mod primitives;
119         pub use crate::primitives::*;
120 
121         mod trusty;
122         pub use crate::trusty::*;
123 
124         prelude!();
125     } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
126         mod primitives;
127         pub use crate::primitives::*;
128 
129         mod sgx;
130         pub use crate::sgx::*;
131 
132         prelude!();
133     } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
134         mod primitives;
135         pub use crate::primitives::*;
136 
137         mod wasi;
138         pub use crate::wasi::*;
139 
140         prelude!();
141     } else if #[cfg(target_os = "xous")] {
142         mod primitives;
143         pub use crate::primitives::*;
144 
145         mod xous;
146         pub use crate::xous::*;
147 
148         prelude!();
149     } else {
150         // non-supported targets: empty...
151     }
152 }
153