• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 )]
16 #![cfg_attr(libc_deny_warnings, deny(warnings))]
17 // Attributes needed when building as part of the standard library
18 #![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))]
19 #![cfg_attr(libc_thread_local, feature(thread_local))]
20 // Enable extra lints:
21 #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))]
22 #![deny(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 #![cfg_attr(libc_const_extern_fn_unstable, feature(const_extern_fn))]
26 
27 #[macro_use]
28 mod macros;
29 
30 cfg_if! {
31     if #[cfg(feature = "rustc-dep-of-std")] {
32         extern crate rustc_std_workspace_core as core;
33         #[allow(unused_imports)]
34         use core::iter;
35         #[allow(unused_imports)]
36         use core::ops;
37         #[allow(unused_imports)]
38         use core::option;
39     }
40 }
41 
42 cfg_if! {
43     if #[cfg(libc_priv_mod_use)] {
44         #[cfg(libc_core_cvoid)]
45         #[allow(unused_imports)]
46         use core::ffi;
47         #[allow(unused_imports)]
48         use core::fmt;
49         #[allow(unused_imports)]
50         use core::hash;
51         #[allow(unused_imports)]
52         use core::num;
53         #[allow(unused_imports)]
54         use core::mem;
55         #[doc(hidden)]
56         #[allow(unused_imports)]
57         use core::clone::Clone;
58         #[doc(hidden)]
59         #[allow(unused_imports)]
60         use core::marker::{Copy, Send, Sync};
61         #[doc(hidden)]
62         #[allow(unused_imports)]
63         use core::option::Option;
64     } else {
65         #[doc(hidden)]
66         #[allow(unused_imports)]
67         pub use core::fmt;
68         #[doc(hidden)]
69         #[allow(unused_imports)]
70         pub use core::hash;
71         #[doc(hidden)]
72         #[allow(unused_imports)]
73         pub use core::num;
74         #[doc(hidden)]
75         #[allow(unused_imports)]
76         pub use core::mem;
77         #[doc(hidden)]
78         #[allow(unused_imports)]
79         pub use core::clone::Clone;
80         #[doc(hidden)]
81         #[allow(unused_imports)]
82         pub use core::marker::{Copy, Send, Sync};
83         #[doc(hidden)]
84         #[allow(unused_imports)]
85         pub use core::option::Option;
86     }
87 }
88 
89 cfg_if! {
90     if #[cfg(windows)] {
91         mod fixed_width_ints;
92         pub use fixed_width_ints::*;
93 
94         mod windows;
95         pub use windows::*;
96     } else if #[cfg(target_os = "fuchsia")] {
97         mod fixed_width_ints;
98         pub use fixed_width_ints::*;
99 
100         mod fuchsia;
101         pub use fuchsia::*;
102     } else if #[cfg(target_os = "switch")] {
103         mod fixed_width_ints;
104         pub use fixed_width_ints::*;
105 
106         mod switch;
107         pub use switch::*;
108     } else if #[cfg(target_os = "psp")] {
109         mod fixed_width_ints;
110         pub use fixed_width_ints::*;
111 
112         mod psp;
113         pub use psp::*;
114     } else if #[cfg(target_os = "vxworks")] {
115         mod fixed_width_ints;
116         pub use fixed_width_ints::*;
117 
118         mod vxworks;
119         pub use vxworks::*;
120     } else if #[cfg(target_os = "solid_asp3")] {
121         mod fixed_width_ints;
122         pub use fixed_width_ints::*;
123 
124         mod solid;
125         pub use solid::*;
126     } else if #[cfg(unix)] {
127         mod fixed_width_ints;
128         pub use fixed_width_ints::*;
129 
130         mod unix;
131         pub use unix::*;
132     } else if #[cfg(target_os = "hermit")] {
133         mod fixed_width_ints;
134         pub use fixed_width_ints::*;
135 
136         mod hermit;
137         pub use hermit::*;
138     } else if #[cfg(target_os = "teeos")] {
139         mod fixed_width_ints;
140         pub use fixed_width_ints::*;
141 
142         mod teeos;
143         pub use teeos::*;
144     } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
145         mod fixed_width_ints;
146         pub use fixed_width_ints::*;
147 
148         mod sgx;
149         pub use sgx::*;
150     } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
151         mod fixed_width_ints;
152         pub use fixed_width_ints::*;
153 
154         mod wasi;
155         pub use wasi::*;
156     } else if #[cfg(target_os = "xous")] {
157         mod fixed_width_ints;
158         pub use fixed_width_ints::*;
159 
160         mod xous;
161         pub use xous::*;
162     } else {
163         // non-supported targets: empty...
164     }
165 }
166