• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #![allow(
9     renamed_and_removed_lints, // Keep this order.
10     unknown_lints, // Keep this order.
11     bad_style,
12     overflowing_literals,
13     improper_ctypes,
14     // This lint is renamed but we run CI for old stable rustc so should be here.
15     redundant_semicolon,
16     redundant_semicolons,
17     unused_macros,
18     unused_macro_rules,
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 #![cfg_attr(libc_const_extern_fn_unstable, feature(const_extern_fn))]
30 
31 #[macro_use]
32 mod macros;
33 
34 cfg_if! {
35     if #[cfg(feature = "rustc-dep-of-std")] {
36         extern crate rustc_std_workspace_core as core;
37         #[allow(unused_imports)]
38         use core::iter;
39         #[allow(unused_imports)]
40         use core::ops;
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, Send, Sync};
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, Send, Sync};
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 = "fuchsia")] {
101         mod fixed_width_ints;
102         pub use fixed_width_ints::*;
103 
104         mod fuchsia;
105         pub use fuchsia::*;
106     } else if #[cfg(target_os = "switch")] {
107         mod fixed_width_ints;
108         pub use fixed_width_ints::*;
109 
110         mod switch;
111         pub use switch::*;
112     } else if #[cfg(target_os = "psp")] {
113         mod fixed_width_ints;
114         pub use fixed_width_ints::*;
115 
116         mod psp;
117         pub use psp::*;
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(target_os = "solid_asp3")] {
125         mod fixed_width_ints;
126         pub use fixed_width_ints::*;
127 
128         mod solid;
129         pub use solid::*;
130     } else if #[cfg(unix)] {
131         mod fixed_width_ints;
132         pub use fixed_width_ints::*;
133 
134         mod unix;
135         pub use unix::*;
136     } else if #[cfg(target_os = "hermit")] {
137         mod fixed_width_ints;
138         pub use fixed_width_ints::*;
139 
140         mod hermit;
141         pub use hermit::*;
142     } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
143         mod fixed_width_ints;
144         pub use fixed_width_ints::*;
145 
146         mod sgx;
147         pub use sgx::*;
148     } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
149         mod fixed_width_ints;
150         pub use fixed_width_ints::*;
151 
152         mod wasi;
153         pub use wasi::*;
154     } else {
155         // non-supported targets: empty...
156     }
157 }
158