xref: /rust-libc-0.2.174/src/lib.rs (revision ef39104f)
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: 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 // Enable extra lints:
25 #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))]
26 #![deny(missing_copy_implementations, safe_packed_borrows)]
27 #![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)]
28 #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
29 
30 #[macro_use]
31 mod macros;
32 
33 cfg_if! {
34     if #[cfg(feature = "rustc-dep-of-std")] {
35         extern crate rustc_std_workspace_core as core;
36         #[allow(unused_imports)]
37         use core::iter;
38         #[allow(unused_imports)]
39         use core::ops;
40         #[allow(unused_imports)]
41         use core::option;
42     }
43 }
44 
45 #[doc(hidden)]
46 #[allow(unused_imports)]
47 use core::clone::Clone;
48 #[allow(unused_imports)]
49 use core::ffi;
50 #[allow(unused_imports)]
51 use core::fmt;
52 #[allow(unused_imports)]
53 use core::hash;
54 #[doc(hidden)]
55 #[allow(unused_imports)]
56 use core::marker::{Copy, Send, Sync};
57 #[allow(unused_imports)]
58 use core::mem;
59 #[allow(unused_imports)]
60 use core::num;
61 #[doc(hidden)]
62 #[allow(unused_imports)]
63 use core::option::Option;
64 
65 pub use core::ffi::c_void;
66 
67 cfg_if! {
68     if #[cfg(windows)] {
69         mod fixed_width_ints;
70         pub use fixed_width_ints::*;
71 
72         mod windows;
73         pub use windows::*;
74     } else if #[cfg(target_os = "fuchsia")] {
75         mod fixed_width_ints;
76         pub use fixed_width_ints::*;
77 
78         mod fuchsia;
79         pub use fuchsia::*;
80     } else if #[cfg(target_os = "switch")] {
81         mod fixed_width_ints;
82         pub use fixed_width_ints::*;
83 
84         mod switch;
85         pub use switch::*;
86     } else if #[cfg(target_os = "psp")] {
87         mod fixed_width_ints;
88         pub use fixed_width_ints::*;
89 
90         mod psp;
91         pub use psp::*;
92     } else if #[cfg(target_os = "vxworks")] {
93         mod fixed_width_ints;
94         pub use fixed_width_ints::*;
95 
96         mod vxworks;
97         pub use vxworks::*;
98     } else if #[cfg(target_os = "solid_asp3")] {
99         mod fixed_width_ints;
100         pub use fixed_width_ints::*;
101 
102         mod solid;
103         pub use solid::*;
104     } else if #[cfg(unix)] {
105         mod fixed_width_ints;
106         pub use fixed_width_ints::*;
107 
108         mod unix;
109         pub use unix::*;
110     } else if #[cfg(target_os = "hermit")] {
111         mod fixed_width_ints;
112         pub use fixed_width_ints::*;
113 
114         mod hermit;
115         pub use hermit::*;
116     } else if #[cfg(target_os = "teeos")] {
117         mod fixed_width_ints;
118         pub use fixed_width_ints::*;
119 
120         mod teeos;
121         pub use teeos::*;
122     } else if #[cfg(target_os = "trusty")] {
123         mod fixed_width_ints;
124         pub use fixed_width_ints::*;
125 
126         mod trusty;
127         pub use trusty::*;
128     } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
129         mod fixed_width_ints;
130         pub use fixed_width_ints::*;
131 
132         mod sgx;
133         pub use sgx::*;
134     } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
135         mod fixed_width_ints;
136         pub use fixed_width_ints::*;
137 
138         mod wasi;
139         pub use wasi::*;
140     } else if #[cfg(target_os = "xous")] {
141         mod fixed_width_ints;
142         pub use fixed_width_ints::*;
143 
144         mod xous;
145         pub use xous::*;
146     } else {
147         // non-supported targets: empty...
148     }
149 }
150