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